JS Gaode map API obtains the latitude and longitude of the address according to the address

Time:2021-3-15
var location = [];
function getAddrGeo(addr) {
  //Get the latitude and longitude of an address, which can be used for mobile terminal to jump app navigation
  $.ajax({
    type: "GET",
    url:
      " http://restapi.amap.com/v3/geocode/geo?key= Your key & S = rsv3 & address = "+
      addr.trim(),
    success: function (response) {
      location =
        response.geocodes[0] && response.geocodes[0].location.split(",");
    },
    error: function (e) {
      console.log (address coordinate acquisition failed, e);
    },
  });
}

When you want to get the longitude and latitude information of the current position on the development mobile terminal, Gaode has an interface, but you should pay attention to Gaode’s coordinate system. If you want to use other maps, you may have to convert them. It seems that it is IP positioning, and there may be some small deviations