Hello, I would like to use OSM as a location setter on my page. The user should be able to move the marker on the map and then save the location to the database and next time when he/she opens it, the marker should be on the new place. However the marker is not moveable if OSM is embedded. I found no information about how can i move the marker on an embedded OSM iframe. Any ideas on this? asked 16 Jan '22, 15:25 TCH68k |
You won't be able to achieve this if you are using the iframe embed option. Reason: all browsers have a cross origin security policy that does not allow your website to intercept any interactions a user would have with the map in the iframe. You would rather have to include the map through a web library like Leaflet ( https://leaflet.org ) that would give you the chance to orchestrate the interaction with the map. Maybe a leaflet plugin like https://cliffcloud.github.io/Leaflet.LocationShare/ would be a start (but it does not save to a database but rather just uses an url to set the information). answered 17 Jan '22, 09:14 Spiekerooger I can read the iframe's src and see the changes from the URL, but that's not important. How can i move the marker if OSM is embedded? Even if i cannot detect the changes. How can i move the marker?
(17 Jan '22, 12:55)
TCH68k
If you would go the embed way you would not only have to manipulate the marker lat/lon parameter but also calculate the surrounding bbox values to get the right iframe url for your users. So it is much easier to do this in using a library like Leaflet and start from there.
(17 Jan '22, 13:28)
Spiekerooger
|