I just embedded the HTML provided by the Export function into a web page, and when it displays on my site, the map is zoomed out to the max: it shows the whole world instead of the area I selected. How can I make it display like it used to a week or so ago, zoomed exactly to the area I selected, just as it was when I exported it. asked 27 Feb '13, 10:17 frisket aseerel4c26 ♦ |
You should find that you can adjust your view of the map on the OpenStreetMap website, to make adjustments to the resulting generated HTML (fiddle with your view, e.g. to zoom in/out a bit, and then re-do the copy and paste of the HTML into your website) But you may well find the zoom you see on the website (in a wide window) is higher than the zoom level in the resulting embedded map (narrow iframe), so if you specifically want a higher zoom level, simply zoom in a bit more to compensate. What you actually need to pay attention to, is what extents of the map can you see on screen, to the left and right and sides. These will still be visible within the narrower embedded view. It's designed to preserve the extents of what you can see, rather than preserve the centre and zoom level of what you can see. If you are interested in parameters, you can see that generated HTML is an iframe with a 'src' parameter. This points to embed.html with the parameter 'bbox'. It is this parameter which represents the bounding box coordinates of this extent of what's visible on the screen. This is telling it indirectly what the zoom level will be. Another interesting consequence of this approach is that you would get a higher zoom level if you made your iframe bigger (change the width and height parameters in the generated HTML) But as for specifying a zoom level parameter more directly in the URL, that is currently not supported. The embed.html javascript is relatively simple, and only supports the bbox parameter as generated by the share feature. We could enhance this to add more options, but the central OpenStreetMap website isn't really about hosting iframe contents for people, and if you have more sophisticated requirements as a web developer, you should do one of the following (in increasing order of complexity)
answered 19 Feb '14, 14:29 Harry Wood |
So I assume that you used the Export tab of openstreetmap.org site. There it is documented that the exported HTML code is displaying the current map view ... so if this does not work for you, it may be a software bug at osm.org Please try again, or show us the delivered HTML code you have embedded to your website via Pastebin or some similar service if it is too much text. answered 27 Feb '13, 18:56 stephan75 1
Here is the code I pasted: iframe src="http://www.openstreetmap.org/export/embed.html?bbox=-8.4973,51.89139,-8.48863,51.89476&layer=mapnik&marker=51.89297,-8.49417" width="425" height="350"></iframe> This is showing at http://www.ucc.ie/en/support/it/offices/ (click on the blue bar to reveal). There is a screenshot of what I see in FF or Chrome here: http://www.ucc.ie/zoomed-out-map.png
(28 Feb '13, 11:21)
frisket
the live example works as expected for me (Firefox) - at least now.
(28 Feb '13, 21:56)
aseerel4c26 ♦
|
the generated HTML code by the export panel on http://www.openstreetmap.org/ (I guess you mean that) includes a parameter "bbox" which defines the area which should be shown. I just tried an example export and the HTML code did not show the whole world but a much smaller area which I had in my current osm.org view. Go to http://www.openstreetmap.org/?lat=50.1331&lon=8.6917&zoom=12&layers=M select export, select the HTML option. There you are: <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox=8.5628,50.0781,8.8217,50.1877&layer=mapnik" style="border: 1px solid black"></iframe> answered 27 Feb '13, 22:27 aseerel4c26 ♦ 1
OK, thanks. Yes, that's exactly what I did. Some experimenting shows that this works fine in a plain hand-made HTML5 doc, so the problem is a conflict with our site style (CSS/JS): it works when I place it outside the unfolding menubar. Strange that it worked fine last week...someone must have changed the CSS or JS in the meantime. Thanks for the help.
(28 Feb '13, 11:27)
frisket
BTW how do I mark this as Closed?
(28 Feb '13, 11:27)
frisket
There's a tick / checkmark that you can select under the correct answer. Do that, and it'll appear as "answered". (and no, it's not particularly obvious!).
(28 Feb '13, 11:32)
SomeoneElse ♦
1
@frisket: thank you for your feedback, that's helpful for all others.
(28 Feb '13, 21:49)
aseerel4c26 ♦
|
Hey, it's my first post here :) It's not ideal way, but here's rewritten method from my PHP's class to use as separate function. It makes iframe URL from input data: lat, lon and area. The function you'd use is It could be written better, but you have an idea. The algorithm is not ideal, but it should be ok for this use. If you don't want marker, remove everything after As the result of the function is an array, you can feed it to
If you want bounding box for area 1x1km, now you need to count it like that:
By the way I had problems with map totally zoomed out, but it's rather OSM bug. I changed offset to smaller, then I got back to earlier offset and it worked. Maybe malformed cookies or so. It happened once. answered 10 Aug '16, 01:58 KrzysiuNet |
I'm having a similar problem. The embedded iframe works fine for a while, then after one or two browser refreshes the view I wanted is replaced by a map of the world. answered 01 Apr, 08:49 VirtualMount... |