如果我这样做: http : //maps.googleapis.com/maps/api/geocode/json?address=kemayoran&sensor=false 这是我想要的结果,如果不是因为我希望它在访问者键入 kem 而不是 kemayoran 时起作用.
{
"results" : [
{
"address_components" : [
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta Pusat",
"short_name" : "Jakarta Pusat",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta",
"short_name" : "Jakarta",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Jakarta Capital Region",
"short_name" : "Jakarta Capital Region",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Indonesia",
"short_name" : "ID",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Kemayoran, Jakarta, Indonesia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -6.14935190,
"lng" : 106.8857620
},
"southwest" : {
"lat" : -6.171493900000001,
"lng" : 106.84546290
}
},
"location" : {
"lat" : -6.16165420,
"lng" : 106.8550150
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -6.14935190,
"lng" : 106.8857620
},
"southwest" : {
"lat" : -6.171493900000001,
"lng" : 106.84546290
}
}
},
"types" : [ "sublocality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "train_station", "transit_station", "establishment" ]
},
{
"long_name" : "Jalan Garuda",
"short_name" : "Jalan Garuda",
"types" : [ "route" ]
},
{
"long_name" : "Pasar Baru",
"short_name" : "Pasar Baru",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Sawah Besar",
"short_name" : "Sawah Besar",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta Pusat",
"short_name" : "Jakarta Pusat",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta",
"short_name" : "Jakarta",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Jakarta Capital Region",
"short_name" : "Jakarta Capital Region",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Indonesia",
"short_name" : "ID",
"types" : [ "country", "political" ]
},
{
"long_name" : "10710",
"short_name" : "10710",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Kemayoran, Jalan Garuda, Jakarta 10710, Indonesia",
"geometry" : {
"location" : {
"lat" : -6.16204140,
"lng" : 106.84154990
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -6.160692419708497,
"lng" : 106.8428988802915
},
"southwest" : {
"lat" : -6.163390380291502,
"lng" : 106.8402009197085
}
}
},
"types" : [ "train_station", "transit_station", "establishment" ]
},
{
"address_components" : [
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta Pusat",
"short_name" : "Jakarta Pusat",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Jakarta",
"short_name" : "Jakarta",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Jakarta Capital Region",
"short_name" : "Jakarta Capital Region",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Indonesia",
"short_name" : "ID",
"types" : [ "country", "political" ]
},
{
"long_name" : "10620",
"short_name" : "10620",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Kemayoran, Jakarta 10620, Indonesia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -6.1602730,
"lng" : 106.8572680
},
"southwest" : {
"lat" : -6.1664210,
"lng" : 106.851820
}
},
"location" : {
"lat" : -6.16165420,
"lng" : 106.8550150
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -6.1602730,
"lng" : 106.8572680
},
"southwest" : {
"lat" : -6.1664210,
"lng" : 106.851820
}
}
},
"types" : [ "sublocality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Krembangan",
"short_name" : "Krembangan",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Surabaya",
"short_name" : "Surabaya",
"types" : [ "locality", "political" ]
},
{
"long_name" : "East Java",
"short_name" : "East Java",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Indonesia",
"short_name" : "ID",
"types" : [ "country", "political" ]
},
{
"long_name" : "60176",
"short_name" : "60176",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Kemayoran, Surabaya 60176, Indonesia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -7.2369960,
"lng" : 112.7333040
},
"southwest" : {
"lat" : -7.2465120,
"lng" : 112.726760
}
},
"location" : {
"lat" : -7.2417540,
"lng" : 112.7300320
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -7.2369960,
"lng" : 112.7333040
},
"southwest" : {
"lat" : -7.2465120,
"lng" : 112.726760
}
}
},
"types" : [ "sublocality", "political" ]
},
{
"address_components" : [
{
"long_name" : "Kemayoran",
"short_name" : "Kemayoran",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Bangkalan",
"short_name" : "Bangkalan",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Bangkalan Regency",
"short_name" : "Bangkalan Regency",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "East Java",
"short_name" : "East Java",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Indonesia",
"short_name" : "ID",
"types" : [ "country", "political" ]
},
{
"long_name" : "69116",
"short_name" : "69116",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Kemayoran, Bangkalan 69116, Indonesia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -7.0243290,
"lng" : 112.7483040
},
"southwest" : {
"lat" : -7.039670,
"lng" : 112.7349340
}
},
"location" : {
"lat" : -7.031263999999999,
"lng" : 112.7417250
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -7.0243290,
"lng" : 112.7483040
},
"southwest" : {
"lat" : -7.039670,
"lng" : 112.7349340
}
}
},
"types" : [ "sublocality", "political" ]
}
],
"status" : "OK"
}
我有几个kemayoran。
如果我做:
http://maps.googleapis.com/maps/api/geocode/json?address=kemayoran&sensor=false&bounds=-6,106|-5,107
我得到了kemayoran。但是即使所有其他的kemayoran都在范围内,也只有一个。
我在第一次查询时正确指定了边界,因为正如大家所见,kemayoran 的纬度对数正好在 -6,106|-5,107 的范围内
如果我做
http://maps.googleapis.com/maps/api/geocode/json?address=kemay&sensor=false&bounds=-6,106|-5,107
我得到了 Kemnay 而不是 kemayoran。
与此私有 API 进行比较: http://maps.google.com/maps/suggest?q=kemay&cp=2&hl=en&gl=&v=2&clid=1&json=a&ll=-6.230664,106.55365&spn=1,1&src=1&num=20& numps =0
结果正是我想要的,只是它没有给出纬度和经度,更不用说是一个私有 API。
所以我该怎么做?