2011-07-14 9 views
3

ロケーション名を渡すことができるgoogle maps apiはありますか?それはgooglemapsの場所を示す座標を返しますか?良いgoogle.maps geolocation api?

+0

私は、Google Maps Data APIがもう使用できなくなったことさえ知りませんでした:http://code.google.com/intl/nl/apis/maps/documentation/mapsdata/これらは代替手段を提供しています。 – Harmen

答えて

0

いいえ、逆ジオロケーションを使用する必要があります。あなたは住所または位置の文字列を送ることができ、それは可能な緯度/経度座標の配列を与えます。これらはGeocoderResultsで、通常は最初のものがあなたが望むものです。あなたが米国を望んでいた場合と同様に、あなたはここで

geocoder.geocode({'address': 'USA' }, function(results, status) { 
    response($.map(results, function(item) { 
    var latlng = new google.maps.LatLng(item.geometry.location.lat(), item.geometry.location.lng()); 
    //Do some action with the provided latlng 
    })); 
}); 
2

を行うことができます。ここThe Google Geocoding API

は、例えば、要求されている。

http://maps.googleapis.com/maps/api/geocode/xml?address=Berlin&sensor=false

あなたは結果をフィルタリングすることができます:geometry/location/latlngのために

<GeocodeResponse> 
    <status>OK</status> 
    <result> 
    <type>locality</type> 
    <type>political</type> 
    <formatted_address>Berlin, Deutschland</formatted_address> 
    […] 
    <geometry> 
     <location> 
     <lat>52.5234051</lat> 
     <lng>13.4113999</lng> 
     </location> 
     <location_type>APPROXIMATE</location_type> 
     <viewport>[…]</viewport> 
     <bounds>[…]</bounds> 
    </geometry> 
    </result> 
</GeocodeResponse> 
0

マフィアa同じ無料サービスを提供しています。 mappy.comを見て、残りのAPIを検索してください。