问题
How to add text below/above in the middle of the polyline in osmdroid? setTitle()
does not work neither is setSubDescription()
.
And also how to add button overlays.
回答1:
There is a way to do it and it's an opt in feature of the Marker class. The easiest way to find an example is with the LatLonGridOverlay. I'll reduce the logic to something simple to understand below. The key is the order of code, see the title, then set the icon to null, then add to the map. You'll have to figure out where you want the Marker to be based on the coordinates of the polyline but it does work.
Polyline p = new Polyline();
List<GeoPoint> pts = new ArrayList<GeoPoint>();
//add your points here
p.setPoints(pts);
//add to map
Marker m = new Marker(mapView);
m.setTitle("Some text here");
//must set the icon last
m.setIcon(null);
m.setPosition(new GeoPoint(marker location here));
//add to map
source
来源:https://stackoverflow.com/questions/40935351/how-to-add-text-below-above-in-the-middle-of-the-polyline-in-osmdroid