<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=bhgBdlyi2yG3On1T6nrpg8vb"></script> <script type="text/javascript"> var map = new BMap.Map("allmap"), gc = new BMap.Geocoder; function getaddress(c, d) { var e = new BMap.Point(d, c), f = new BMap.Convertor, g = []; g.push(e); f.translate(g, 1, 5,function(c) { gc.getLocation(e,function(c) { var f = c.addressComponents.city; if(f != ''){ } $(".location-text").text(f).removeClass("location-no").addClass("location-ok"); $("#hidaddress").val(c.addressComponents.city+c.addressComponents.district) }) }) } if(navigator.geolocation) { navigator.geolocation.getCurrentPosition( function(position) { lng = position.coords.longitude; lat = position.coords.latitude; getaddress(lat,lng); }, function() { } ); } </script>
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com