mcguffin / acf-openstreetmap-field

WordPress ACF Field for OpenStreetMap
https://wordpress.org/plugins/acf-openstreetmap-field/
GNU General Public License v3.0
107 stars 21 forks source link

Incorrect "lat" and "lng" values when moving the markers via drag and drop #67

Closed Emanuel-23 closed 2 years ago

Emanuel-23 commented 3 years ago

in the wordpress administration when using the acf-openstreetmap-field: when adding a map marker by inputting the address manually and then clicking the wanted address from the autofill list the correct address will become selected and a marker will be set correctly. the result is expected and correct, even when outputting the fields value in frontend or by looking into the database.

however, after moving the marker in the administrations map using drag and drop, only the address will be updated correctly, whilst the lat and lng values are untouched. it looks correct at first glance, because you can move the marker in the administration and the address input fields value becomes updated, but because you save those values via a hidden input form field (holding the json data) that only updates the address, this will lead to incorrect marker pins in the frontend.

the following example illustrates the behavior, showing the corresponding hidden input fields values. before moving:

before-moving-annotated

after moving the marker via drag and drop:

after-moving-annotated

This is really far from expected, and will confuse the user as well as the developer.

EDIT: i suppose its even more confusing, because the moved marker will be saved correctly and show in the administration at its new position, but the raw datas location coordinates dont reflect the changes. means, both coordinates will become saved somehow. i dont get it...

andreasputlitz commented 3 years ago

I just realized this glitch as well. The lat/lng-coordinates are like ~1km off in my case, even though the marker and the address in the backend are displayed correctly.

andreasputlitz commented 3 years ago

Actually, in my case the coordinates are being updated, when I drag and drop the map marker on the CPT page. However, the coordinates aren't correct. I output the map using WP Gridbuilder. Also, when checking the stored lat/lng-coordinates with Google Maps, I can confirm that the map output by WP Gridbuilder is correct. Somehow, the geocoding via Nominatim seems to be messed up?

mcguffin commented 2 years ago

@Emanuel-23: Thanks for the report – and apologies for a slight delay. The Lat/Lng values you're pointing at in your screenshots is the maps center position. The marker position is stored independently in the markers array: https://github.com/mcguffin/acf-openstreetmap-field/wiki/Usage#raw-data-structure