3

I want to show the map in my app in English (no localized names in the language most people can't read)

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}',

I'm using mapbox tiles and it's working for me, but all the signs are shown in local languages. Since my app is in English, I don't want to show Chinese signs to my visitors.

I found the docs about how to change the language in mapbox.js, but I don't want to use their library. Is there a way to build tiles url so it would've been aware about the language preferences?

update: mapbox is not really an important requirement. I'm looking for the tile with labels in English. Can't find any

2

If you're using Mapbox Classic you could change the map {id} to use mapbox.run-bike-hike which uses English globally. See https://www.mapbox.com/api-documentation/#maps

Otherwise you would need to modify the default streets style as described at https://www.mapbox.com/help/change-language/#change-label-language-in-mapbox-studio-classic.

If you're Mapbox GL (rather than classic) the instructions are at https://www.mapbox.com/help/change-language/. You can still include raster tiles from your Mapbox GL style in your Leaflet application with https://www.mapbox.com/api-documentation/#retrieve-raster-tiles-from-styles

| improve this answer | |
  • I'm using classic option and mapbox.run-bike-hike is exactly what I was looking for. Thanks! – user93757 Mar 21 '17 at 11:15
  • I know its almost 3 years later but I'm having this same problem, and I don't understand this answer. The link says to use map.setLayoutProperty('country-label', 'text-field', [ 'get', 'name_' + language ]);, but this is within the mapbox API, not the leaflet API. The leaflet API doesn't have a setLayoutProperty method. How can we get the desired language using an L.tilelayer('mapboxURL') layer in leaflet? – Seth Lutske Jan 21 at 3:32
  • If you're not using Mapbox GL JS you can't dynamically set the language on the client, so you'll need to create a new style in Mapbox Studio with your text field using the field for your language – AndrewHarvey Jan 21 at 8:45
  • 1
    There are many layers which provide both english and native names. Try here leaflet-extras.github.io/leaflet-providers/preview – Muneeb Mirza Apr 13 at 12:28
2

Step 1. sign up https://studio.mapbox.com/, then sign in.

Step 2. desgin your own map style, change the Places componets language.

Step 3. save the style, and get the style URL mapbox://styles/yourusername/randomstring, in fact, yourusername/randomstring is the ID(id).

Step 4. use the id \ accessToken in https://api.mapbox.com/styles/v1/{id}/{z}/{x}/{y}@2x?access_token={accessToken}

refer to: https://docs.mapbox.com/api/maps/#vector-tiles enter image description here enter image description here

enter image description here

| improve this answer | |
  • I think the z is the Zoom value. – Jerry Oct 28 at 9:44

Your Answer

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