Incorrect parsed name from Google Maps api
还没有人认领这个 Issue。
评估
调研方向
从 GoogleMaps.php 第 235 行附近开始,跟踪 address_components 如何映射到返回的对象中。重新执行 Pershagen 和 Ronna 搜索,然后验证解析出的名称在两种情况下都正确,并且其他地址组件的结果没有回归问题。
由索引模型根据 Issue 内容生成。
描述
Searching for Pershagen returns the following json
https://maps.googleapis.com/maps/api/geocode/json?address=Pershagen&key=xxx
{
"results" : [
{
"address_components" : [
{
"long_name" : "Pershagen",
"short_name" : "Pershagen",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Södertälje",
"short_name" : "Södertälje",
"types" : [ "postal_town" ]
},
{
"long_name" : "Stockholm County",
"short_name" : "Stockholm County",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Sweden",
"short_name" : "SE",
"types" : [ "country", "political" ]
},
{
"long_name" : "151 39",
"short_name" : "151 39",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "151 39 Pershagen, Sweden",
"geometry" : {
"location" : {
"lat" : 59.14664239999999,
"lng" : 17.6511284
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 59.15236419999999,
"lng" : 17.6671358
},
"southwest" : {
"lat" : 59.1409196,
"lng" : 17.635121
}
}
},
"place_id" : "ChIJV_Hb5dUSX0YRULaMsvX-AAo",
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
Using the google maps provider I get the following object. The phrase Pershagen is omitted.

Searching for the similar area Ronna I get a more correct object.

When looping over address components Pershagen is first set but then overridden by Södertälje.
Reversing the array on L235 in GoogleMaps.php returns a more accurate result.
+foreach (array_reverse($result->address_components) as $component) {
-foreach ($result->address_components as $component) {

Not at all sure how this will affect other results!
- 主要语言
- PHP
- 星标
- 4k
- 派生
- 525
- 平均合并
- 8 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
geocoder-php/Geocoder 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
geocoder-php/Geocoder#1272 ·
-
question
难度 4/5 3-5 天 新手友好度 25/100
geocoder-php/Geocoder#1267 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
geocoder-php/Geocoder#1266 ·
-
难度 1/5 1 小时以内 新手友好度 38/100
geocoder-php/Geocoder#1244 · 2 条评论 · 2 个 reaction ·
-
provider
难度 4/5 3-5 天 新手友好度 30/100
geocoder-php/Geocoder#1243 ·
查看 geocoder-php/Geocoder 的全部 Issue
相似的 Issue
-
priority: p3
难度 2/5 1-3 小时 新手友好度 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
难度 2/5 1-3 小时 新手友好度 78/100
nextcloud/fulltextsearch#1011 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
coollabsio/coolify#11927 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 68/100