geocoder-php / geocoder-php/Geocoder
Mapbox Provider prevents searching for countries
还没有人认领这个 Issue。
- 主要语言
- PHP
- 星标
- 4k
- 派生
- 525
- 平均合并
- 8 分钟
- 30 天内合并 PR
- 1
描述
I'm using the Mapbox Provider in my API to fetch coordinates for given entities. These entities can be either:
- Countries
- Cities
- Districts
- Addresses
However, the current implementation of the mapbox provider prevents from returning anything that doesn't contain a context.
When I run this snippet and watch the console, I see that the query to Mapbox is correct and data is returned.
$locations = $mapboxGeocoder->geocodeQuery(
GeocodeQuery::create($country->getName())
->withLocale('nl')
->withData('location_type', 'country')
);
However, the fetchUrl method in Mapbox.php simply breaks when a result without context is returned by Mapbox.
https://github.com/geocoder-php/mapbox-provider/blob/master/Mapbox.php#L283
When I remove that piece of code, and add an additional check here to check if context is available before iterating through it, the code returns the requested items.
https://github.com/geocoder-php/mapbox-provider/blob/master/Mapbox.php#L301
This isn't a clean solution and additional models are required to make it a better implementation. However, the repo is read-only so I cannot help with the required changes
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查第283行和第301行附近的 Mapbox.php,从 fetchUrl 以及对不包含 context 字段的 Mapbox 结果的处理开始。跟踪用于 context 数据的现有模型,并确认国家结果能够正常返回,同时城市、地区和地址保持现有行为不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100