2

How to bring all the markers above polyline. I'm using deprecated 'Marker' and 'LineManager' to draw marker and polyline. I think with Layers its possible, but its hard for me to switch now, is there any with 'Marker'?

This is how i add marker and polyline

LatLng latLng = new LatLng(mLatLngList.get(i).getLatituede(), mLatLngList.get(i).getLongitude());
MarkerOptions markerOptions = new MarkerOptions().position(latLng).icon(icon).setTitle(cabList.get(i).getCabId());
Marker marker = mMapboxMap.addMarker(markerOptions);
mMapboxMap.setStyle(new Style.Builder().fromUrl(getString(R.string.mapbox_style_url_light)), style -> {
                mLineManager = new LineManager(mMapView, mapboxMap, style);
LineOptions lineOptions = new LineOptions()
                                    .withLatLngs(points)
                                    .withLineJoin(Property.LINE_JOIN_ROUND)
                                    .withLineColor(ColorUtils.colorToRgbaString(getResources().getColor(R.color.colorPrimary)))
                                    .withLineWidth(4.0f);
                            mMapBoxLines = mLineManager.create(lineOptions);
});

I even tried manually removing line layer and adding below symbol layer, but it didn't work.

SymbolLayer symbolLayer = (SymbolLayer) mMapboxMap.getStyle().getLayer("mapbox-android-symbol-layer");
                LineLayer lineLayer = (LineLayer) mMapboxMap.getStyle().getLayer("mapbox-android-line-layer");


mMapboxMap.getStyle().removeLayer(lineLayer);
mMapboxMap.getStyle().addLayerBelow(lineLayer, symbolLayer.getSourceId());
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.0.0'
 implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.3.0'
 implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v7:0.4.0'
shine_joseph
  • 2,922
  • 4
  • 22
  • 44

0 Answers0