<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=高德地图key&plugin=AMap.Geocoder"></script>
<script>
  $("#xi-address").on(\'click\',function(){
    var address = $("#address").val();
    layer.msg(\'地址解析中...\');
      AMap.plugin(\'AMap.Geocoder\', function() {
        var geocoder = new AMap.Geocoder({ })
        geocoder.getLocation( address, function(status, result) {
          if (status === \'complete\' && result.info === \'OK\') {
            layer.msg(\'地址解析成功!\');
            var x = result.geocodes[\'0\'].location.lng;
            var y = result.geocodes[\'0\'].location.lat;
            $("#lng").val(x+\',\'+y);
          } else {
            layer.msg(\'您输入的地址没有解析到结果!\');
          }
        })
      })
  });
    
</script>

  

版权声明:本文为gumo9原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/gumo9/p/14110644.html