Skip to content

Commit

Permalink
fix regex and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanschaller committed Aug 9, 2023
1 parent b79f945 commit fbac454
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ class MapLibreLocalization(private val mapBoxMap: MapboxMap) {
fun setMapLanguage(language: String) {
val layers = mapBoxMap.style?.layers ?: emptyList()

// Find name:de, name:es or name:latin
val nameRegex = Regex("(name:[a-z]+)")

val symbolLayers = layers.filterIsInstance<SymbolLayer>()

for (layer in symbolLayers) {
val expression = layer.textField.expression ?: continue

val nameRegex = Regex("(name:[a-z]+)")

val newExpression = expression
.toString()
.replace(nameRegex, "name:$language")
Expand Down

0 comments on commit fbac454

Please sign in to comment.