ios - Google Maps: get coordinates on touch -
i trying find coordinates of point when touch google map, far have done not working. ideally, want able coordinates of point on map when click it. after, able put pin on location.
i tried other attempts like:
- (void)longpresstogetlocation:(uigesturerecognizer *)gesturerecognizer { if (gesturerecognizer.state != uigesturerecognizerstatebegan) return; cgpoint touchpoint = [gesturerecognizer locationinview:self.mapview]; cllocationcoordinate2d location = [self.mapview convertpoint:touchpointtocoordinatefromview:self.mapview]; nslog(@"location found map: %f %f",location.latitude,location.longitude); }
but not work , got error saying "no visible @interface gmsmapview declares selector convertpoint tocoordinatefromview.
i kind of lost , not sure do.
best, j
the google maps gives delegate when tapped @ point. way these events is,
you conform class gmsmapviewdelegate
, implement method: - mapview:didtapatcoordinate:
. make sure set delegate of mapview
self
.
you can find gmsmapviewdelegate
here.
Comments
Post a Comment