问题 -
人们根据自己的兴趣在各个地方发帖,而其他人则在更大范围内搜索帖子。
例如 - 用户 A 在悉尼郊区的邦迪海滩下发帖。
用户 B 在 Sydney 下搜索帖子。
期望的结果 - 用户 B 可以看到用户 A 的帖子,因为 Bondi 位于悉尼境内。
解决方案:
在 Google Places API 中查找它告诉您郊区 X 属于城市 Y 等等。
在我的示例中 - 我想获取有关邦迪的信息,告诉我它属于哪个城市。
这是我对邦迪海滩的简单查询(我使用自动完成,因为它是一个自动完成下拉菜单): https ://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=true&input=bondi%20beach&key=myKey
{
"predictions" : [
{
"description" : "Bondi Beach, New South Wales, Australia",
"id" : "ffa6ad484d2fec594378fb2a24e8328a2bc4459f",
"matched_substrings" : [
{
"length" : 11,
"offset" : 0
}
],
"place_id" : "ChIJWTi8xgGyEmsRgK0yFmh9AQU",
"reference" : "CkQ_AAAAMnfwZeK5SV6uPBnPr34JVdHudAGxMtna--JWHtwe7t81gLBGgsB6mRgmj375m7KReRhpMq1Y6AYxCrC2MnYn8hIQQfASvoG5-7LwRcVR7ELjNxoURh-iBs6M2dmrU8wLKIPcFFgymn4",
"terms" : [
{
"offset" : 0,
"value" : "Bondi Beach"
},
{
"offset" : 13,
"value" : "New South Wales"
},
{
"offset" : 30,
"value" : "Australia"
}
],
"types" : [ "locality", "political", "geocode" ]
},
{
"description" : "Bondi Beachouse YHA, Fletcher Street, Bondi Beach, New South Wales, Australia",
"id" : "fdab345a9db5c6cfcddd7cd561a8b83acc538d73",
"matched_substrings" : [
{
"length" : 11,
"offset" : 0
}
],
"place_id" : "ChIJzwpdVYStEmsRd6F0Wa1NQ2I",
"reference" : "CmRbAAAA_AFGY8xaYlQebohzYWKrvNoMiJAktObvU4Vb03ORpmf7-ZTlv3BkU3dJPdAIBMtgol8ngdxC1NhVZA7AsAnkRfe4WPT7GJlqkIa_S0Hsb87Dlt-OT1Dt5uQNg_ei4cRPEhCvI7pwL5qD1US6yrOxvVpXGhRQxfEObV1zUxys2a2EZTkbKUdMbg",
"terms" : [
{
"offset" : 0,
"value" : "Bondi Beachouse YHA"
},
{
"offset" : 21,
"value" : "Fletcher Street"
},
{
"offset" : 38,
"value" : "Bondi Beach"
},
{
"offset" : 51,
"value" : "New South Wales"
},
{
"offset" : 68,
"value" : "Australia"
}
],
"types" : [ "establishment" ]
},
{
"description" : "Bondi Beach Car Park, Campbell Parade, Bondi Beach, New South Wales, Australia",
"id" : "ba6c34f150f7f3ac035d731662f2a08a22a3b5dd",
"matched_substrings" : [
{
"length" : 11,
"offset" : 0
}
],
"place_id" : "ChIJXch67J6tEmsRFXD11Ce64WA",
"reference" : "CmRcAAAA_H6cxlTUVW2JHFb5EO0MQAL-d1M-_6_DXOQAvw6xJOFSri4HaIvodY6lcZH3F8rrAlyaXqOM4lcgbegqvVEPScyRE20iiJSXC6jHPxH5EwplZGPWx7rxy34l1uweXgmhEhBirrakiRpK-Zd_naBW7Hd8GhTiujZAiOEDsWj9tuP3bumLR6SamQ",
"terms" : [
{
"offset" : 0,
"value" : "Bondi Beach Car Park"
},
{
"offset" : 22,
"value" : "Campbell Parade"
},
{
"offset" : 39,
"value" : "Bondi Beach"
},
{
"offset" : 52,
"value" : "New South Wales"
},
{
"offset" : 69,
"value" : "Australia"
}
],
"types" : [ "establishment" ]
},
{
"description" : "Bondi Beach Public School, Campbell Parade, Bondi Beach, New South Wales, Australia",
"id" : "e808bb9453705761b5b1672065a5aaa5b1b5b52a",
"matched_substrings" : [
{
"length" : 11,
"offset" : 0
}
],
"place_id" : "ChIJaXfeKJ6tEmsRM_pgTjpurLs",
"reference" : "CnRiAAAAN-CRd33lyhCZBryEwtPxVdxweAC-WcxikMSlmiP83st3Eu0qt5tOdx_Kxvfb6aTH_F3szZETbrRYSXb8-Ql-NSdXFhIeZjIf3au9qrwIII7y9-ZhFRImHCeYRJ1xslrS2dal0_lulOh_dY39jgofrRIQoVco7kZBb4DgSaACK9h4ARoUf98GpsdtuHPVY615rIszSUVqRpM",
"terms" : [
{
"offset" : 0,
"value" : "Bondi Beach Public School"
},
{
"offset" : 27,
"value" : "Campbell Parade"
},
{
"offset" : 44,
"value" : "Bondi Beach"
},
{
"offset" : 57,
"value" : "New South Wales"
},
{
"offset" : 74,
"value" : "Australia"
}
],
"types" : [ "establishment" ]
},
{
"description" : "Bondi Beach View, Campbell Parade, Sydney, New South Wales, Australia",
"id" : "16758032a0384967c04985914cd861dc2c488fe8",
"matched_substrings" : [
{
"length" : 11,
"offset" : 0
}
],
"place_id" : "ChIJr6fcCputEmsRtFcOcREuc48",
"reference" : "CmRUAAAAK3dQSHexE9SerblRCR84jdJ8ScqqDwteRMH2H1f_uCRVQNVsFmgELlMlWWCG2mMbbNOL0yQRv2K0Bx2aqKIe3Bt236LvDl5sxjDaRvdd7QTdBATMJsTHec-xXc3z9c02EhC-JDoD5ln1Q-qdeb-urugLGhSur_7TThy4ekl9yoXRFzZwZmn26w",
"terms" : [
{
"offset" : 0,
"value" : "Bondi Beach View"
},
{
"offset" : 18,
"value" : "Campbell Parade"
},
{
"offset" : 35,
"value" : "Sydney"
},
{
"offset" : 43,
"value" : "New South Wales"
},
{
"offset" : 60,
"value" : "Australia"
}
],
"types" : [ "establishment" ]
}
],
"status" : "OK"
}
如您所见,唯一告诉我邦迪是悉尼一部分的结果是“邦迪海滩景观”,这没有意义,也无助于解决我的问题。
我在世界各地的许多其他地方都遇到过这个问题。
如何获得地点层次结构的准确信息?