Apply theme to all vector layers
This commit is contained in:
parent
70c5812b09
commit
6f0a008ffd
@ -26,6 +26,7 @@ import org.oscim.event.EventListener;
|
|||||||
import org.oscim.event.Gesture;
|
import org.oscim.event.Gesture;
|
||||||
import org.oscim.event.GestureDetector;
|
import org.oscim.event.GestureDetector;
|
||||||
import org.oscim.event.MotionEvent;
|
import org.oscim.event.MotionEvent;
|
||||||
|
import org.oscim.layers.Layer;
|
||||||
import org.oscim.layers.MapEventLayer;
|
import org.oscim.layers.MapEventLayer;
|
||||||
import org.oscim.layers.tile.TileLayer;
|
import org.oscim.layers.tile.TileLayer;
|
||||||
import org.oscim.layers.tile.vector.OsmTileLayer;
|
import org.oscim.layers.tile.vector.OsmTileLayer;
|
||||||
@ -166,14 +167,26 @@ public abstract class Map implements TaskQueue {
|
|||||||
* use map background color from theme.
|
* use map background color from theme.
|
||||||
*/
|
*/
|
||||||
public void setTheme(ThemeFile theme) {
|
public void setTheme(ThemeFile theme) {
|
||||||
|
setTheme(theme, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to set theme of base vector-layer, optionally
|
||||||
|
* to all vector layers and use map background color from theme.
|
||||||
|
*/
|
||||||
|
public void setTheme(ThemeFile theme, boolean allLayers) {
|
||||||
if (mBaseLayer == null) {
|
if (mBaseLayer == null) {
|
||||||
log.error("No base layer set");
|
log.error("No base layer set");
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
setTheme(ThemeLoader.load(theme));
|
setTheme(ThemeLoader.load(theme), allLayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTheme(IRenderTheme theme) {
|
public void setTheme(IRenderTheme theme) {
|
||||||
|
setTheme(theme, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTheme(IRenderTheme theme, boolean allLayers) {
|
||||||
if (theme == null) {
|
if (theme == null) {
|
||||||
throw new IllegalArgumentException("Theme cannot be null.");
|
throw new IllegalArgumentException("Theme cannot be null.");
|
||||||
}
|
}
|
||||||
@ -184,6 +197,14 @@ public abstract class Map implements TaskQueue {
|
|||||||
((VectorTileLayer) mBaseLayer).setRenderTheme(theme);
|
((VectorTileLayer) mBaseLayer).setRenderTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allLayers) {
|
||||||
|
for (Layer layer : mLayers) {
|
||||||
|
if (layer instanceof VectorTileLayer) {
|
||||||
|
((VectorTileLayer) layer).setRenderTheme(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MapRenderer.setBackgroundColor(theme.getMapBackground());
|
MapRenderer.setBackgroundColor(theme.getMapBackground());
|
||||||
|
|
||||||
clearMap();
|
clearMap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user