如何在osmdroid中的折线中间添加下方/上方的文本 [英] How to add text below/above in the middle of the polyline in osmdroid

查看:86
本文介绍了如何在osmdroid中的折线中间添加下方/上方的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在osmdroid的折线中间添加下方/上方文本?setTitle() 不起作用,setSubDescription() 也不起作用.
以及如何添加按钮叠加层.

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.

推荐答案

有一种方法可以做到这一点,它是 Marker 类的一个选择功能.查找示例的最简单方法是使用 LatLonGridOverlay.我将在下面将逻辑简化为易于理解的内容.关键是code的顺序,看标题,然后把icon设置为null,然后添加到地图中.您必须根据折线的坐标确定您希望标记的位置,但它确实有效.

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

来源

这篇关于如何在osmdroid中的折线中间添加下方/上方的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆