Software Archive
Read-only legacy content
17060 ディスカッション

reverse geocoding latitude and longitude

Oonagh_M_1
ビギナー
728件の閲覧回数

i currently have the following code in my JavaScript file. When i run the app, the 'reverse geocode' button appears, which i click on. Once i click on the button the following error appears: "Geocoder failed due to: ZERO_RESULTS. Am i missing something?

This has been testing on my mobile device and the error is also appearing. Any help would be appreciated. Thank you.

 

 

function click_button_reverseGeo(currentLatitude, currentLongitude){
  var latlng = new google.maps.LatLng(currentLatitude, currentLongitude);
  var geocoder = new google.maps.Geocoder();
  geocoder.geocode({'latLng': latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      if (results[1]) {
        alert(results[1].formatted_address);
      } else {
        alert('No results found');
      }
    } else {
      alert('Geocoder failed due to: ' + status);
    }
  });
}
0 件の賞賛
1 返信
Michael_O_2
新規コントリビューター I
728件の閲覧回数

Hello.

Make a call to maps.googleapis.com/geocode/xml from  your server after getting the latlng.

Geocoding service will give you appropriate results when you send a request from your back end.

返信