From 6742017a9a272a362efac537c6fd3938d6e0c95c Mon Sep 17 00:00:00 2001 From: m-stephen Date: Tue, 4 Jun 2019 11:05:24 +0800 Subject: =?UTF-8?q?[macos]Added=20an=20`MGLMapView.prefetchesTiles`=20prop?= =?UTF-8?q?erty=20to=20configure=20lo=E2=80=A6=20(#14816)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [macos]Added an `MGLMapView.prefetchesTiles` property to configure lower-resolution tile prefetching behavior * [macos]Update changelog --- platform/macos/CHANGELOG.md | 2 ++ platform/macos/src/MGLMapView.h | 13 +++++++++++++ platform/macos/src/MGLMapView.mm | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 520f8c204b..9094e8ebbc 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +* Added an `MGLMapView.prefetchesTiles` property to configure lower-resolution tile prefetching behavior. ([#14816](https://github.com/mapbox/mapbox-gl-native/pull/14816)) + ### Styles and rendering * Setting `MGLMapView.contentInset` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664)) diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index 21ae8c2974..35db5257d9 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -188,6 +188,19 @@ MGL_EXPORT IB_DESIGNABLE */ @property (nonatomic, readonly) NSView *attributionView; +/** + A Boolean value indicating whether the map should prefetch tiles. + + When this property is set to `YES`, the map view prefetches tiles designed for + a low zoom level and displays them until receiving more detailed tiles for the + current zoom level. The prefetched tiles typically contain simplified versions + of each shape, improving the map view’s perceived performance. + + The default value of this property is `YES`. + */ +@property (nonatomic, assign) BOOL prefetchesTiles; + + #pragma mark Manipulating the Viewpoint /** diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 04b895bb50..0a1ec5516a 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -654,6 +654,11 @@ public: self.styleURL = styleURL; } +- (void)setPrefetchesTiles:(BOOL)prefetchesTiles +{ + _mbglMap->setPrefetchZoomDelta(prefetchesTiles ? mbgl::util::DEFAULT_PREFETCH_ZOOM_DELTA : 0); +} + - (mbgl::Map *)mbglMap { return _mbglMap; } -- cgit v1.2.1