Google's Geocoder returns wrong country, ignoring the region hint

后端 未结 13 1050
孤城傲影
孤城傲影 2020-12-07 21:03

I\'m using Google\'s Geocoder to find lat lng coordinates for a given address.

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode(
    {
            


        
13条回答
  •  被撕碎了的回忆
    2020-12-07 21:39

    I always found this to be pretty easy to filter through since the results can vary and the region doesn't seem to work.

    response( $.map( results, function( item ) {
     if (item.formatted_address.indexOf("GB") != -1) {
        return {
          latitude: item.geometry.location.lat(),
          longitude: item.geometry.location.lng()
        }
      }
    }
    

提交回复
热议问题