Skip to content

Instantly share code, notes, and snippets.

@lloydsheng
Last active March 19, 2018 08:11
Show Gist options
  • Save lloydsheng/0d9b1cc76eb08bdf45810668c1eb1502 to your computer and use it in GitHub Desktop.
Save lloydsheng/0d9b1cc76eb08bdf45810668c1eb1502 to your computer and use it in GitHub Desktop.
- (MKMapRect)visibleMapRect {
MGLCoordinateBounds bounds = self.mapboxMapView.visibleCoordinateBounds;
MKMapPoint sw = MKMapPointForCoordinate(bounds.sw);
MKMapPoint ne = MKMapPointForCoordinate(bounds.ne);
double x = sw.x;
double y = ne.y;
double width = ne.x - sw.x;
double height = sw.y - ne.y;
if (width < 0) {
width += MKMapSizeWorld.width;
}
if (height < 0) {
height += MKMapSizeWorld.height;
}
return MKMapRectMake(x, y, width, height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment