Skip to content Skip to sidebar Skip to footer

Assign A Click Listener To The Info Window, Cannot Navigate To The Webpage Google Maps V2

The problem is that I cannot click on the URL 'www.news.com' displayed on andoid map v2 inside custom infowindow of a marker. In xml layout file I have:

Solution 1:

Info window is not a live View, rather the view is rendered as an image onto the map. So the view only response click as a whole view. For your case I suppose you have to use GoogleMap.setOnInfoWindowClickListener, and then retrieve the web string to launch.

[UPDATE1]

Maybe you could try this way:

mMap.setOnInfoWindowClickListener(newGoogleMap.OnInfoWindowClickListener()
{

           @OverridepublicvoidonInfoWindowClick(Marker thisMarker)
           {

                IntentviewIntent=newIntent(Intent.ACTION_VIEW, Uri.parse("http://www.news.com"));
                startActivity(viewIntent);                 

           }

});

[UPDATE2]

For the case you have several Markers, and want to open different Activity when click each Marker, then one solution is to put Activity info to Marker's Snippet as:

Markermarker= mMap.addMarker(newMarkerOptions()
 .position(...)
 .title(...)
 .snippet("http://www.news.com"); //put your activity info here

and then get it when click Marker:

@OverridepublicvoidonInfoWindowClick(Marker thisMarker)
{
         ... ...
     StringsnippetStr= thisMarker.getSnippet();
     StringwebUrl= snippetStr.substring(snippetStr.lastIndexOf("website:") + 1);
     IntentviewIntent=newIntent(Intent.ACTION_VIEW, Uri.parse(webUrl));
     startActivity(viewIntent);
}

Post a Comment for "Assign A Click Listener To The Info Window, Cannot Navigate To The Webpage Google Maps V2"