Fitoussi / geo-my-wp

Advanced mapping and geolocation plugin for Wordpress
https://geomywp.com
36 stars 22 forks source link

When Using Leaflet Maps - search by city breaks #70

Closed pattyok closed 3 years ago

pattyok commented 3 years ago

When using leaflet maps and searching by city, if the nominatim request comes back with multiple results, you do a comparison on region code. The result comes back as 'us', and the default result set in options is ''US" so no match is found and it errors out.

Solve with a simple toLowerCase

Line 1579 of gmw.core.js

if ( typeof( data[t].address.country_code ) !== 'undefined' && data[t].address.country_code.toLowerCase() == options.region.toLowerCase() )

The same issue exists in the backend geocode function too

gwm-geocoding-providers.php ~line 333

if ( ! empty( $location_details->address->country_code ) && strtolower ($this->params['region']) === strtolower ($location_details->address->country_code) ) {

Fitoussi commented 3 years ago

Hey @pattyok,

I apologize for the delayed reply.

Thank you for the suggestion above. I applied it to the plugin and will be available in the next version.