diff options
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/CHANGELOG.md | 8 | ||||
-rw-r--r-- | platform/ios/app/Info.plist | 13 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 80 | ||||
-rw-r--r-- | platform/ios/docs/guides/Adding Points to a Map.md | 1 | ||||
-rw-r--r-- | platform/ios/docs/guides/For Style Authors.md | 10 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 23 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme | 2 | ||||
-rw-r--r-- | platform/ios/jazzy.yml | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.h | 29 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 79 | ||||
-rw-r--r-- | platform/ios/src/Mapbox.h | 1 | ||||
-rw-r--r-- | platform/ios/src/UIImage+MGLAdditions.h | 4 | ||||
-rw-r--r-- | platform/ios/src/UIImage+MGLAdditions.mm | 14 | ||||
m--------- | platform/ios/vendor/SMCalloutView | 0 |
14 files changed, 187 insertions, 82 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index c08952a664..785b0ee78b 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,14 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## master + +### Styles + +* Added support for displaying geo-referenced images via the `MGLImageSource`. [#9110](https://github.com/mapbox/mapbox-gl-native/pull/9110) +* The previously-deprecated support for style classes has been removed. For interface compatibility, the API methods remain, but they are now non-functional. +* Added an `overlays` property to `MGLMapView`. ([#8617](https://github.com/mapbox/mapbox-gl-native/pull/8617)) + ## 3.6.0 ### Packaging diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist index d05d81e49d..d5b6825422 100644 --- a/platform/ios/app/Info.plist +++ b/platform/ios/app/Info.plist @@ -51,18 +51,5 @@ <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> - <key>NSAppTransportSecurity</key> - <dict> - <key>NSExceptionDomains</key> - <dict> - <key>stamen.com</key> - <dict> - <key>NSIncludesSubdomains</key> - <true/> - <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> - <true/> - </dict> - </dict> - </dict> </dict> </plist> diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index d3927374a7..29c5c65012 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -52,7 +52,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) { }; typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) { - MBXSettingsRuntimeStylingWater = 0, + MBXSettingsRuntimeStylingBuildingExtrusions = 0, + MBXSettingsRuntimeStylingWater, MBXSettingsRuntimeStylingRoads, MBXSettingsRuntimeStylingRaster, MBXSettingsRuntimeStylingShape, @@ -71,6 +72,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) { MBXSettingsRuntimeStylingUpdateShapeSourceFeatures, MBXSettingsRuntimeStylingVectorSource, MBXSettingsRuntimeStylingRasterSource, + MBXSettingsRuntimeStylingImageSource, MBXSettingsRuntimeStylingCountryLabels, MBXSettingsRuntimeStylingRouteLine, MBXSettingsRuntimeStylingDDSPolygon, @@ -324,6 +326,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { break; case MBXSettingsRuntimeStyling: [settingsTitles addObjectsFromArray:@[ + @"Add Building Extrusions", @"Style Water With Function", @"Style Roads With Function", @"Add Raster & Apply Function", @@ -343,6 +346,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @"Update Shape Source: Features", @"Style Vector Source", @"Style Raster Source", + @"Style Image Source", [NSString stringWithFormat:@"Label Countries in %@", (_usingLocaleBasedCountryLabels ? @"Local Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])], @"Add Route Line", @"Dynamically Style Polygon", @@ -523,6 +527,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsRuntimeStyling: switch (indexPath.row) { + case MBXSettingsRuntimeStylingBuildingExtrusions: + [self styleBuildingExtrusions]; + break; case MBXSettingsRuntimeStylingWater: [self styleWaterLayer]; break; @@ -580,6 +587,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsRuntimeStylingRasterSource: [self styleRasterSource]; break; + case MBXSettingsRuntimeStylingImageSource: + [self styleImageSource]; + break; case MBXSettingsRuntimeStylingCountryLabels: [self styleCountryLabelsLanguage]; break; @@ -860,6 +870,38 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [self.mapView showAnnotations:annotations animated:YES]; } +- (void)styleBuildingExtrusions +{ + MGLSource* source = [self.mapView.style sourceWithIdentifier:@"composite"]; + if (source) { + + MGLFillExtrusionStyleLayer* layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"extrudedBuildings" source:source]; + layer.sourceLayerIdentifier = @"building"; + layer.predicate = [NSPredicate predicateWithFormat:@"extrude == 'true' AND height > 0"]; + layer.fillExtrusionBase = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"min_height" options:nil]; + layer.fillExtrusionHeight = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"height" options:nil]; + + // Set the fill color to that of the existing building footprint layer, if it exists. + MGLFillStyleLayer* buildingLayer = (MGLFillStyleLayer*)[self.mapView.style layerWithIdentifier:@"building"]; + if (buildingLayer) { + if (buildingLayer.fillColor) { + layer.fillExtrusionColor = buildingLayer.fillColor; + } else { + layer.fillExtrusionColor = [MGLStyleValue valueWithRawValue:[UIColor whiteColor]]; + } + + layer.fillExtrusionOpacity = [MGLStyleValue<NSNumber *> valueWithRawValue:@0.75]; + } + + MGLStyleLayer* labelLayer = [self.mapView.style layerWithIdentifier:@"waterway-label"]; + if (labelLayer) { + [self.mapView.style insertLayer:layer belowLayer:labelLayer]; + } else { + [self.mapView.style addLayer:layer]; + } + } +} + - (void)styleWaterLayer { MGLFillStyleLayer *waterLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"water"]; @@ -1261,8 +1303,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)styleRasterSource { - // 3rd party raster source requires NSAppTransportSecurity exception for stamen.com - NSArray *tileURLTemplates = @[@"http://a.tile.stamen.com/terrain-background/{z}/{x}/{y}.jpg"]; + NSArray *tileURLTemplates = @[@"https://stamen-tiles.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.jpg"]; MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"style-raster-source-id" tileURLTemplates:tileURLTemplates options:@{ MGLTileSourceOptionTileSize: @256, }]; @@ -1272,6 +1313,39 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [self.mapView.style addLayer:rasterLayer]; } +- (void)styleImageSource +{ + MGLCoordinateQuad coordinateQuad = { + { 46.437, -80.425 }, + { 37.936, -80.425 }, + { 37.936, -71.516 }, + { 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"]]; + + [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 { NSArray<NSString *> *labelLayers = @[ diff --git a/platform/ios/docs/guides/Adding Points to a Map.md b/platform/ios/docs/guides/Adding Points to a Map.md index ab1702a076..2698d5564f 100644 --- a/platform/ios/docs/guides/Adding Points to a Map.md +++ b/platform/ios/docs/guides/Adding Points to a Map.md @@ -36,7 +36,6 @@ By default, annotations added to the map are displayed with a red pin ([example] * Annotation images are purely static and cannot be animated * No control over z-ordering -* Limits to the number and size of images you can add ### Annotation Views (`MGLAnnotationView`) diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index 35375ea2a9..7eabfed777 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -109,7 +109,6 @@ the following terms for concepts defined in the style specification: In the style specification | In the SDK ---------------------------|--------- -class | style class filter | predicate function type | interpolation mode id | identifier @@ -130,8 +129,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 @@ -172,6 +172,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 ab110bca5c..9af8387233 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -7,6 +7,11 @@ objects = { /* 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 */; }; + 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 */; }; 1753ED421E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; }; 1753ED431E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; }; 1F06668A1EC64F8E001C16D7 /* MGLLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F0666881EC64F8E001C16D7 /* MGLLight.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -186,6 +191,8 @@ 40F887701D7A1E58008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40F887711D7A1E59008ECB67 /* MGLShapeSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */; }; 40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; }; + 5549A0391EF2877100073113 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; + 5549A03A1EF2877500073113 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; }; 556660CA1E1BF3A900E2C41B /* MGLFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 556660C91E1BF3A900E2C41B /* MGLFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 556660D81E1D085500E2C41B /* MGLVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 556660D71E1D085500E2C41B /* MGLVersionNumber.m */; }; 556660DB1E1D8E8D00E2C41B /* MGLFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 556660C91E1BF3A900E2C41B /* MGLFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -540,6 +547,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 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>"; }; 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLConversion.h; sourceTree = "<group>"; }; 1F0666881EC64F8E001C16D7 /* MGLLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLight.h; sourceTree = "<group>"; }; 1F0666891EC64F8E001C16D7 /* MGLLight.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLight.mm; sourceTree = "<group>"; }; @@ -938,6 +948,7 @@ buildActionMask = 2147483647; files = ( DA8847D91CBAF91600AB86E3 /* Mapbox.framework in Frameworks */, + 5549A0391EF2877100073113 /* OpenGLES.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -971,6 +982,7 @@ buildActionMask = 2147483647; files = ( DAA4E4081CBB6C9500178DFB /* Mapbox.framework in Frameworks */, + 5549A03A1EF2877500073113 /* OpenGLES.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -980,6 +992,8 @@ 35136D491D4277EA00C20EFD /* Sources */ = { isa = PBXGroup; children = ( + 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */, + 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */, 3566C76A1D4A8DFA008152BC /* MGLRasterSource.h */, DAF0D80F1DFE0EA000B28378 /* MGLRasterSource_Private.h */, 3566C76B1D4A8DFA008152BC /* MGLRasterSource.mm */, @@ -1137,6 +1151,7 @@ 40CFA64E1D78754A008103BD /* Sources */ = { isa = PBXGroup; children = ( + 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */, 40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */, 920A3E5C1E6F995200C16EFC /* MGLSourceQueryTests.m */, 4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */, @@ -1671,6 +1686,7 @@ DA8848311CBAFA6200AB86E3 /* NSString+MGLAdditions.h in Headers */, 353933F81D3FB79F003F57D7 /* MGLLineStyleLayer.h in Headers */, DAAF722D1DA903C700312FA4 /* MGLStyleValue_Private.h in Headers */, + 071BBB031EE76146001FB02A /* MGLImageSource.h in Headers */, DA8847F41CBAFA5100AB86E3 /* MGLOfflinePack.h in Headers */, DA88482E1CBAFA6200AB86E3 /* NSException+MGLAdditions.h in Headers */, DA8848551CBAFB9800AB86E3 /* MGLLocationManager.h in Headers */, @@ -1754,6 +1770,7 @@ 3566C7671D4A77BA008152BC /* MGLShapeSource.h in Headers */, DA35A29F1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */, 404C26E31D89B877000AA13D /* MGLTileSource.h in Headers */, + 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */, DABFB8611CBE99E500D62B32 /* MGLMultiPoint.h in Headers */, 3510FFF11D6D9D8C00F413B2 /* NSExpression+MGLAdditions.h in Headers */, 35D3A1E71E9BE7EC002B38EE /* MGLScaleBar.h in Headers */, @@ -1964,7 +1981,6 @@ TargetAttributes = { DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; - DevelopmentTeam = GJZR2MEM28; LastSwiftMigration = 0820; }; DA25D5B81CCD9EDE00607828 = { @@ -2150,6 +2166,7 @@ 35D9DDE21DA25EEC00DAAD69 /* MGLCodingTests.m in Sources */, DA1F8F3D1EBD287B00367E42 /* MGLDocumentationGuideTests.swift in Sources */, 3598544D1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m in Sources */, + 071BBB071EE77631001FB02A /* MGLImageSourceTests.m in Sources */, DA2DBBCE1D51E80400D38FF9 /* MGLStyleLayerTests.m in Sources */, DA35A2C61CCA9F8300E826B2 /* MGLCompassDirectionFormatterTests.m in Sources */, DAE7DEC21E245455007505A6 /* MGLNSStringAdditionsTests.m in Sources */, @@ -2226,6 +2243,7 @@ DD0902A91DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */, 35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, DA35A2CB1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, + 071BBB001EE7613F001FB02A /* MGLImageSource.mm in Sources */, DA8848321CBAFA6200AB86E3 /* NSString+MGLAdditions.m in Sources */, 408AA8581DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */, DA35A2A11CC9E95F00E826B2 /* MGLCoordinateFormatter.m in Sources */, @@ -2307,6 +2325,7 @@ DD0902AA1DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */, DA35A2B41CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, 35D13ABA1D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, + 071BBAFF1EE7613E001FB02A /* MGLImageSource.mm in Sources */, DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, 408AA8591DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */, DAA4E4281CBB730400178DFB /* MGLTypes.m in Sources */, @@ -2629,6 +2648,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -2642,6 +2662,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme index 9dd128ff24..f5aff5b3b4 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/bench.xcscheme @@ -42,7 +42,7 @@ </AdditionalOptions> </TestAction> <LaunchAction - buildConfiguration = "Debug" + buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" 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/MGLMapView.h b/platform/ios/src/MGLMapView.h index 31320ac977..ca765a046b 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -270,13 +270,25 @@ IB_DESIGNABLE */ @property (nonatomic, readonly) UIButton *attributionButton; -@property (nonatomic) NS_ARRAY_OF(NSString *) *styleClasses __attribute__((deprecated("Use style.styleClasses."))); +/** + Support for style classes has been removed. This property always returns an empty array. + */ +@property (nonatomic) NS_ARRAY_OF(NSString *) *styleClasses __attribute__((deprecated("This property is non-functional."))); -- (BOOL)hasStyleClass:(NSString *)styleClass __attribute__((deprecated("Use style.hasStyleClass:."))); +/** + Support for style classes has been removed. This property always returns NO. + */ +- (BOOL)hasStyleClass:(NSString *)styleClass __attribute__((deprecated("This method is non-functional."))); -- (void)addStyleClass:(NSString *)styleClass __attribute__((deprecated("Use style.addStyleClass:."))); +/** + Support for style classes has been removed. This property is a no-op. + */ +- (void)addStyleClass:(NSString *)styleClass __attribute__((deprecated("This method is non-functional."))); -- (void)removeStyleClass:(NSString *)styleClass __attribute__((deprecated("Use style.removeStyleClass:."))); +/** + Support for style classes has been removed. This property is a no-op. + */ +- (void)removeStyleClass:(NSString *)styleClass __attribute__((deprecated("This method is non-functional."))); #pragma mark Displaying the User’s Location @@ -1119,6 +1131,15 @@ IB_DESIGNABLE #pragma mark Overlaying the Map /** + The complete list of overlays associated with the receiver. (read-only) + + The objects in this array must adopt the `MGLOverlay` protocol. If no + overlays are associated with the map view, the value of this property is + empty array. + */ +@property (nonatomic, readonly, nonnull) NS_ARRAY_OF(id <MGLOverlay>) *overlays; + +/** Adds a single overlay object to the map. To remove an overlay from a map, use the `-removeOverlay:` method. diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f3b0d8506a..1444fc3cb0 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -15,6 +15,7 @@ #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/storage/network_status.hpp> +#include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/custom_layer.hpp> @@ -379,7 +380,7 @@ public: - (nonnull NSURL *)styleURL { - NSString *styleURLString = @(_mbglMap->getStyleURL().c_str()).mgl_stringOrNilIfEmpty; + NSString *styleURLString = @(_mbglMap->getStyle().getURL().c_str()).mgl_stringOrNilIfEmpty; NSAssert(styleURLString || _isTargetingInterfaceBuilder, @"Invalid style URL string %@", styleURLString); return styleURLString ? [NSURL URLWithString:styleURLString] : nil; } @@ -395,12 +396,12 @@ public: styleURL = styleURL.mgl_URLByStandardizingScheme; self.style = nil; - _mbglMap->setStyleURL([[styleURL absoluteString] UTF8String]); + _mbglMap->getStyle().loadURL([[styleURL absoluteString] UTF8String]); } - (IBAction)reloadStyle:(__unused id)sender { NSURL *styleURL = self.styleURL; - _mbglMap->setStyleURL(""); + _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; } @@ -444,7 +445,6 @@ public: const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; _mbglThreadPool = mbgl::sharedThreadPool(); _mbglMap = new mbgl::Map(*_mbglView, self.size, scaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default); - [self validateTileCacheSize]; // start paused if in IB if (_isTargetingInterfaceBuilder || background) { @@ -763,42 +763,6 @@ public: #pragma mark - Layout - -- (void)setFrame:(CGRect)frame -{ - [super setFrame:frame]; - if ( ! CGRectEqualToRect(frame, self.frame)) - { - [self validateTileCacheSize]; - } -} - -- (void)setBounds:(CGRect)bounds -{ - [super setBounds:bounds]; - if ( ! CGRectEqualToRect(bounds, self.bounds)) - { - [self validateTileCacheSize]; - } -} - -- (void)validateTileCacheSize -{ - if ( ! _mbglMap) - { - return; - } - - CGFloat zoomFactor = self.maximumZoomLevel - self.minimumZoomLevel + 1; - CGFloat cpuFactor = [NSProcessInfo processInfo].processorCount; - CGFloat memoryFactor = (CGFloat)[NSProcessInfo processInfo].physicalMemory / 1000 / 1000 / 1000; - CGFloat sizeFactor = (CGRectGetWidth(self.bounds) / mbgl::util::tileSize) * - (CGRectGetHeight(self.bounds) / mbgl::util::tileSize); - - NSUInteger cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5; - - _mbglMap->setSourceTileCacheSize(cacheSize); -} - + (BOOL)requiresConstraintBasedLayout { return YES; @@ -2164,10 +2128,10 @@ public: - (void)resetPosition { - CGFloat pitch = _mbglMap->getDefaultPitch(); - CLLocationDirection heading = mbgl::util::wrap(_mbglMap->getDefaultBearing(), 0., 360.); - CLLocationDistance distance = MGLAltitudeForZoomLevel(_mbglMap->getDefaultZoom(), pitch, 0, self.frame.size); - self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(_mbglMap->getDefaultLatLng()) + CGFloat pitch = _mbglMap->getStyle().getDefaultPitch(); + CLLocationDirection heading = mbgl::util::wrap(_mbglMap->getStyle().getDefaultBearing(), 0., 360.); + CLLocationDistance distance = MGLAltitudeForZoomLevel(_mbglMap->getStyle().getDefaultZoom(), pitch, 0, self.frame.size); + self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(_mbglMap->getStyle().getDefaultLatLng()) fromDistance:distance pitch:pitch heading:heading]; @@ -2558,8 +2522,6 @@ public: - (void)setMinimumZoomLevel:(double)minimumZoomLevel { - _mbglMap->setMinZoom(minimumZoomLevel); - [self validateTileCacheSize]; } - (double)minimumZoomLevel @@ -2570,7 +2532,6 @@ public: - (void)setMaximumZoomLevel:(double)maximumZoomLevel { _mbglMap->setMaxZoom(maximumZoomLevel); - [self validateTileCacheSize]; } - (double)maximumZoomLevel @@ -3444,7 +3405,7 @@ public: annotationImage.delegate = self; // add sprite - _mbglMap->addAnnotationImage(iconIdentifier.UTF8String, annotationImage.image.mgl_styleImage); + _mbglMap->addAnnotationImage([annotationImage.image mgl_styleImageWithIdentifier:iconIdentifier]); // Create a slop area with a “radius” equal in size to the annotation // image’s alignment rect, allowing the eventual tap to be on any point @@ -3527,6 +3488,22 @@ public: } } +- (nonnull NS_ARRAY_OF(id <MGLOverlay>) *)overlays +{ + if (self.annotations == nil) { return @[]; } + + NS_MUTABLE_ARRAY_OF(id <MGLOverlay>) *mutableOverlays = [NSMutableArray array]; + + [self.annotations enumerateObjectsUsingBlock:^(id<MGLAnnotation> _Nonnull annotation, NSUInteger idx, BOOL * _Nonnull stop) { + if ([annotation conformsToProtocol:@protocol(MGLOverlay)]) + { + [mutableOverlays addObject:(id<MGLOverlay>)annotation]; + } + }]; + + return [NSArray arrayWithArray:mutableOverlays]; +} + - (void)addOverlay:(id <MGLOverlay>)overlay { [self addOverlays:@[ overlay ]]; @@ -4989,7 +4966,7 @@ public: return; } - self.style = [[MGLStyle alloc] initWithMapView:self]; + self.style = [[MGLStyle alloc] initWithRawStyle:&_mbglMap->getStyle() mapView:self]; if ([self.delegate respondsToSelector:@selector(mapView:didFinishLoadingStyle:)]) { [self.delegate mapView:self didFinishLoadingStyle:self.style]; @@ -5442,7 +5419,7 @@ public: /// context state with the anticipated values. void updateAssumedState() override { assumeFramebufferBinding(ImplicitFramebufferBinding); - assumeViewportSize(nativeView.framebufferSize); + assumeViewport(0, 0, nativeView.framebufferSize); } void bind() override { @@ -5455,7 +5432,7 @@ public: updateAssumedState(); } else { // Our framebuffer is still bound, but the viewport might have changed. - setViewportSize(nativeView.framebufferSize); + setViewport(0, 0, nativeView.framebufferSize); } } diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index 67a26e8ed4..abe16cc3ee 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -52,6 +52,7 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLVectorSource.h" #import "MGLShapeSource.h" #import "MGLRasterSource.h" +#import "MGLImageSource.h" #import "MGLTilePyramidOfflineRegion.h" #import "MGLTypes.h" #import "MGLUserLocation.h" diff --git a/platform/ios/src/UIImage+MGLAdditions.h b/platform/ios/src/UIImage+MGLAdditions.h index 642355d412..6e15e07cb5 100644 --- a/platform/ios/src/UIImage+MGLAdditions.h +++ b/platform/ios/src/UIImage+MGLAdditions.h @@ -8,7 +8,9 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage; -- (std::unique_ptr<mbgl::style::Image>)mgl_styleImage; +- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier; + +- (mbgl::PremultipliedImage)mgl_premultipliedImage; @end diff --git a/platform/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm index db64d78232..5e28d18190 100644 --- a/platform/ios/src/UIImage+MGLAdditions.mm +++ b/platform/ios/src/UIImage+MGLAdditions.mm @@ -6,14 +6,14 @@ - (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage { - CGImageRef image = CGImageFromMGLPremultipliedImage(styleImage->image.clone()); + CGImageRef image = CGImageFromMGLPremultipliedImage(styleImage->getImage().clone()); if (!image) { return nil; } - if (self = [self initWithCGImage:image scale:styleImage->pixelRatio orientation:UIImageOrientationUp]) + if (self = [self initWithCGImage:image scale:styleImage->getPixelRatio() orientation:UIImageOrientationUp]) { - if (styleImage->sdf) + if (styleImage->isSdf()) { self = [self imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } @@ -22,10 +22,14 @@ return self; } -- (std::unique_ptr<mbgl::style::Image>)mgl_styleImage { +- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier { BOOL isTemplate = self.renderingMode == UIImageRenderingModeAlwaysTemplate; - return std::make_unique<mbgl::style::Image>(MGLPremultipliedImageFromCGImage(self.CGImage), + return std::make_unique<mbgl::style::Image>([identifier UTF8String], + self.mgl_premultipliedImage, float(self.scale), isTemplate); } +-(mbgl::PremultipliedImage)mgl_premultipliedImage { + return MGLPremultipliedImageFromCGImage(self.CGImage); +} @end diff --git a/platform/ios/vendor/SMCalloutView b/platform/ios/vendor/SMCalloutView -Subproject 2aede5d8d1577101bf18405246220e7a710df60 +Subproject d6ecaba377c9f963aef630faf86e3b8f8cdb88d |