-1
複数の郵便番号から緯度と経度を取得したいが、郵便番号配列をループしてgeocoder.geocodeメソッドを呼び出すと、同じ緯度と経度値が返される。私のソースコードは、上記ソースコードの結果は、上記の結果の出力、第2の緯度と経度、3は同じ値であり、第5の緯度と経度でGoogle map api geocoder.geocode同じ値を返す
PostCode: ON N6A 1A1
Latitude: 42.9975524
Longtitude: -81.25463660000003
PostCode: ON N6J 2J8
Latitude: 42.9535959
Longtitude: -81.27941229999999
PostCode: ON N6J 1H6
Latitude: 42.9535959
Longtitude: -81.27941229999999
PostCode: ON N6C 3P4
Latitude: 42.9730003
Longtitude: -81.2540343
PostCode: ON N6B 2K9
Latitude: 42.9818077
Longtitude: -81.23811510000002
PostCode: ON N6B 1L4
Latitude: 42.9818077
Longtitude: -81.23811510000002
PostCode: ON N6C 4M8
Latitude: 42.9711174
Longtitude: -81.2363939
ある
var postcodeList = [
{postcode: "ON N6A 1A1", name: "1. Lawson Cafe"},
{postcode: "ON N6J 2J8", name: "2. LA Cafe"},
{postcode: "ON N6J 1H6", name: "3. Frangos COffee Shop"},
{postcode: "ON N6C 3P4", name: "4. Cortado"},
{postcode: "ON N6B 2K9", name: "5. Walker's Restaurant"},
{postcode: "ON N6B 1L4", name: "6. Kambie Chinese Restaurant"},
{postcode: "ON N6C 4M8", name: "7. Curry's Restaurant"}
];
var googleMap;
function initialize() {
googleMap = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
mapTypeControl: false,
center: new google.maps.LatLng(51.509865, -0.118092),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
for (i = 0; i < postcodeList.length; i++) {
searchAddress(postcodeList[i].postcode);
}
}
function searchAddress(postcode) {
var geocoder = new google.maps.Geocoder();
var location;
geocoder.geocode({'address': postcode}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log("PostCode: " + postcode);
console.log(" Latitude: " + results[0].geometry.location.lat());
console.log(" Longtitude: " + results[0].geometry.location.lng());
} else {
console.log("Geocode was not successful for the following reason: " + status);
}
});
}
未満であります、6番目も同じ値です。 私はなぜ助けてください助けてください
なぜあなたはそれらが異なっているべきだと思いますか? – geocodezip
@geocodezip - 異なる郵便番号を使用すると、別の場所が表示される –
私は、問題は郵便番号の書式設定であり、Googleは郵便番号の位置をスペース(FSA)に戻していたということです。 – geocodezip