mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
323 stars 8 forks source link

Converting a CGPoint to a CLLocation or CLLocationCoordinate2D (Question) #671

Closed mitchellporter closed 8 years ago

mitchellporter commented 8 years ago

So based on how my app functions I need to be able to draw the polygon annotation using an array of CGPoints. This works fine by default in the 2.0 SDK, but in version 1.6 the polygon's initialization method wants an array of CLLocation objects.

So I need to convert my CGPoints to CLLocation objects or CLLocationCoordinate2D's

I found the following StackOverflow answer which allows you to do this using MapKit: http://stackoverflow.com/a/16230174/3344977

But it seems kind of foolish to use MapKit and initialize an MKMapView that no one will ever see just so I can utilize this one function, and now that I think about it there's no way to guarantee that the MKMapView would be in sync with the real RMMapView so this workaround would be unreliable anyways.

I've been looking through the mapbox legacy API docs and can't seem to find a similar function, so I'm hoping that one exists and I've simply made a mistake.

Is there any way to convert a CGPoint to a CLLocation or CLLocationCoordinate2D using the mapbox legacy iOS SDK?

Thanks.

incanus commented 8 years ago

Yep, check out this example. You want API like -[RMMapView pixelToCoordinate:].

mitchellporter commented 8 years ago

@incanus Thanks!