1

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.

pkk
  • 3,691
  • 2
  • 21
  • 29
Pipeline
  • 567
  • 1
  • 8
  • 23

1 Answers1

0

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 :)

Community
  • 1
  • 1
pkk
  • 3,691
  • 2
  • 21
  • 29
  • Hi. Thanks for your answer. I already have an onTap method, but I need to get a value from GoogleMapsActivity to do something like: Uri.parse("http://example.com/?id=" + x); where x is a value from GoogleMapsActivity. – Pipeline Aug 16 '11 at 07:36