2011-10-27 15 views

答えて

1

私は同様の問題を抱えていたし、ここにコードを投稿:

how to use the google maps api with greasemonkey to read a table of addresses and trace the route?

は見てください、それはあなたを助けているかどうかを確認。

以下のコードは州を返すためにアメリカの郵便番号を使用していますが、あなたのニーズに合わせて変更することができます。

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

function getState(zipcode) { 
    geocoder.geocode({ 'address': zipcode}, function (result, status) { 
     var state = "N/A"; 
     for (var component in result[0]['address_components']) { 
      for (var i in result[0]['address_components'][component]['types']) { 
       if (result[0]['address_components'][component]['types'][i] == "administrative_area_level_1") { 
        state = result[0]['address_components'][component]['short_name']; 
        // do stuff with the state here! 
        document.getElementById('state').innerHTML = state; 
        return; 
       } 
      } 
     } 
    }); 
} 

--- EDITED [28/10/2011] ---

OK。非常に単純な例で、コードは必要ありません。
click here

あなたがしなければならないことはcenter=SW1A,UKと書かれているSW1Aです。
傾きはそれよりも簡単になります:)

+0

応答に感謝します...しかし、私はまだ少し失われています。 – Adam

+0

私の答えを編集しました。見てみましょう。 – RASG

関連する問題