0

Ok, be gentle. I'm self-taught and don't know the 100% technically correct way to phrase my question.. :)

My goal is to create a Mapbox style that shows only the state of Virginia, and any standard features like roads, place names, water that I want to add. But only show it for Virginia.

Within Mapbox I have created a style that shows the state of Virginia (and only the state of Virginia) by nature of importing a JSON file of all the counties in the US, then filtering that layer to show only counties in Virginia. But adding in a layer like place names adds them across the entire US and they show up on the map I want restricted to Virginia. I don't see a state filter to help with some of this additional layer data.

It was suggested to use Overpass Turbo to query only what I need, but I don't see a way to limit a query to just Virginia.

Any suggestions (written in novice terms) to get my map to only show a Virginia map?

5
  • One option that is a bit of a shortcut, is just to create a mask layer that blocks everything outside of Virginia from view.
    – Lisa
    Apr 30, 2018 at 19:11
  • Sounds like a good idea, but not sure how to do that. Any specific suggestions on how to go about doing that? Apr 30, 2018 at 19:26
  • 1
    Agree with the mask approach, see mapbox.com/mapbox.js/example/v1.0.0/mask-feature for an idea how you can manually construct a GeoJSON file with a mask. You should be able to do it with something like geojson.io, by manually editing the GeoJSON. In Mapbox Studio, you might need to use opacity 0.99 to hide the labels due to a bug. May 1, 2018 at 13:02
  • Thanks AndrewHarvey. I feel closer but still not following all aspects 100%. I was able to use geojson.io to create a line around Virginia's perimeter and save it as a map.geojson file. The mapbox example you linked me to doesn't have enough tutorial description so I am not following all of it. I don't see where my map.geojson file of coordinates is used in the example. And I am confused by this line of code in terms of where that file is supposed to be located. It looks like it is a local reference to my server but I don't have this javascript file or know what is in it. May 1, 2018 at 18:13
  • OK, realized I needed to make a polygon so redid that and have imported the file into Mapbox as a tileset. I can see it but not any way to make it function as a mask. So is the best approach for me to use javascript on a web page to add the mask? I had hoped to do it in Studio and work further with the map in Studio. May 1, 2018 at 19:09

1 Answer 1

1

It was suggested to use Overpass Turbo to query only what I need, but I don't see a way to limit a query to just Virginia.

To limit your query with Overpass Turbo you could use the wizard with a location filter, e.g. using the following in the wizard

amenity = bar in Virginia

results in objects with amenity=bar in Virginia:

http://overpass-turbo.eu/s/yr0

Regarding the suggestion using a mask layer see:

https://stackoverflow.com/questions/40772764/mask-mapbox-gl-map-with-arbitrary-polygon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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