2011-07-19 7 views
4

ユーザーがイギリス、スコットランド、アイルランドなどの緯度/経度からアクセスしているかどうかを調べる必要があります。イギリスの代わりにイングランド、スコットランドなどを緯度/経度から返します

しかし、私はGoogle Maps APIを使用していますが、これはイギリスを返します。

Googleマップでこれを行う方法はありますか、それとも個々の国を返すAPIがありますか?

答えて

1

リージョンごとに境界ポリゴンを定義し、緯度/経度が内側にあるかどうかを確認できます。

https://github.com/tparkin/Google-Maps-Point-in-Polygon

+0

をそしてあなたが選択した英国の都市に緯度/経度の値を使用することができます大面積ポリゴンの定義に役立ちます。 http://www.mapsofworld.com/lat_long/united-kingdom/united-kingdom-lat-long.htmlを参照してください。 – seasonedgeek

+0

各国の境界をどのように知ることができますか? :S – Curt

+0

境界線に沿ってポリゴンを描画します。私はそれが100%正確である必要はないと思います。簡単な例:http://maps.google.com/maps/ms?authuser=0&vps=5&ie=UTF8&msa=0&output=kml&msid=210482407182953405460.0004a8913a611c22ee21c –

0

私は

var gc = new google.maps.Geocoder(); 
gc.geocode({'location': ll}, function(results, status) { 
     if (status == google.maps.GeocoderStatus.OK) { 
      if (results[0]) {  
       var results = results[0].address_components; 
      } 
     } 
    }); 

と、このような結果にその表情使用geocode

を試してみてください。

results[0].formatted_address: "275-291 Bedford Ave, Brooklyn, NY 11211, USA", 
results[1].formatted_address: "Williamsburg, NY, USA", 
results[2].formatted_address: "New York 11211, USA", 
results[3].formatted_address: "Kings, New York, USA", 
results[4].formatted_address: "Brooklyn, New York, USA", 
results[5].formatted_address: "New York, New York, USA", 
results[6].formatted_address: "New York, USA", 
results[7].formatted_address: "United States" 
+0

これはまだイギリスを返すと思いますか? – Curt

+0

これはlat-long値に依存し、lat-long値を入力してからgeocode結果を返します –

+0

戻り値はLat/Long値によって異なりますが、現在はイギリスに位置しています。このスクリプトに私の緯度/経度の値を入れたいのであれば、それは "英国"を返しますが、私はより具体的な情報(すなわちイングランド)が必要ですが、 – Curt

関連する問題