GoogleマップAPIを使用して場所から追加情報を抽出しようとしています。私は見て、それは可能ですが、私はどこで境界パラメータを配置する必要がありますよく理解していない。これは私の要求です:google apiを使用して地域を抽出します
var address = document.getElementById("address").value;
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
alert(results[0].formatted_address);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
「アドレス」の後にバインドを追加するとします。私はそれでtryiedが、それは動作しますしません:
geocoder.geocode({ 'address': address, "types":["sublocality","political"]}, function(results, status) {
イタリアの州に精通している場合、私は知らないが、私はそのような何かが必要です。
要求:ベネチア
応答:VEやベネチア
要求:ムラーノ
応答:VEやベネチア
----の改善:
私はこの取得でき http://maps.googleapis.com/maps/api/geocode/json?address=murano&sensor=false使用:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Murano",
"short_name" : "Murano",
"types" : [ "natural_feature" ]
},
{
"long_name" : "Venezia",
"short_name" : "Venezia",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Venezia",
"short_name" : "VE",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Veneto",
"short_name" : "Veneto",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Italia",
"short_name" : "IT",
"types" : [ "country", "political" ]
},
{
"long_name" : "30141",
"short_name" : "30141",
"types" : [ "postal_code" ]
}
],
アラート(結果[0] .address_components)を使用して印刷しようとします。それは私がこれを抽出することができますどのように、私には何も表示されません。
"long_name" : "Venezia",
"short_name" : "VE",
"types" : [ "administrative_area_level_2", "political" ]
おかげで、 アンドレア
それは動作します:結果[0] .address_components [1] .short_name; –