在谷歌地图API V2定制覆盖 [英] Custom Overlays in Google Maps API v2

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

问题描述

我需要创建自己的地图和定制我的意思是,我需要更多的信息添加到叠加,使其被点击时,我可以显示一个对话框,或一些有关覆盖信息一些定制多边形覆盖。

I need to create some custom polygon overlays on my map and by custom I mean I need to add more information to the overlay so that when it gets clicked I can show a dialog or something with information about the overlay.

我做了一些阅读和它看起来像覆盖 ItemizedOverlay 类是从API第2版中删除形式为多边形折线等...

I have done a little reading and it looks like the Overlay and ItemizedOverlay classes were removed from the API v2 in the form of Polygons,Polylines etc...

为了创建一个自定义覆盖它看起来像我要创建一个查看在地图之上,只是借鉴的看法,但我的一些多边形可能不对于当前地图投影可见

In order to create a custom overlay it looks like I have to create a View on top of the map and just draw on the view but some of my polygons might not be visible for the current map projection

反正有一个id分配给多边形类或东西,让我知道被点击,所以我可以得到的信息是什么?

Is there anyway to assign an id to the polygon class or something so that I know what was clicked so I can get the information?

推荐答案

所有的Andr​​oid GMaps实现API V2不提供点击多边形时回调的第一个。你将不得不使用onMapClick并使用点多边形内部的算法遍历所有多边形。

First of all GMaps Android API v2 doesn't provide a callback for when a polygon is clicked. You would have to use onMapClick and use point inside polygon algorithm iterating over all polygons.

如果你把地图,你可以遍历键,如果你有一个比赛,获得的价值。

If you keep Map you can iterate over keys and if you have a match, get the value.

另外,你可能想尝试 Android地图扩展,其中有一个 GoogleMap.getPolygons()为您遍历和 Polygon.setData(对象) + Polygon.getData()来分配任何额外的数据和检索它,当你使用的多边形算法内侧位置找到一个匹配。

Alternatively you may want to try Android Maps Extensions, which has a GoogleMap.getPolygons() for you to iterate over and Polygon.setData(Object) + Polygon.getData() to assign any additional data and retrieve it when you find a match using point inside polygon algorithm.

这篇关于在谷歌地图API V2定制覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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