如何在osmdroid中折线中间的上方/上方添加文字? setTitle()
不起作用setSubDescription()
。
还有如何添加按钮覆盖。
答案 0 :(得分:1)
有一种方法可以做到这一点,它是Marker类的选择功能。查找示例的最简单方法是使用LatLonGridOverlay。我将逻辑简化为下面简单易懂的东西。关键是代码的顺序,看标题,然后将图标设置为null,然后添加到地图。您必须根据折线的坐标确定标记的位置,但它确实有效。
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
答案 1 :(得分:0)
单独将 icon 设置为 null 对我不起作用,我需要使用 setTextIcon:
distanceMarker = new Marker(mapView);
distanceMarker.setIcon(null);
distanceMarker.setTextIcon(distance);
GeoPoint p3 = new GeoPoint((loc.getLatitude()+poi.getLat())/2,(loc.getLongitude()+poi.getLon())/2);
distanceMarker.setPosition(p3);
mapView.getOverlayManager().add(distanceMarker);