diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-06-13 12:55:01 -0700 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-06-19 09:50:08 -0700 |
commit | 7f36e0cf769f6fe7a759b1cf6c56948c4c141fef (patch) | |
tree | 2b72187a6306df9d97d4b57007bd64c86a4bf4c7 /platform/macos/src | |
parent | b7c7d3fdab283d7bf03d8acf68b9cfd478d6973f (diff) | |
download | qtlocation-mapboxgl-7f36e0cf769f6fe7a759b1cf6c56948c4c141fef.tar.gz |
[iOS][macOS] Export `MGLImageSource`, add and update documentation. Use animated ImageSource demo in iOS test app
Diffstat (limited to 'platform/macos/src')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 16 | ||||
-rw-r--r-- | platform/macos/src/NSImage+MGLAdditions.h | 2 | ||||
-rw-r--r-- | platform/macos/src/NSImage+MGLAdditions.mm | 4 |
3 files changed, 14 insertions, 8 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index a8a84522a5..d2cb5e7100 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -20,6 +20,7 @@ #import "MGLPolyline.h" #import "MGLAnnotationImage.h" #import "MGLMapViewDelegate.h" +#import "MGLImageSource.h" #import <mbgl/map/map.hpp> #import <mbgl/map/view.hpp> @@ -943,13 +944,16 @@ public: } } -- (void)sourceDidChange { +- (void)sourceDidChange:(MGLSource *)source { if (!_mbglMap) { return; } - - [self installAttributionView]; + // Attribution only applies to tiled sources + if ([source isKindOfClass:[MGLTileSource class]]) { + [self installAttributionView]; + } self.needsUpdateConstraints = YES; + self.needsDisplay = YES; } #pragma mark Printing @@ -2847,8 +2851,10 @@ public: [nativeView mapViewDidFinishLoadingStyle]; } - void onSourceChanged(mbgl::style::Source&) override { - [nativeView sourceDidChange]; + void onSourceChanged(mbgl::style::Source& source) override { + NSString *identifier = @(source.getID().c_str()); + MGLSource * nativeSource = [nativeView.style sourceWithIdentifier:identifier]; + [nativeView sourceDidChange:nativeSource]; } mbgl::gl::ProcAddress initializeExtension(const char* name) override { diff --git a/platform/macos/src/NSImage+MGLAdditions.h b/platform/macos/src/NSImage+MGLAdditions.h index 0e57784bc5..c08fc57bea 100644 --- a/platform/macos/src/NSImage+MGLAdditions.h +++ b/platform/macos/src/NSImage+MGLAdditions.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN - (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier; -- (mbgl::PremultipliedImage) mgl_PremultipliedImage; +- (mbgl::PremultipliedImage) mgl_premultipliedImage; @end diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm index e4ef38eea5..6abe53e9ae 100644 --- a/platform/macos/src/NSImage+MGLAdditions.mm +++ b/platform/macos/src/NSImage+MGLAdditions.mm @@ -33,7 +33,7 @@ } - (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier { - mbgl::PremultipliedImage cPremultipliedImage = self.mgl_PremultipliedImage; + mbgl::PremultipliedImage cPremultipliedImage = self.mgl_premultipliedImage; auto imageWidth = cPremultipliedImage.size.width; return std::make_unique<mbgl::style::Image>([identifier UTF8String], std::move(cPremultipliedImage), @@ -41,7 +41,7 @@ [self isTemplate]); } -- (mbgl::PremultipliedImage)mgl_PremultipliedImage { +- (mbgl::PremultipliedImage)mgl_premultipliedImage { // Create a bitmap image representation from the image, respecting backing // scale factor and any resizing done on the image at runtime. // http://www.cocoabuilder.com/archive/cocoa/82430-nsimage-getting-raw-bitmap-data.html#82431 |