MapView-style markers on Mapxbox Android

I need help with Mapbox Android. I drew a polyline and some custom default markers in the style without any problems, but when changing the default style to a custom style, I still see the polyline, but no markers are drawn (neither custom nor default markers).

Can someone help me with this problem?

This is my code:

//Setting style
mapView.setStyleUrl(Constants.MAP_URL_GREEN);

//Adding polilyne
PolylineOptions options = new PolylineOptions();

for(double[] coordArray : route.getListCoords()) {
    options.add(new LatLng(coordArray[0], coordArray[1]));
 }
options.color(ContextCompat.getColor(getContext(), R.color.color_end_green));
options.width(5);

mapView.addPolyline(options);

//Adding markers
MarkerOptions currentMarker;
for(Point point : route.getListPoints()){
    currentMarker = getMarkerFromPoint(point);
    markers.add(mapView.addMarker(currentMarker));
}

Where getMarkerFromPoint:

private MarkerOptions getMarkerFromPoint(Point point) {

    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(new LatLng(point.getLat(), point.getLng()));
    //markerOptions.icon(MapUtils.getPointIcon(point, getContext()));

    return markerOptions;
}

EDIT . I am using MapBox Android SDK 3.2.0.

Thank you in advance

+4
source share
2 answers

, , , . , . , , Point LatLng. , .

List<LatLng> route = new ArrayList<>();
route.add(new LatLng(29.751260, -95.373639));
route.add(new LatLng(29.752881, -95.374454));
route.add(new LatLng(29.755107, -95.374583));

//Adding markers
MarkerOptions currentMarker;
for(int i=0; i<route.size(); i++) {
    currentMarker = getMarkerFromPoint(route.get(i));
    mapView.addMarker(currentMarker);
    }

getMarkerFromPoint():

private MarkerOptions getMarkerFromPoint(LatLng point) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(point);
    return markerOptions;
}

, , , .

+1

.

json , json -, .

...

!

0

Source: https://habr.com/ru/post/1627922/


All Articles