2017-01-30 76 views

回答

2

如果我明白你的問題是正確的,你可以簡單地設置一個componentRestrictions。看起來是這樣的:

doGeocode: function (address, postal_code, callback) { 
    console.log("TEST: " + address.toString()); 
    var geocoder = new google.maps.Geocoder(); 
    geocoder.geocode({ 
     'address': address, 
     'componentRestrictions': { 
      'postalCode': postal_code, 
      'country': 'de' //change this to the Code of Ukraine 
     } 
    }, function (results, status) { 
     if (status === google.maps.GeocoderStatus.OK) { 
      console.log(results); 
      callback(results); 
     } else { 
      //Error handling 
      alert('Geocode was not successful for the following reason: ' + status); 
     } 
    }); 

注:當然,你要在這裏設置爲烏克蘭國家代碼。而且,因爲你沒有提到你有哪些地址或緯度/經度,所以我給了你一個地址的例子。

相關問題