5757import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconAllowOverlap ;
5858import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconIgnorePlacement ;
5959import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconImage ;
60+ import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconOffset ;
6061import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconRotate ;
6162import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconRotationAlignment ;
6263import static com .mapbox .mapboxsdk .style .layers .PropertyFactory .iconSize ;
@@ -117,12 +118,14 @@ void setRenderMode(@RenderMode.Mode int renderMode) {
117118 switch (renderMode ) {
118119 case RenderMode .NORMAL :
119120 styleForeground (options , isStale );
121+ setLayerVisibility (SHADOW_LAYER , true );
120122 setLayerVisibility (FOREGROUND_LAYER , true );
121123 setLayerVisibility (BACKGROUND_LAYER , true );
122124 setLayerVisibility (ACCURACY_LAYER , true );
123125 break ;
124126 case RenderMode .COMPASS :
125127 styleForeground (options , isStale );
128+ setLayerVisibility (SHADOW_LAYER , true );
126129 setLayerVisibility (FOREGROUND_LAYER , true );
127130 setLayerVisibility (BACKGROUND_LAYER , true );
128131 setLayerVisibility (ACCURACY_LAYER , true );
@@ -164,7 +167,7 @@ private void addLayers() {
164167 addSymbolLayer (SHADOW_LAYER , BACKGROUND_LAYER );
165168 addSymbolLayer (BACKGROUND_LAYER , FOREGROUND_LAYER );
166169 addSymbolLayer (FOREGROUND_LAYER , null );
167- addSymbolLayer (LocationLayerConstants . BEARING_LAYER , null );
170+ addSymbolLayer (BEARING_LAYER , null );
168171 addAccuracyLayer ();
169172 }
170173
@@ -211,6 +214,18 @@ void updateAccuracyRadius(Location location) {
211214 }
212215 }
213216
217+ void updateForegroundOffset (double tilt ) {
218+ layerMap .get (FOREGROUND_LAYER ).setProperties (
219+ iconOffset (new Float [] {0f , (float ) (-0.05 * tilt )}));
220+ layerMap .get (SHADOW_LAYER ).setProperties (
221+ iconOffset (new Float [] {0f , (float ) (0.05 * tilt )}));
222+ }
223+
224+ void updateForegroundBearing (float bearing ) {
225+ layerMap .get (FOREGROUND_LAYER ).setProperties (iconRotate (bearing ));
226+ layerMap .get (SHADOW_LAYER ).setProperties (iconRotate (bearing ));
227+ }
228+
214229 private float calculateZoomLevelRadius (Location location ) {
215230 if (location == null ) {
216231 return 0 ;
@@ -337,7 +352,7 @@ public void onNewGpsBearingValue(float gpsBearing) {
337352 @ Override
338353 public void onNewCompassBearingValue (float compassBearing ) {
339354 if (renderMode == RenderMode .COMPASS ) {
340- setLayerBearing (LocationLayerConstants . BEARING_LAYER , compassBearing );
355+ setLayerBearing (BEARING_LAYER , compassBearing );
341356 }
342357 }
343358}
0 commit comments