Closed Emanuel-23 closed 2 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.
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?
@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
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:
after moving the marker via drag and drop:
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...