【发布时间】:2016-12-02 15:11:52
【问题描述】:
如何在osmdroid中的折线中间添加下方/上方的文本? setTitle() 不起作用,setSubDescription() 也不起作用。
还有如何添加按钮叠加层。
【问题讨论】:
如何在osmdroid中的折线中间添加下方/上方的文本? setTitle() 不起作用,setSubDescription() 也不起作用。
还有如何添加按钮叠加层。
【问题讨论】:
有一种方法可以做到这一点,它是 Marker 类的一个可选功能。查找示例的最简单方法是使用 LatLonGridOverlay。我将在下面将逻辑简化为易于理解的内容。关键是代码的顺序,看标题,然后把icon设置为null,再添加到map中。您必须根据折线的坐标确定您希望标记的位置,但它确实有效。
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
【讨论】:
单独将图标设置为 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);
【讨论】: