我面临着谷歌地理编码API服务的奇怪问题 . 我正在请求 "48 spottiswoode residences, spottiwood park, Singapore 088660" 地址,其API分别返回lat = 1.345871和lng = 103.75089739999999 . 但是,谷歌 Map 显示lat = 1.2752757和lng = 103.8346363为同一地址 .
请求网址:
响应:
{ "results" : [
{
"address_components" : [
{
"long_name" : "Singapore",
"short_name" : "Singapore",
"types" : [ "route" ]
},
{
"long_name" : "Bukit Batok",
"short_name" : "Bukit Batok",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "Singapore",
"short_name" : "Singapore",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Singapore",
"short_name" : "SG",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Singapore, Singapore",
"geometry" : {
"location" : {
"lat" : 1.345871,
"lng" : 103.7508974
},
"location_type" : "GEOMETRIC_CENTER",
"viewport" : {
"northeast" : {
"lat" : 1.347219980291502,
"lng" : 103.7522463802915
},
"southwest" : {
"lat" : 1.344522019708498,
"lng" : 103.7495484197085
}
}
},
"partial_match" : true,
"place_id" : "ChIJOfDA4T8Q2jERL48IW_56xww",
"types" : [ "route" ]
}
],
"status" : "OK"
}
提前致谢 .
2 回答
提供的地址似乎不正确(正确的地址是 48 Spottiswoode Park Road, Singapur 088660 )
要获得类似的结果maps.google.com(即使地址错误),您应该使用Places.TextSearch:
您没有在请求中传递完整地址 . 缺少第一部分 48 spottiswoode residences, spottiwood park
http://maps.googleapis.com/maps/api/js/GeocodeService.Search?4sSingapore%2C%20088660&7sUS&8m2&1scountry&2sSingapore&9sen-US&callback=xdc._wo127a&token=117480
你需要url编码,以获得正确的位置 .