Comments (8)
Could you give us more details about your issue ?
What provider are you using ?
What address ?
Is there some error message ?
from geocoder.
Yes ofc, so the issue is that when i retrieve the subLocality, using the method getSublocality, or even by using the dumper GeoArray this property always comes null.
The adminLevels are filled, but the sublocality for some reason never gets assigned a value.
I don't get an error message, the error is the sublocality property don't come with data.
Provider : Mapbox (but I tested several, and i got the same problem)
Regarding the address, same as the provider using any PT address is null
Currently using this setup:
$geocoder = new ProviderAggregator();
$chain = new Chain([
//new Nominatim\Nominatim($httpClient, 'https://nominatim.openstreetmap.org', 'Geocoder test'),
new Mapbox($httpClient, $key),
new Geocoder\Provider\ArcGISOnline\ArcGISOnline($httpClient),
//new \Geocoder\Provider\GoogleMaps\GoogleMaps($client, 'France'),
//new \Geocoder\Provider\BingMaps\BingMaps($client, '<API_KEY>'),
]);
$geocoder->registerProvider($chain);
// search by user typed data
$result = $geocoder->geocodeQuery(GeocodeQuery::create($query));
$dumper = new GeoArray();
foreach ($result as $item) {
$arraydump = $dumper->dump($item);
}
from geocoder.
Which of the two providers was used? What is the input (address), what the output (full data structure)?
from geocoder.
Note
@mrelliot69 I took the liberty to improve the formatting of the code in your comment to make it more readable.
Indeed, Mapbox provider does not return any sub-locality property (check Mapbox.php
).
The available properties will depend on both the provider and the 3rd party API.
If the 3rd party API returns the sub-locality (for instance) but the provider doesn't "fetch" it, we can easily add it ; on the other hand, if the 3rd party API doesn't return a sub-locality, there is not much we can do.
In your use case, does the 3rd party API returns a sub-locality ?
Could you show us the response you get from the API ?
from geocoder.
Which of the two providers was used? What is the input (address), what the output (full data structure)?
Its the first one (mapbox)
from geocoder.
Note
@mrelliot69 I took the liberty to improve the formatting of the code in your comment to make it more readable.Indeed, Mapbox provider does not return any sub-locality property (check
Mapbox.php
).The available properties will depend on both the provider and the 3rd party API. If the 3rd party API returns the sub-locality (for instance) but the provider doesn't "fetch" it, we can easily add it ; on the other hand, if the 3rd party API doesn't return a sub-locality, there is not much we can do.
In your use case, does the 3rd party API returns a sub-locality ? Could you show us the response you get from the API ?
yeah ofc, im attaching on this reply a response, so you can see it
Geocoder\Provider\Mapbox\Model\MapboxAddress Object
(
[id:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] => address.8706368440886428
[streetNumber:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] =>
[streetName:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] => Avenida Da República
[resultType:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] => Array
(
[0] => address
)
[formattedAddress:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] => Avenida Da República, 2685-181 Portela, Lisbon, Portugal
[neighborhood:Geocoder\Provider\Mapbox\Model\MapboxAddress:private] =>
[coordinates:Geocoder\Model\Address:private] => Geocoder\Model\Coordinates Object
(
[latitude:Geocoder\Model\Coordinates:private] => 38.7818878
[longitude:Geocoder\Model\Coordinates:private] => -9.115792
)
[bounds:Geocoder\Model\Address:private] =>
[subLocality:Geocoder\Model\Address:private] =>
[locality:Geocoder\Model\Address:private] => Portela
[postalCode:Geocoder\Model\Address:private] => 2685-181
[adminLevels:Geocoder\Model\Address:private] => Geocoder\Model\AdminLevelCollection Object
(
[adminLevels:Geocoder\Model\AdminLevelCollection:private] => Array
(
[1] => Geocoder\Model\AdminLevel Object
(
[level:Geocoder\Model\AdminLevel:private] => 1
[name:Geocoder\Model\AdminLevel:private] => Portela
[code:Geocoder\Model\AdminLevel:private] =>
)
[2] => Geocoder\Model\AdminLevel Object
(
[level:Geocoder\Model\AdminLevel:private] => 2
[name:Geocoder\Model\AdminLevel:private] => Lisbon
[code:Geocoder\Model\AdminLevel:private] => 11
)
)
)
[country:Geocoder\Model\Address:private] => Geocoder\Model\Country Object
(
[name:Geocoder\Model\Country:private] => Portugal
[code:Geocoder\Model\Country:private] => PT
)
[timezone:Geocoder\Model\Address:private] =>
[providedBy:Geocoder\Model\Address:private] => mapbox
[streetNumber:Geocoder\Model\Address:private] =>
[streetName:Geocoder\Model\Address:private] =>
)
As you can see the admin level 2 its lisbon so that in theory its also the sublocality and the admin level 2 the locality
from geocoder.
You might be right but according to Mapbox response I don't think we can always assume that Admin Level 1 is the sub-locality.
Check the code here and you'll see that locality
is already correctly set (and that Admin Level 2 is region
).
Could you show us a response from Mapbox API (the raw response, not the MapboxAddress
object) to double check ? Thanks.
from geocoder.
According to Mapbox documentation there is indeed no sub-locality provided.
from geocoder.
Related Issues (20)
- Clean wrong tag/release created by @JaZo HOT 5
- Unable to install providers HOT 4
- Always get the address id HOT 3
- Arcgis Provider HOT 3
- Static Maps HOT 1
- [Nominatim] Neighbourhood field HOT 1
- [Google] Administrative level 1 is defined twice HOT 4
- Serialization of 'Closure' is not allowed HOT 7
- Store Address In Database HOT 10
- Equivalent to NoResult Exception when updating from older versions HOT 2
- Tag new release HOT 1
- Abandoned dependency php-http/message-factory
- Reverse Geocode failure - Here maps - Undefined index: LocationId HOT 2
- Error installing geocoder-php/nominatim-provider HOT 8
- Documentation to create custom providers
- Google invalid response HOT 4
- Issues with PHP 8.1 during installation HOT 2
- Take exception message from provider response in case of statusCode >= 400
- Tag new release HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geocoder.