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, 15:25

TCH68k's gravatar image

TCH68k
1112
accept rate: 0%


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).

permanent link

answered 17 Jan, 09:14

Spiekerooger's gravatar image

Spiekerooger
2.3k11942
accept rate: 14%

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, 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, 13:28) Spiekerooger
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×95
×10
×9

question asked: 16 Jan, 15:25

question was seen: 220 times

last updated: 17 Jan, 13:40

powered by OSQA