I'm using Mapbox SDK Android ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1@aar' and 'com.mapbox.mapboxsdk:mapbox-android-services:1.1.0@aar'). I use offline map and put markers but remove and setposition dont' work.
I declare in global:
private MapboxMap mapboxMap2;
private MarkerViewOptions marker_inter;
Then in my OnMapReadyCallback(), I save the MapboxMap with:
public void onMapReady(MapboxMap mapboxMap)
{
mapboxMap2 = mapboxMap;
so I'll be able to use it latter.
Also in OnMapReadyCallback I put the marker using:
marker_inter = new MarkerViewOptions()
.position(new LatLng(the_lagps_inter, the_logps_inter))
.title("Intervention")
.snippet("Desc inter")
.icon(iconeInter);
markerView = mapboxMap.addMarker(marker_inter);
The marker is set correctly. Then on onMapClick(@NonNull LatLng point) I retrieve the coord of the click (which are correct). But:
1) If I try to remove the marker using:
mapboxMap2.removeMarker(marker_inter);
I get "removeMarker (com.mapbox.mapboxsdk.annotations.Marker) in MapboxMap cannot be applied to (com.mapbox.mapboxsdk.annotations.MarkerViewOptions)"
2) If I try to set a new position using:
marker_inter.setPosition(new LatLng(the_lagps_inter, the_logps_inter));
I get: "Cannot resolve method 'setPosition(com.mapbox.maboxsdk.geometry.LatLng)"
Note: I import com.mapbox.mapboxsdk.geometry.LatLng;
It seems removeMarker don't work with MarkerViewOptions and that setPosition is no more in geometry.LatLng??
Any idea?