除去谷歌地图折线 [英] Removing a polyline from google maps

查看:402
本文介绍了除去谷歌地图折线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能通过其ID来移除谷歌地图折线?其实我有一个活动,并在具体的案例来绘制折线已经在第二活动中删除它,我TRID通过意图传递折线但未能成功,我能够传递折线的id,现在的我试图通过它的ID删除的折线,这可能吗?感谢您的帮助。

Is it possible to remove a polyline from google maps through its id? Actually I have to draw a polyline in one activity and in a specific case have to remove it in the second activity, I trid to pass that polyline through intent but couldn't succeed, I was able to pass that polyline's id, now I am trying to remove the polyline through it's id, is it possible? Thanks for your help

推荐答案

这可能不是一个直接的答案,但在我的情况下,这是我会怎么做。

This may not be a direct answer but in my case this is how I would do it

首先跟踪折线。

Map<String , Polyline> mHashMap = new HashMap<String , Polyline>();
...
Polyline polyline = this.mMap.addPolyline(new PolylineOptions().....);

mHashMap.put(polyline.getId() , polyline);

现在将其删除。

//probably this would happen on `OnActivityResult` of first_activity

Polyline pl = mHashMap.get("polyline_id_from_first_activity_rerouted_from_second_activity");
pl.remove();

希望它能帮助:)

Hope it helps :)

这篇关于除去谷歌地图折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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