Skip to content

Add support for displaying municipality in AzureMaps autocomplete results #1242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 22, 2025

Conversation

kryber
Copy link
Contributor

@kryber kryber commented Jan 30, 2025

We noticed that the autocomplete functionality in the AzureMaps provider was missing the ability to display the municipality (city). This was causing incomplete location suggestions, as cities were not included in the results.

To fix this, we added the following line to the formatGeocodeResponse function:

$builder->setLocality($result->address->municipality ?? null);

Now, when searching for an address like Via Giuseppe Garibaldi 62, IT, Italy, the autocomplete properly returns results that include city names. This improves the accuracy and usability of the geocoding provider.

Let us know if any adjustments are needed! 🚀

image

@jbelien
Copy link
Member

jbelien commented Feb 16, 2025

All good 👍 Thanks for your contribution!

Could you just add a test about this change?
I'll then approve and merge it. Thanks.

@kryber
Copy link
Contributor Author

kryber commented Feb 17, 2025

I've added a test to verify that the municipality (city) is properly included in the geocode response. Let me know if anything more is needed. Thank you for your fantastic job!

@jbelien
Copy link
Member

jbelien commented Feb 18, 2025

Could you make sure all failing checks are passing?

PHP CS Fixer is "just" a linting/formatting issue.
To fix the other tests, you'll have to commit the cached response of your new test.

Thanks!

@kryber
Copy link
Contributor Author

kryber commented Feb 21, 2025

Hi! I am sorry for that, that was my first time doing this :) I cleaned it with php vendor\bin\php-cs-fixer fix, and afterwards tested with php vendor\bin\phpunit -c phpunit.xml.dist --filter=AzureMapsTest. It generated same cache file.

There was 1 failure:

  1. Geocoder\Provider\AzureMaps\Tests\AzureMapsTest::testGeocodeIncludesMunicipality
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'Rome'
    +'Scisciano'

C:\inetpub\wwwroot\github_projects\Geocoder\src\Provider\AzureMaps\Tests\AzureMapsTest.php:115

FAILURES!
Tests: 3, Assertions: 35, Failures: 1.
hopefully we are good now.

@jbelien jbelien merged commit 0e4b39f into geocoder-php:master Feb 22, 2025
187 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants