Map view and get variables on MapItemizedOverlay Activity
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,开发者_StackOverflow 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.
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:
@Override
protected boolean onTap(int index) {
if (index == 0) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://stackoverflow.com/questions/7050144/map-view-and-get-variables-on-mapitemizedoverlay-activity/7050301#7050301"));
mContext.startActivity(i);
return true;
}
return super.onTap(index);
}
Hope this is what you wanted to achieve :)
精彩评论