1

I'd like to show place labels (cities and towns) only for the one country. Is it possible to achieve this in Maputnik editor? I'm looking for something like Mapbox "iso_3166_1" parameter. I've tried to add iso_a2 to the layer filter settings in such way:

"id": "place_city",
...   
"filter": [
  "all",
   ["==", "$type", "Point"],
   ["==", "class", "city"],
   ["==", "iso_a2", "FR"]

but it didn't work.

2
  • 1
    Do you have attribute "iso_a2" as an attribute in your vector tiles?
    – user30184
    Jun 22, 2020 at 19:50
  • No, I want to filter style.json generated in maputnik editor. It is not my style but one of the default styles ("dark matter") and it has openmaptiles as source. Openmaptiles seems to have this iso_a2 property as indicated here openmaptiles.org/schema/#place but I can't understand how to activate it. Jun 23, 2020 at 9:04

1 Answer 1

1

In general your filter is fine (there's a missing bracket ] to close the array), but the filter doesn't give the result you want because there is only one feature with the iso_a2 property for whole France in the source vector tiles (OpenMapTiles).

As stated in the OpenMapTiles docs, the iso_a2 property is a

Two-letter country code ISO 3166-1 alpha-2. Original value of the country_code_iso3166_1_alpha_2 tag.

https://wiki.openstreetmap.org/wiki/Tag:place%3Dcountry states that this tag is useful but currently not part of map features.

In fact there is only one feature available in OSM with country_code_iso3166_1_alpha_2=FR and only this feature with class=country is available for filtering:

https://taginfo.openstreetmap.org/tags/?key=country_code_iso3166_1_alpha_2&value=FR

https://www.openstreetmap.org/node/1363947712

Screenshot Maputnik

However, if you want to show labels only for one country, you could try to use a filter with the within expression and a GeoJSON of the country geometry.

Here es an example how such a filter would look like:

https://gist.github.com/pathmapper/6b3b8955454b9bc69452493c06a72b0c#file-filter-json

Sample geometry used for this filter:

https://gist.github.com/pathmapper/6b3b8955454b9bc69452493c06a72b0c#file-polygon-geojson

Please note that this filter is currently not working with https://maputnik.github.io/editor because the GL JS version used for Maputnik v1.7.0 has a bug with nested within expressions in filters.

If you don't want to wait for the next release (v1.8.0) of Maputnik to try the filter out, you could build Maputnik yourself from master or use this codesandbox:

https://codesandbox.io/s/keen-panini-7yesf

https://7yesf.sse.codesandbox.io

Here is also a filter which uses only a within exression so this one works with Maputnik v1.7.0 which is currently available on https://maputnik.github.io/editor:

https://gist.github.com/pathmapper/6b3b8955454b9bc69452493c06a72b0c#file-filter_only_within-json

1

Your Answer

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

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