Android Maps API v2: a polyline is pulled under a tile overlay

I am trying to draw a tile overlay and a polyline on a google map. I would like the polyline to appear on top of the tile overlay so that it can be seen. It is currently drawn under the tile overlay and is fading, my code is as follows:

// Draw the tile overlay
NBUrlTileProvider tileProvider = new NBUrlTileProvider(url, 256, 256);

TileOverlayOptions tileOverlayOptions = new TileOverlayOptions()
                    .tileProvider(tileProvider)
                    .fadeIn(true);

mMap.addTileOverlay(tileOverlayOptions);

// Draw the poly line
PolylineOptions polyLineOptions = new PolylineOptions();

polyLineOptions.width(5).geodesic(true).color(Color.rgb(255, 0, 255));

polyLineOptions.add(location1);
polyLineOptions.add(location2);
polyLineOptions.add(location3);

mMap.addPolyline(polyLineOptions);

Any help would be greatly appreciated, I thought that the polylines would just be drawn on top of the default tiles, is there anything extra I need to add?

+4
source share
1 answer

The solution was to use:

Polyline polyline = mMap.addPolyline(polyLineOptions);

polyline.setZIndex(1000); //Or some large number :)
+17
source

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


All Articles