How to move marker on gmsmapview in google sdk ios -


i want move marker on basis of lat,long i'm getting continously i'm doing below...

- (void)locationmanager:(cllocationmanager *)manager didupdatelocations   (nsarray<cllocation *> *)locations  {  cllocationcoordinate2d coor2d = cllocationcoordinate2dmake(longitude, latitude);     self.marker.position = coor2d;  } 

the method updating lat long markers not moving why... in info.plist have added.. enter image description here

try this, assuming have set delegate:

- (void)locationmanager:(cllocationmanager *)manager didupdatelocations   (nsarray<cllocation *> *)locations  {  cllocationcoordinate2d coor2d = cllocationcoordinate2dmake(longitude, latitude);     self.marker.position = coor2d;  [self.mapview animatetolocation:coord2d.coordinate] } 

if you're trying update current location. should use kvo that.

@implementation mylocationviewcontroller {   gmsmapview *mapview_;   bool firstlocationupdate_; }  - (void)viewdidload {   [super viewdidload];   gmscameraposition *camera = [gmscameraposition camerawithlatitude:-33.868                                                           longitude:151.2086                                                                zoom:12];    mapview_ = [gmsmapview mapwithframe:cgrectzero camera:camera];   mapview_.settings.compassbutton = yes;   mapview_.settings.mylocationbutton = yes;    // listen mylocation property of gmsmapview.   [mapview_ addobserver:self              forkeypath:@"mylocation"                 options:nskeyvalueobservingoptionnew                 context:null];    self.view = mapview_;    // ask location data after map has been added ui.   dispatch_async(dispatch_get_main_queue(), ^{     mapview_.mylocationenabled = yes;   }); }  - (void)dealloc {   [mapview_ removeobserver:self                 forkeypath:@"mylocation"                    context:null]; }  #pragma mark - kvo updates  - (void)observevalueforkeypath:(nsstring *)keypath                       ofobject:(id)object                         change:(nsdictionary *)change                        context:(void *)context {   if (!firstlocationupdate_) {     // if first location update has not yet been recieved, jump     // location.     firstlocationupdate_ = yes;     cllocation *location = [change objectforkey:nskeyvaluechangenewkey];     mapview_.camera = [gmscameraposition camerawithtarget:location.coordinate                                                      zoom:14];   } }  @end 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -