Android Studio 如何在Osmdroid中的文件夹中间添加文本下方/上方

tyg4sfes  于 12个月前  发布在  Android
关注(0)|答案(2)|浏览(121)

如何在osmdroid中的文件夹中间添加文本下方/上方?setTitle()不工作,setSubDescription()也不工作。
以及如何添加按钮覆盖。

mwngjboj

mwngjboj1#

有一种方法可以做到这一点,这是一个选择在标记类的功能。找到示例的最简单方法是使用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

source

hpcdzsge

hpcdzsge2#

将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);

相关问题