简体   繁体   中英

Send request to google maps api

when I get the coordinates, I need send request like this:

http://maps.googleapis.com/maps/api/geocode/json?latlng=55.75320193022759,37.61922086773683&sensor=false&language=ru

, but how i can send this in JavaScript?

If you are using the Google Maps API v3 use the geocoding service

var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(55.75320193022759, 37.61922086773683);

geocoder.geocode({'latLng': latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        alert(results[1].formatted_address);
    } else {
        alert("Geocoder failed due to: " + status);
    }
});

See: https://developers.google.com/maps/documentation/javascript/geocoding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM