zoukankan      html  css  js  c++  java
  • 百度地图失去坐标html

    <html>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
            body,
            html {
                 100%;
                height: 100%;
                margin: 0;
                font-family: "微软雅黑";
            }
    
            #allmap {
                height: 700px;
                 100%;
            }
    
            #r-result {
                 100%;
                font-size: 14px;
            }
        </style>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=4IU3oIAMpZhfWZsMu7xzqBBAf6vMHcoa"></script>
        <title>城市名定位</title>
    </head>
    
    <body>
        <div id="allmap"></div>
        <div id="r-result">
            地址: <input id="cityName" type="text" style="100px; margin-right:10px;" />
            <input type="button" value="查询" onclick="theLocation()" />
                            经度:<input type="text" id="jd" />纬度<input type="text" id="wd" />
        </div>
    </body>
    
    </html>
    <script type="text/javascript">
        // 百度地图API功能
        var map = new BMap.Map("allmap", {
            mapType: BMAP_HYBRID_MAP,
            minZoom: 4,
            maxZoom: 25,
            enableMapClick:false
        });
        var point = new BMap.Point(116.331398, 39.897445);
        map.enableScrollWheelZoom(true);
        map.setDefaultCursor("crosshair");
        map.centerAndZoom('广州', 11);
        map.addEventListener("click", function (e) {
            var input = document.getElementById('wd');
            var input2 = document.getElementById('jd');
            input.value = e.point.lng;
            input2.value = e.point.lat;
        });
    
    
    
        map.addControl(new BMap.NavigationControl());
    
    
        var local = new BMap.LocalSearch(map, {
            renderOptions: {
                map: map
            }
        });
    
        function theLocation() {
            var city = document.getElementById("cityName").value;
            if (city != "") {
                local.search(city);
            }
        }
        var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});
        //添加控件和比例尺
    	function add_control(){
    		map.addControl(top_left_control);        
    		map.addControl(top_left_navigation);     
    		map.addControl(top_right_navigation);    
    	}
        add_control()
    </script>
    

      

    萌橙 你瞅啥?
  • 相关阅读:
    springboot
    POI/JFreeChart
    ssm(6)spring-test
    DBUtils与BeanUtils
    数据连接池C3P0/DBCP/DRUID/自定义连接池
    web核心(3)响应头请求头状态码及dns解析过程
    log4j/Logback/SLF4j
    ssm(4)整合
    列表字典元组方法
    第四天 Python基础语法 编码规范 变量
  • 原文地址:https://www.cnblogs.com/daimaxuejia/p/10748508.html
Copyright © 2011-2022 走看看