maplibre / maplibre/maplibre-plugins-android

Use SymbolManager and have icon sizes depending on the zoom

Open
#84 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
50
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Hello,
I found myself needing to use SymbolManager to drag and drop, and I realized that you can't specify an expression.
This is a shame because the icons are fixed in size.
To solve my problem, I did the following:

```
class ScaleSymbolManager(mapView: MapView, maplibreMap: MapLibreMap, style: Style) : SymbolManager(
mapView, maplibreMap, style
) {
override fun setDataDrivenPropertyIsUsed(property: String) {
when (property) {
"icon-size" -> layer.setProperties(
iconSize(
interpolate(
linear(), zoom(),
stop(9, 0.0f),
stop(10, 1.0f),
stop(12, 1.5f),
)
)
)

"text-size" ->
layer.setProperties(
textSize(
interpolate(
linear(), zoom(),
stop(9, 0.0f),
stop(10, 10f),
stop(12, 14f),
)
)
)

else -> super.setDataDrivenPropertyIsUsed(property)
}
}
}
```

I don't think this is the right method but it works while waiting for a better answer.

Contributor guide

Open the contributing guide

Research direction

Start with SymbolManager and its setDataDrivenPropertyIsUsed override, then inspect how MapView, MapLibreMap, and Style are wired into the manager. Done means icon-size and text-size can use zoom-dependent expressions without requiring a custom SymbolManager subclass, while preserving drag-and-drop behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.