html部分:
<div class="sign_add_left" style="height:123px;border:#ccc solid 1px;" id="dituContent"></div>
js部分:
<script type="text/javascript" src="http://api./api?v=2.0&ak=134db1b9cf1f1f2b4427210932b34dcb"></script><script type="text/javascript">var map = new BMap.Map("dituContent");var point = new BMap.Point(lng, lat);map.centerAndZoom(point, 12);map.enableScrollWheelZoom();var geolocation = new BMap.Geolocation();geolocation.getCurrentPosition(function (r) {if (this.getStatus() == BMAP_STATUS_SUCCESS) {var mk = new BMap.Marker(r.point);map.addOverlay(mk);map.panTo(r.point);var pt = r.point;var gc = new BMap.Geocoder();gc.getLocation(pt, function(rs){var addComp = rs.addressComponents;detail_address = addComp.district + addComp.street + addComp.streetNumber;address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;$("#address1").text(detail_address);$("#address2").text(address);})document.getElementById("lat").value = r.point.lat;document.getElementById("lng").value = r.point.lng;//document.getElementById("h3").innerHTML = "";}else {alert('failed' + this.getStatus());}})</script>