From 9720f581ff614f625819c31ea6f26f61b930342b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 23 Aug 2016 18:12:35 -0700 Subject: [PATCH] [macos] Avoid negative content insets (#6102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed an issue in which a map view that doesn’t occupy the entire window would consider its center point to be the window’s center point rather than the view’s. --- platform/macos/CHANGELOG.md | 1 + platform/macos/src/MGLMapView.mm | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 2e51a4d3d..d0d2d0b5a 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -7,6 +7,7 @@ * A new runtime styling API allows you to adjust the style and content of the base map dynamically. All the options available in [Mapbox Studio](https://www.mapbox.com/studio/) are now exposed via MGLStyle and subclasses of MGLStyleLayer and MGLSource. ([#5727](https://github.com/mapbox/mapbox-gl-native/pull/5727)) * Improved offline and ambient cache database performance. ([#5796](https://github.com/mapbox/mapbox-gl-native/pull/5796)) * Added `showAnnotations:animated:` and `showAnnotations:edgePadding:animated:`, which moves the map viewport to show the specified annotations. ([#5749](https://github.com/mapbox/mapbox-gl-native/pull/5749)) +* Fixed an issue where the map view’s center would always be calculated as if the view occupied the entire window. ([#6102](https://github.com/mapbox/mapbox-gl-native/pull/6102)) * To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088)) * MGLMapView’s `styleURL` property can now be set to an absolute file URL. ([#6026](https://github.com/mapbox/mapbox-gl-native/pull/6026)) * GeoJSON sources specified by the stylesheet at design time now support `cluster`, `clusterMaxZoom`, and `clusterRadius` attributes for clustering point features on the base map. ([#5724](https://github.com/mapbox/mapbox-gl-native/pull/5724)) diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 7b7ab0247..a222f55fa 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1180,8 +1180,8 @@ public: NSRect contentLayoutRect = [self convertRect:self.window.contentLayoutRect fromView:nil]; if (NSMaxX(contentLayoutRect) > 0 && NSMaxY(contentLayoutRect) > 0) { contentInsets = NSEdgeInsetsMake(NSHeight(self.bounds) - NSMaxY(contentLayoutRect), - NSMinX(contentLayoutRect), - NSMinY(contentLayoutRect), + MAX(NSMinX(contentLayoutRect), 0), + MAX(NSMinY(contentLayoutRect), 0), NSWidth(self.bounds) - NSMaxX(contentLayoutRect)); } } else {