Android Google Map - Clicked marker opens new activity or bigger window -


i've been searching on implementing onmarkerclicklistener nothing i've found has worked. marker below , when clicked changes colour(light blue). i'm looking open bigger window can put in more info. possible?

     googlemap.addmarker(new markeroptions()     .position(new latlng(49.378,-0.3904))     .title("hello world")     .snippet("this test app")         .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_orange))); 

the marker works fine above on map click on marker , open new activity/page or bigger window, ever easier work with. real novice @ making apps, if has got working example please put link or code.

thanks in advance!

edit:

from tutorial suggested have changed of mainactivity.java.

i've added in onmarkerclicklistener , have chosen add unimplemented methods public class

  public class mainactivity extends activity implements locationlistener, onmarkerclicklistener { 

underneath private void setupmap() have added code: private marker mymarker, setonmarkerclick listener , mymarker =, :

       private marker mymarker;          { googlemap.setonmarkerclicklistener(this);  mymarker = googlemap.addmarker(new markeroptions()     .position(new latlng(latlng))     .title("hello world")     .snippet("my first app")         .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_orange)));   } 

in unimplemented method @ bottom have:

   @override    public boolean onmarkerclick(marker arg0) { // todo auto-generated method stub   return false; 

what need change in public boolean onmarkerclick part? i'm not getting errors not working. else have add in or change?

any appreciated!

marker click events

don't snap marker after click in android map v2

quoting above post

you can use onmarkerclicklistener listen click events on marker. set listener on map, call googlemap.setonmarkerclicklistener(onmarkerclicklistener). when user clicks on marker, onmarkerclick(marker) called , marker passed through argument. method returns boolean indicates whether have consumed event (i.e., want suppress default behavior). if returns false, default behavior occur in addition custom behavior. default behavior marker click event show info window (if available) , move camera such marker centered on map.

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/googlemap.onmarkerclicklistener.

use onmarkerclicklistener on marker.

check link code snippets

google maps api v2: how make markers clickable?

example: works on phone

        marker source,destination;          googlemap mmap;          mmap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map))                                 .getmap();          source = mmap.addmarker(new markeroptions()                 .position(sc)                 .title("myhome")                 .snippet("bangalore")                     .icon(bitmapdescriptorfactory.fromresource(r.drawable.pin)));           destination= mmap.addmarker(new markeroptions()                 .position(lng)                 .title("maplebear head office")                 .snippet("jayanager")                 .icon(bitmapdescriptorfactory.fromresource(r.drawable.pin)));                 mmap.setonmarkerclicklistener(new onmarkerclicklistener()                 {                      @override                     public boolean onmarkerclick(marker arg0) {                         if(arg0.gettitle().equals("myhome")) // if marker source clicked                              toast.maketext(mainactivity.this, arg0.gettitle(), toast.length_short).show();// display toast                         return true;                     }                  });        

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -