Opened 9 years ago
Last modified 7 years ago
#2410 new enhancement
API feature request: /map take centre point and width,height, or zoom level
Reported by: | Ed Avis | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | Wishlist |
Component: | api | Version: | |
Keywords: | Cc: |
Description
Currently to fetch data with /api/map you specify a bounding box with two longitudes and two latitudes. It would be easier for some uses to give a centre point plus the width and height in metres of the area to be fetched, e.g.
/api/0.6/map?centre=50.812279,-3.033383;width=1000;height=1000
This would calculate the bounding box for you and return the same results as
/api/0.6/map?bbox=-3.04051192352175,50.8077744954955,-3.02625407647825,50.8167835045045
Of course clients can calculate these for themselves, to reasonable accuracy, using a couple of constants and a cosine. So this wouldn't make the API any more powerful, just a bit more convenient for some uses.
Further, it would be useful to fetch the same map area as a particular slippy map display, as
/api/0.6/map?centre=50.812279,-3.033383;zoom=18;screen_width=800;screen_height=600
This would compute the width and height based on the zoom level, location, and screen size given. Again, clients can compute this with a few lines of code provided they have a lookup of what the zoom factors are, but it would be a useful builtin. If screen_width and screen_height are omitted, some default such as 800x600 could be assumed.
Change History (5)
comment:1 Changed 9 years ago by
Milestone: | → Wishlist |
---|
comment:2 Changed 9 years ago by
I was thinking of when you want to quickly use the API to look at the XML for a particular map area. The slippy map interface uses (lat, lon, zoom) rather than a bounding box and this triple is sometimes used as a kind of OSM bookmark - e.g. in Merkaartor you can paste in a link to the slippy map to choose the area to download. Merkaartor has its own code to turn that into a bbox.
As for the pixel width and height, perhaps viewport_width and viewport_height would be better names.
comment:3 Changed 9 years ago by
So you don't actually have a concrete use for this? It just seemed like a good idea so you thought you ask somebody to spend time implementing it in case somebody later decided they would like to use it...
comment:4 Changed 9 years ago by
Yes, this is just a feature request. The concrete use is as I mentioned, and is something I wrote code for, but thought it might make sense to have implemented in the API instead.
comment:5 Changed 7 years ago by
Owner: | changed from Tom Hughes to rails-dev@… |
---|
Can you elaborate on what sort of uses this would help with?
Incidentally, screen_width and screen_height are clearly the wrong names unless you're going to tell us what percentage of the width and height of the screen are being used to display the map. It would be better just to name them width and height (or map_width and map_height or something).
Of course strictly speaking you would also need to tell us what projection you're using ;-)