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/ios | |
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/ios')
-rw-r--r-- | platform/ios/app/MBXViewController.m | 24 | ||||
-rw-r--r-- | platform/ios/docs/guides/For Style Authors.md | 9 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | platform/ios/jazzy.yml | 5 | ||||
-rw-r--r-- | platform/ios/src/UIImage+MGLAdditions.h | 2 | ||||
-rw-r--r-- | platform/ios/src/UIImage+MGLAdditions.mm | 4 |
6 files changed, 37 insertions, 13 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 756f4d5516..29c5c65012 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -1317,15 +1317,33 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { { MGLCoordinateQuad coordinateQuad = { { 46.437, -80.425 }, - { 46.437, -71.516 }, + { 37.936, -80.425 }, { 37.936, -71.516 }, - { 37.936, -80.425 } }; + { 46.437, -71.516 } }; + + MGLImageSource *imageSource = [[MGLImageSource alloc] initWithIdentifier:@"style-image-source-id" coordinateQuad:coordinateQuad URL:[NSURL URLWithString:@"https://www.mapbox.com/mapbox-gl-js/assets/radar0.gif"]]; - MGLImageSource *imageSource = [[MGLImageSource alloc] initWithIdentifier:@"style-image-source-id" coordinates:coordinateQuad imageURL:[NSURL URLWithString:@"https://www.mapbox.com/mapbox-gl-js/assets/radar.gif"]]; [self.mapView.style addSource:imageSource]; MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"style-raster-image-layer-id" source:imageSource]; [self.mapView.style addLayer:rasterLayer]; + + [NSTimer scheduledTimerWithTimeInterval:1.0 + target:self + selector:@selector(updateAnimatedImageSource:) + userInfo:imageSource + repeats:YES]; +} + + +- (void)updateAnimatedImageSource:(NSTimer *)timer { + static int radarSuffix = 0; + MGLImageSource *imageSource = (MGLImageSource *)timer.userInfo; + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.mapbox.com/mapbox-gl-js/assets/radar%d.gif", radarSuffix++]]; + [imageSource setValue:url forKey:@"URL"]; + if (radarSuffix > 3) { + radarSuffix = 0; + } } -(void)styleCountryLabelsLanguage diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index 734e0dc9ee..8b7bc05f2c 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -127,8 +127,9 @@ In style JSON | In the SDK `geojson` | `MGLShapeSource` `raster` | `MGLRasterSource` `vector` | `MGLVectorSource` +`image` | `MGLImageSource` -`canvas`, `image`, and `video` sources are not supported. +`canvas` and `video` sources are not supported. ### Tile sources @@ -169,6 +170,12 @@ To create a shape source from local GeoJSON data, first [convert the GeoJSON data into a shape](working-with-geojson-data.html#converting-geojson-data-into-shape-objects), then use the `-[MGLShapeSource initWithIdentifier:shape:options:]` method. +### Image sources + +Image sources accept a non-axis aligned quadrilateral as their geographic coordinates. +These coordinates, in `MGLCoordinateQuad`, are described in counterclockwise order, +in contrast to the clockwise order defined in the style specification. + ## Configuring the map content’s appearance Each layer defined by the style JSON file is represented at runtime by a style diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 0ed3fdbe8c..a906c4fd77 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -9,8 +9,6 @@ /* Begin PBXBuildFile section */ 071BBAFF1EE7613E001FB02A /* MGLImageSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */; }; 071BBB001EE7613F001FB02A /* MGLImageSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */; }; - 071BBB011EE76142001FB02A /* MGLImageSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFB1EE75CD4001FB02A /* MGLImageSource_Private.h */; }; - 071BBB021EE76143001FB02A /* MGLImageSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFB1EE75CD4001FB02A /* MGLImageSource_Private.h */; }; 071BBB031EE76146001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB071EE77631001FB02A /* MGLImageSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */; }; @@ -545,7 +543,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 071BBAFB1EE75CD4001FB02A /* MGLImageSource_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLImageSource_Private.h; sourceTree = "<group>"; }; 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLImageSource.h; sourceTree = "<group>"; }; 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLImageSource.mm; sourceTree = "<group>"; }; 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLImageSourceTests.m; path = ../../darwin/test/MGLImageSourceTests.m; sourceTree = "<group>"; }; @@ -988,7 +985,6 @@ isa = PBXGroup; children = ( 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */, - 071BBAFB1EE75CD4001FB02A /* MGLImageSource_Private.h */, 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */, 3566C76A1D4A8DFA008152BC /* MGLRasterSource.h */, DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */, @@ -1721,7 +1717,6 @@ DA8847F21CBAFA5100AB86E3 /* MGLMapCamera.h in Headers */, 3538AA1D1D542239008EC33D /* MGLForegroundStyleLayer.h in Headers */, DA8847F51CBAFA5100AB86E3 /* MGLOfflineRegion.h in Headers */, - 071BBB011EE76142001FB02A /* MGLImageSource_Private.h in Headers */, DA737EE11D056A4E005BDA16 /* MGLMapViewDelegate.h in Headers */, DA8848851CBB033F00AB86E3 /* FABKitProtocol.h in Headers */, DA88481B1CBAFA6200AB86E3 /* MGLGeometry_Private.h in Headers */, @@ -1757,7 +1752,6 @@ FA68F14B1E9D656600F9F6C2 /* MGLFillExtrusionStyleLayer.h in Headers */, 353933FC1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h in Headers */, 3566C76D1D4A8DFA008152BC /* MGLRasterSource.h in Headers */, - 071BBB021EE76143001FB02A /* MGLImageSource_Private.h in Headers */, DAED38641D62D0FC00D7640F /* NSURL+MGLAdditions.h in Headers */, DABFB85E1CBE99E500D62B32 /* MGLAnnotation.h in Headers */, DABFB8641CBE99E500D62B32 /* MGLOfflineStorage.h in Headers */, diff --git a/platform/ios/jazzy.yml b/platform/ios/jazzy.yml index 31380faa2c..ba56c312eb 100644 --- a/platform/ios/jazzy.yml +++ b/platform/ios/jazzy.yml @@ -75,6 +75,7 @@ custom_categories: children: - MGLSource - MGLTileSource + - MGLImageSource - MGLShapeSource - MGLRasterSource - MGLVectorSource @@ -108,6 +109,9 @@ custom_categories: - MGLCoordinateBoundsMake - MGLCoordinateBoundsOffset - MGLCoordinateInCoordinateBounds + - MGLCoordinateQuad + - MGLCoordinateQuadMake + - MGLCoordinateQuadFromCoordinateBounds - MGLCoordinateSpan - MGLCoordinateSpanEqualToCoordinateSpan - MGLCoordinateSpanMake @@ -115,6 +119,7 @@ custom_categories: - MGLDegreesFromRadians - MGLRadiansFromDegrees - MGLStringFromCoordinateBounds + - MGLStringFromCoordinateQuad - name: Formatters children: - MGLClockDirectionFormatter diff --git a/platform/ios/src/UIImage+MGLAdditions.h b/platform/ios/src/UIImage+MGLAdditions.h index 671a5ced85..6e15e07cb5 100644 --- a/platform/ios/src/UIImage+MGLAdditions.h +++ b/platform/ios/src/UIImage+MGLAdditions.h @@ -10,7 +10,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/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm index 029366c01e..5e28d18190 100644 --- a/platform/ios/src/UIImage+MGLAdditions.mm +++ b/platform/ios/src/UIImage+MGLAdditions.mm @@ -25,11 +25,11 @@ - (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier { BOOL isTemplate = self.renderingMode == UIImageRenderingModeAlwaysTemplate; return std::make_unique<mbgl::style::Image>([identifier UTF8String], - self.mgl_PremultipliedImage, + self.mgl_premultipliedImage, float(self.scale), isTemplate); } --(mbgl::PremultipliedImage)mgl_PremultipliedImage { +-(mbgl::PremultipliedImage)mgl_premultipliedImage { return MGLPremultipliedImageFromCGImage(self.CGImage); } @end |