地图视图并获取 MapItemizedOverlay Activity 上的变量
我的 Android 应用程序上有 MapView。我有一个 GoogleMapsActivity,可以在其中获取要在地图上显示的坐标。
GeoPoint point = new GeoPoint((int) (lat * 1E6),(int) (lng * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "title", "text");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
而且,我也有一个 MapsItemizedOverlay 活动,我在其中显示这些点。基本上我遵循了 MapView 教程。 现在我需要将 int 和字符串从 GoogleMapsActivity 传递到 MapsItemizedOveraly,因为当我点击标记时我需要重定向到 URL。
我不知道我是否解释过,但在简历中: 我需要将一个字符串和一个整数从 GoogleMapsActivity 传递到 MapsItemizedOverlay。
感谢您的帮助。
I have MapView on my android application. I have a GoogleMapsActivity where I get coords to display on a map.
GeoPoint point = new GeoPoint((int) (lat * 1E6),(int) (lng * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "title", "text");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
And, I have too a MapsItemizedOverlay activity, where I display this points. Basically I followed the MapView tutorial.
Now I need to pass an int and string from GoogleMapsActivity to MapsItemizedOveraly, because when I tap on a mark I need to redirect to a URL.
I don't know if I explain, but in resume:
I need to pass one string and one int from GoogleMapsActivity to MapsItemizedOverlay.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这里,可能会有所帮助:
Android - 获取地图叠加项的点击事件
基本上你需要重写 ItemizedOverlay.onTap(int index) 方法。
这是一个片段,当点击已添加到地图中的第一个(索引 0)项目时,将打开 stackoverflow.com 页面(您需要将活动上下文传递给构造函数中扩展 ItemizedOverlay 的类,例如将其分配给 mContext:
希望这个是你想要实现的目标:)
Have a look here, it might help:
Android - Get Click Event of Map Overlay Item
Basically you need to override ItemizedOverlay.onTap(int index) method.
Here is a snippet that will open stackoverflow.com page when tapped on first (index 0) item that has been added to the map (you need to pass activity context to the class extending ItemizedOverlay in constructor, say assigning it to mContext:
Hope this is what you wanted to achieve :)