4

I'm developing an application in which I need to have an underlying graph representation of streets. Google Maps does not provide this data, which is why I decided to use OpenStreetMap.

I have successfully gotten these networks, but to avoid making my algorithm handle too many edges at a time, I've excluded those marked as "residential" by OpenStreetMap.

Is there any corresponding way I can exclude those same roads in the OSM embed?

I've tried Leaflet and OpenLayers and I cannot find any documentation regarding limiting certain types of information.

6
  • 1
    What exactly do you mean by "exclude those same roads in the Google Maps embed"? Do you want to change the way the map is rendered?
    – mmd
    Commented Nov 22, 2018 at 8:46
  • @mmd - Yes, I need the tiles to not have residential roads, as defined by OSM. I'm fine calling OSM each time, I just need some way to remove arbitrary roads. Commented Nov 22, 2018 at 10:02
  • 2
    Tiles on osm.org are prerendered PNG images, there's no meaningful way to remove some roads unless you photoshop them, or set up your own tile rendering server and render tiles according to your needs from raw data. I tried to flag your question to be closed, as it's still totally unclear what you're asking for. However, the bounty won't allow that.
    – mmd
    Commented Nov 22, 2018 at 15:39
  • @mmd If it is impossible without a new tile rendering server, that's kind of sad. But I believe the question is clear: How do I remove roads classified as residential from appearing on maps? I edited the question to hopefully limit its scope a little bit, and not mention Google because they definitely do not have a way to do this. Commented Nov 23, 2018 at 4:36
  • 1
    Adding to @mmd: Alternatively to setting up your own rendering server you could switch to vector tiles.
    – scai
    Commented Nov 23, 2018 at 10:53

1 Answer 1

1
+100

I've tried Leaflet and OpenLayers and I cannot find any documentation regarding limiting certain types of information.

Leaflet and OpenLayers are typically displaying maps using images that are generated by an external server.

https://wiki.openstreetmap.org/wiki/Tile_servers lists some examples of publicly available tile servers allowing some limited usage.

To change that you need to either generate your own tiles (see https://switch2osm.org/serving-tiles/ for one of guidelines) with a custom map style. Modifying https://github.com/gravitystorm/openstreetmap-carto/ or other map style to not show highway=residential is also possible (and presumably also highway=service, highway=track, highway=service, highway=path, highway=footway, highway=cycleway, highway=pedestrian and highway=bridleway).

You may also try to make your own map style from scratch.

In principle it is possible to fetch raw osm data with Overpass Turbo and display them in browser using Leaflet by drawing lines but it will work only for relatively small areas.

4
  • Please comment if any part is unclear - I will try to add links to further resources. I was not starting from full detail as one may write a book as an answer to this question, Commented Nov 25, 2018 at 10:29
  • 1
    Isn't that a very clear sign that this question should be closed, as it is too broad?
    – mmd
    Commented Nov 25, 2018 at 15:01
  • @mmd Well it is even explictly mentioned as "If you can imagine an entire book that answers your question, you’re asking too much." at gis.stackexchange.com/help/dont-ask On the other hand it is not obvious for person asking and it may be useful to have this question as generic "I want to display existing raster tiles with this modification" with answers leading to specific resources. Or maybe I am just attempting to rationalize what I did. Commented Nov 25, 2018 at 22:22
  • 1
    @mmd Almost every question could have a book written up on it if you wanted to explain every possible solution. This question has a fairly short and clear solution "Its not easy because of how the tiles work but here are the directions you should head to for more info"
    – Qwertie
    Commented Dec 6, 2018 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.