Center fixed marker in android v2 mapview -
i want set fixed marker in center point of mapview
while dragging map.it has been done @ android map v1 google mapview
. it's deprecated.now question is, possible in android map v2 google mapview
?(i have tried.but map doesn't show)
i'm betting used getmapcenter()
which, per google maps android v2, no longer available use. no worries, use this:
googlemap.getcameraposition().target
it return latlng
object represents center of map. can use reposition marker center every time there's drag event assigning oncamerachangedlistener
googlemap
.
yourgmapinstance.setoncamerachangelistener(new oncamerachangedlistener() { @override public void oncamerachange (cameraposition position) { // center of map. latlng centerofmap = yourgmapinstance.getcameraposition().target; // update marker's position center of map. yourmarkerinstance.setposition(centerofmap); } });
there. hope helped!
Comments
Post a Comment