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

后端 未结 13 1018
孤城傲影
孤城傲影 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:51

    UPDATE: This answer may not be the best approach anymore. See the comments below the answer for more details.


    In addition to what Pekka already suggested, you may want to concatenate ', UK' to your address, as in the following example:

    
     
     
        
       Google Maps Geocoding only in UK Demo 
        
     
     
       

    Screenshot:

    Geocoding only in UK

    I find that this is very reliable. On the other hand, the following example shows that neither the region parameter, nor the bounds parameter, are having any effect in this case:

    
     
     
        
       Google Maps Geocoding only in UK Demo with Bounds 
        
     
     
       

提交回复
热议问题