Mapbox Provider prevents searching for countries

Offen
#1,107 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
php
Bereich
api, backend

Rechercherichtung

Überprüfe Mapbox.php im Bereich der Zeilen 283 und 301, beginnend mit fetchUrl und der Verarbeitung von Mapbox-Ergebnissen ohne ein context-Feld. Verfolge die vorhandenen Modelle für context-Daten und stelle sicher, dass Ergebnisse für Länder zurückgegeben werden, ohne dass etwas kaputtgeht, während Städte, Bezirke und Adressen ihr bisheriges Verhalten beibehalten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
PHP
Sterne
4k
Forks
525
Ø Merge
8 Min.
Gemergte PRs (30 T.)
1

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus geocoder-php/Geocoder

Alle Issues in geocoder-php/Geocoder

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.