[英]Set marker on Polyline in google maps
I've tried to make possible choice on polyline in google maps. 我试图在谷歌地图的折线上做出可能的选择。 But I'm stuck.
但是我被困住了。 For example: I have 10 points (with lines).
例如:我有10点(带线)。
by using this part of code: 通过使用这部分代码:
polylines = new PolylineOptions();
polylines.color(getResources().getColor(R.color.poly_line_color));
//add path points, set colour, etc. here
polyline = mMap.addPolyline(polylines);
polyline.setPoints(latLngs);
polyline.setClickable(true);
mMap.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
@Override
public void onPolylineClick(Polyline polyline) {
Logger.e("id : "+polyline.getPoints());
}
});
we can easy detect click on polyline. 我们可以轻松检测出折线上的点击。 But - I can't detect current coordinates (latitude/longitude) for this click.
但是-我无法检测到此点击的当前坐标(纬度/经度)。
I tried method 我尝试过方法
"PolyUtil"
“PolyUtil”
from another library - but this is work randomly and not correct. 从另一个库中获取-但这是随机工作,不正确。 And really - look like it does not work.
确实-看起来不起作用。 10 clicks on map = 1 good point which is not on polyline or near this line.
在地图上点击10次= 1个好点,该点不在折线上或在此线附近。
Polyline polyline has only few methods and only one normal "getPoints()" but its returned all points.
折线折线只有很少的方法,只有一个普通的“ getPoints()”,但是它返回了所有点。
Can anyone help me with this? 谁能帮我这个? I checked a lot of posts on SO but none helped me.
我检查了很多关于SO的帖子,但没有一个对我有帮助。
map.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
polyline.getPoints()
});
Try this function polyline.getPoints()
in your code. 在您的代码中尝试使用此函数
polyline.getPoints()
。 This may help you. 这可能对您有帮助。 Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.