复制代码 代码如下: http://www.w3.org/1999/xhtml"> 根据地址查询经纬度 ">http://api.map.baidu.com/api?v=1.3">> 要查询的地址: 查询结果(经纬度): style="position: absolute; margin-top:30px; width: 730px; height: 590px; top: 50; border: 1px solid gray; overflow:hidden;"> <br /> var map = new BMap.Map("container");<br /> map.centerAndZoom("徐州", 12);<br /> map.enableScrollWheelZoom(); //启用滚轮放大缩小,默认禁用<br /> map.enableContinuousZoom(); //启用地图惯性拖拽,默认禁用<br /> map.addControl(new BMap.NavigationControl()); //添加默认缩放平移控件<br /> map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件<br /> map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); //右下角,打开<br /> var localSearch = new BMap.LocalSearch(map);<br /> localSearch.enableAutoViewport(); //允许自动调节窗体大小<br /> function searchByStationName() {<br /> map.clearOverlays();//清空原来的标注<br /> var keyword = document.getElementById("text_").value;<br /> localSearch.setSearchCompleteCallback(function (searchResult) {<br /> var poi = searchResult.getPoi(0);<br /> document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;<br /> map.centerAndZoom(poi.point, 13);<br /> var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat)); // 创建标注,为要查询的地方对应的经纬度<br /> map.addOverlay(marker);<br /> var content = document.getElementById("text_").value + "<br/><br/>经度:" + poi.point.lng + "<br/>纬度:" + poi.point.lat;<br /> var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + content + "");<br /> marker.addEventListener("click", function () { this.openInfoWindow(infoWindow); });<br /> // marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画<br /> });<br /> localSearch.search(keyword);<br /> } <br /> 以上就是代码的全部内容了,小伙伴们可以直接使用在项目中哦,不用跟我说谢谢,请叫我雷锋大大~