Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 1f3345c

Browse files
author
Sam Fader
committed
first draft
1 parent abf2b2a commit 1f3345c

File tree

9 files changed

+203
-9
lines changed

9 files changed

+203
-9
lines changed

Examples.xcodeproj/project.pbxproj

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
07F53B851E00D02100B58DB3 /* AnnotationViewsAndImagesExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 07F53B841E00D02100B58DB3 /* AnnotationViewsAndImagesExample.m */; };
4141
1F1F84751E538ABB00332CC3 /* BlockingGesturesDelegateExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F1F84741E538ABB00332CC3 /* BlockingGesturesDelegateExample.m */; };
4242
1F1F84771E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1F84761E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift */; };
43+
2F00FCD121750D5A0028FC69 /* SymbolLayerZOrderExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */; };
44+
2F00FCD3217511760028FC69 /* SymbolLayerZOrderExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */; };
4345
3E085B801EC526C500163C99 /* BuildingsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E085B7F1EC526C500163C99 /* BuildingsExample.swift */; };
4446
3E085B831EC526E500163C99 /* BuildingsExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E085B821EC526E500163C99 /* BuildingsExample.m */; };
4547
3E1806101EAA800A004DB131 /* UserLocationAnnotationExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E18060F1EAA800A004DB131 /* UserLocationAnnotationExample.m */; };
@@ -232,6 +234,9 @@
232234
1F1F84761E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockingGesturesDelegateExample.swift; sourceTree = "<group>"; };
233235
29A0D7C8DCD539DCA5DA1BAC /* Pods-Examples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Examples.release.xcconfig"; path = "Pods/Target Support Files/Pods-Examples/Pods-Examples.release.xcconfig"; sourceTree = "<group>"; };
234236
2ECF27F4ACA1A3CA05DE1954 /* Pods-DocsCode.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DocsCode.release.xcconfig"; path = "Pods/Target Support Files/Pods-DocsCode/Pods-DocsCode.release.xcconfig"; sourceTree = "<group>"; };
237+
2F00FCCF21750D5A0028FC69 /* SymbolLayerZOrderExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SymbolLayerZOrderExample.h; sourceTree = "<group>"; };
238+
2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SymbolLayerZOrderExample.m; sourceTree = "<group>"; };
239+
2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolLayerZOrderExample.swift; sourceTree = "<group>"; };
235240
3E085B7F1EC526C500163C99 /* BuildingsExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BuildingsExample.swift; sourceTree = "<group>"; };
236241
3E085B811EC526E500163C99 /* BuildingsExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuildingsExample.h; sourceTree = "<group>"; };
237242
3E085B821EC526E500163C99 /* BuildingsExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BuildingsExample.m; sourceTree = "<group>"; };
@@ -476,6 +481,7 @@
476481
3EBCD70D1DC28240001E342F /* ImageAnnotationExample.swift */,
477482
3E1806111EAA804B004DB131 /* UserLocationAnnotationExample.swift */,
478483
64BBDB021DF24E0900BB705D /* WebAPIDataExample.swift */,
484+
2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */,
479485
);
480486
name = "Markers and callouts";
481487
sourceTree = "<group>";
@@ -577,6 +583,7 @@
577583
96D431FB1C84B4F7007D09D1 /* ImageAnnotationExample.m */,
578584
3E18060F1EAA800A004DB131 /* UserLocationAnnotationExample.m */,
579585
64BBDAFC1DF24DEB00BB705D /* WebAPIDataExample.m */,
586+
2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */,
580587
);
581588
name = "Markers and callouts";
582589
sourceTree = "<group>";
@@ -864,6 +871,7 @@
864871
968247011C5BDCBB00494AB8 /* StudioClassicStyleExample.h */,
865872
9691AAA11C5AAD8F006A58C6 /* StudioStyleExample.h */,
866873
05536CB3200F9B4900657097 /* SwitchStylesExample.h */,
874+
2F00FCCF21750D5A0028FC69 /* SymbolLayerZOrderExample.h */,
867875
64CF970E1DF224D400C3C27B /* ThirdPartyVectorStyleExample.h */,
868876
3E18060E1EAA800A004DB131 /* UserLocationAnnotationExample.h */,
869877
969E7FDB1D25C31700663F84 /* UserTrackingModesExample.h */,
@@ -1061,7 +1069,7 @@
10611069
};
10621070
9619628B1C581700002D3DAB = {
10631071
CreatedOnToolsVersion = 7.3;
1064-
DevelopmentTeam = GJZR2MEM28;
1072+
DevelopmentTeam = GM7DBR7Y3J;
10651073
LastSwiftMigration = 0900;
10661074
ProvisioningStyle = Automatic;
10671075
};
@@ -1239,7 +1247,7 @@
12391247
files = (
12401248
);
12411249
inputPaths = (
1242-
"${PODS_ROOT}/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh",
1250+
"${SRCROOT}/Pods/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh",
12431251
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
12441252
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
12451253
"${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework",
@@ -1266,7 +1274,7 @@
12661274
);
12671275
runOnlyForDeploymentPostprocessing = 0;
12681276
shellPath = /bin/sh;
1269-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh\"\n";
1277+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh\"\n";
12701278
showEnvVarsInLog = 0;
12711279
};
12721280
B8CEDEEE83C3362F5C012330 /* [CP] Embed Pods Frameworks */ = {
@@ -1275,7 +1283,7 @@
12751283
files = (
12761284
);
12771285
inputPaths = (
1278-
"${PODS_ROOT}/Target Support Files/Pods-Examples/Pods-Examples-frameworks.sh",
1286+
"${SRCROOT}/Pods/Target Support Files/Pods-Examples/Pods-Examples-frameworks.sh",
12791287
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
12801288
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
12811289
);
@@ -1286,7 +1294,7 @@
12861294
);
12871295
runOnlyForDeploymentPostprocessing = 0;
12881296
shellPath = /bin/sh;
1289-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Examples/Pods-Examples-frameworks.sh\"\n";
1297+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Examples/Pods-Examples-frameworks.sh\"\n";
12901298
showEnvVarsInLog = 0;
12911299
};
12921300
D8896F91CDF96A2DF29EF047 /* [CP] Check Pods Manifest.lock */ = {
@@ -1390,6 +1398,7 @@
13901398
3EBCD7221DC28240001E342F /* LineAnnotationGeoJSONExample.swift in Sources */,
13911399
3E085B831EC526E500163C99 /* BuildingsExample.m in Sources */,
13921400
3E9EF27C209CFD460053D1D7 /* HeatmapExample.swift in Sources */,
1401+
2F00FCD3217511760028FC69 /* SymbolLayerZOrderExample.swift in Sources */,
13931402
64BBDAF61DF232FD00BB705D /* SelectFeatureExample.swift in Sources */,
13941403
CA3B162E2098CA7E005C087B /* TestingSupport.m in Sources */,
13951404
64BBDAF81DF2330B00BB705D /* SelectFeatureExample.m in Sources */,
@@ -1436,6 +1445,7 @@
14361445
05FA53A61FE2FA34001F3D7D /* OfflinePackExample.m in Sources */,
14371446
3E22EF521F8821F800605203 /* ImageSourceExample.m in Sources */,
14381447
05FA53A71FE2FA34001F3D7D /* StaticSnapshotExample.m in Sources */,
1448+
2F00FCD121750D5A0028FC69 /* SymbolLayerZOrderExample.m in Sources */,
14391449
3EBCD71C1DC28240001E342F /* CustomCalloutViewExample.swift in Sources */,
14401450
05FA53AD1FE2FBB3001F3D7D /* DefaultCalloutExample.m in Sources */,
14411451
CA39B2C1209B881300D37037 /* AnnotationViewExample+UITesting.m in Sources */,
@@ -1724,16 +1734,18 @@
17241734
CLANG_ENABLE_MODULES = YES;
17251735
CODE_SIGN_IDENTITY = "iPhone Developer";
17261736
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
1737+
CODE_SIGN_STYLE = Automatic;
17271738
CURRENT_PROJECT_VERSION = 0;
1728-
DEVELOPMENT_TEAM = GJZR2MEM28;
1739+
DEVELOPMENT_TEAM = GM7DBR7Y3J;
17291740
FRAMEWORK_SEARCH_PATHS = (
17301741
"$(inherited)",
17311742
"$(PROJECT_DIR)",
17321743
);
17331744
INFOPLIST_FILE = Examples/Info.plist;
17341745
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
1735-
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples;
1746+
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples6;
17361747
PRODUCT_NAME = "$(TARGET_NAME)";
1748+
PROVISIONING_PROFILE_SPECIFIER = "";
17371749
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
17381750
SWIFT_VERSION = 4.0;
17391751
};
@@ -1747,16 +1759,18 @@
17471759
CLANG_ENABLE_MODULES = YES;
17481760
CODE_SIGN_IDENTITY = "iPhone Developer";
17491761
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
1762+
CODE_SIGN_STYLE = Automatic;
17501763
CURRENT_PROJECT_VERSION = 0;
1751-
DEVELOPMENT_TEAM = GJZR2MEM28;
1764+
DEVELOPMENT_TEAM = GM7DBR7Y3J;
17521765
FRAMEWORK_SEARCH_PATHS = (
17531766
"$(inherited)",
17541767
"$(PROJECT_DIR)",
17551768
);
17561769
INFOPLIST_FILE = Examples/Info.plist;
17571770
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
1758-
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples;
1771+
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples6;
17591772
PRODUCT_NAME = "$(TARGET_NAME)";
1773+
PROVISIONING_PROFILE_SPECIFIER = "";
17601774
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
17611775
SWIFT_VERSION = 4.0;
17621776
};

Examples/Examples.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ extern NSString *const MBXExampleStaticSnapshot;
5757
extern NSString *const MBXExampleStudioClassicStyle;
5858
extern NSString *const MBXExampleStudioStyle;
5959
extern NSString *const MBXExampleSwitchStyles;
60+
extern NSString *const MBXExampleSymbolLayerZOrder;
6061
extern NSString *const MBXExampleThirdPartyVectorStyle;
6162
extern NSString *const MBXExampleUserLocationAnnotation;
6263
extern NSString *const MBXExampleUserTrackingModes;

Examples/Examples.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ + (NSArray *)groups {
5353
@{@"className": MBXExamplePolygonAnnotation, @"title": @"Add a polygon annotation"},
5454
@{@"className": MBXExampleLineStyleLayer, @"title": @"Add a line style layer from GeoJSON"},
5555
@{@"className": MBXExampleAnimatedLine, @"title": @"Animate a line"},
56+
@{@"className": MBXExampleSymbolLayerZOrder, @"title": @"Specify z order of features in symbol layer"}
5657
]
5758
},
5859
@{

Examples/Files/clustering.xcassets/marker.imageset/Contents.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
"idiom" : "universal",
55
"filename" : "marker.pdf",
66
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
715
}
816
],
917
"info" : {

Examples/Files/clustering.xcassets/squircle.imageset/Contents.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
"idiom" : "universal",
55
"filename" : "squircle.pdf",
66
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
715
}
816
],
917
"info" : {

Examples/Files/clustering.xcassets/star.imageset/Contents.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
"idiom" : "universal",
55
"filename" : "star.pdf",
66
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
715
}
816
],
917
"info" : {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// SymbolLayerZOrderExample.h
3+
// Examples
4+
//
5+
// Created by Sam Fader on 10/15/18.
6+
// Copyright © 2018 Mapbox. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface SymbolLayerZOrderExample : UIViewController
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//
2+
// SymbolLayerZOrderExample.m
3+
// Examples
4+
//
5+
// Created by Sam Fader on 10/15/18.
6+
// Copyright © 2018 Mapbox. All rights reserved.
7+
//
8+
9+
#import "SymbolLayerZOrderExample.h"
10+
@import Mapbox;
11+
12+
NSString *const MBXExampleSymbolLayerZOrder = @"SymbolLayerZOrderExample";
13+
14+
@interface SymbolLayerZOrderExample () <MGLMapViewDelegate>
15+
16+
@property (nonatomic) MGLMapView *mapView;
17+
18+
@end
19+
20+
@implementation SymbolLayerZOrderExample
21+
22+
- (void)viewDidLoad {
23+
[super viewDidLoad];
24+
25+
// Create a new map view using the Mapbox Light style.
26+
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
27+
styleURL:[MGLStyle lightStyleURL]];
28+
29+
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
30+
self.mapView.tintColor = [UIColor darkGrayColor];
31+
32+
// Set the map’s center coordinate and zoom level.
33+
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(38.897,-77.039);
34+
self.mapView.zoomLevel = 10.5;
35+
36+
self.mapView.delegate = self;
37+
[self.view addSubview: self.mapView];
38+
}
39+
40+
// Wait until the style is loaded before modifying the map style.
41+
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
42+
43+
// "mapbox://examples.2uf7qges" is a map ID referencing a tileset. For more
44+
// more information, see mapbox.com/help/define-map-id/
45+
MGLSource *source = [[MGLVectorTileSource alloc] initWithIdentifier:@"trees" configurationURL:[NSURL URLWithString:@"mapbox://examples.2uf7qges"]];
46+
47+
[self.mapView.style addSource:source];
48+
49+
MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier: @"tree-style" source:source];
50+
51+
// The source name from the source's TileJSON metadata: mapbox.com/api-documentation/#retrieve-tilejson-metadata
52+
layer.sourceLayerIdentifier = @"yoshino-trees-a0puw5";
53+
54+
// Stops based on age of tree in years.
55+
NSDictionary *stops = @{
56+
@0: [UIColor colorWithRed:1.00 green:0.72 blue:0.85 alpha:1.0],
57+
@2: [UIColor colorWithRed:0.69 green:0.48 blue:0.73 alpha:1.0],
58+
@4: [UIColor colorWithRed:0.61 green:0.31 blue:0.47 alpha:1.0],
59+
@7: [UIColor colorWithRed:0.43 green:0.20 blue:0.38 alpha:1.0],
60+
@16: [UIColor colorWithRed:0.33 green:0.17 blue:0.25 alpha:1.0]
61+
};
62+
63+
// Style the circle layer color based on the above stops dictionary.
64+
layer.circleColor = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(AGE, %@, %@)", [UIColor colorWithRed:1.0 green:0.72 blue:0.85 alpha:1.0], stops];
65+
66+
layer.circleRadius = [NSExpression expressionForConstantValue:@3];
67+
68+
[self.mapView.style addLayer:layer];
69+
}
70+
71+
@end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// SymbolLayerZOrderExample.swift
3+
// Examples
4+
//
5+
// Created by Sam Fader on 10/15/18.
6+
// Copyright © 2018 Mapbox. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import Mapbox
11+
12+
@objc(SymbolLayerZOrderExample_Swift)
13+
14+
class SymbolLayerZOrderExample_Swift: UIViewController, MGLMapViewDelegate {
15+
16+
var mapView: MGLMapView!
17+
18+
override func viewDidLoad() {
19+
super.viewDidLoad()
20+
// Create a new map view using the Mapbox Light style.
21+
mapView = MGLMapView(frame: view.bounds)
22+
mapView.styleURL = MGLStyle.lightStyleURL
23+
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
24+
mapView.tintColor = .darkGray
25+
// Set the map’s center coordinate and zoom level.
26+
mapView.setCenter(CLLocationCoordinate2D(latitude: -41.292650, longitude: 174.778768), animated: false)
27+
mapView.zoomLevel = 11.5
28+
mapView.delegate = self
29+
view.addSubview(mapView)
30+
}
31+
32+
// Wait until the style is loaded before modifying the map style.
33+
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
34+
// Add icons to the map's style.
35+
style.setImage(UIImage(named: "oval")!, forName: "oval")
36+
style.setImage(UIImage(named: "squircle")!, forName: "squircle")
37+
style.setImage(UIImage(named: "star")!, forName: "star")
38+
39+
let feature1 = MGLPointFeature()
40+
feature1.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768)
41+
feature1.attributes = ["id": "squircle"]
42+
let feature2 = MGLPointFeature()
43+
feature2.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768)
44+
feature2.attributes = ["id": "oval"]
45+
let feature3 = MGLPointFeature()
46+
feature3.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768)
47+
feature3.attributes = ["id": "star"]
48+
49+
let shapeCollection = MGLShapeCollectionFeature(shapes: [feature1, feature2, feature3])
50+
let source = MGLShapeSource(identifier: "symbol-layer-z-order-example", shape: shapeCollection, options: nil)
51+
style.addSource(source)
52+
let layer = MGLSymbolStyleLayer(identifier: "points-style", source: source)
53+
layer.sourceLayerIdentifier = "symbol-layer-z-order-example"
54+
55+
// Create a stops dictionary with keys that are possible values for 'id', paired with icon images that will represent those features.
56+
let icons = ["squircle": "squircle", "oval": "oval", "star": "star"]
57+
// Use the stops dictionary to assign an icon based on the "POITYPE" for each feature.
58+
layer.iconImageName = NSExpression(format: "FUNCTION(%@, 'valueForKeyPath:', id)", icons)
59+
60+
layer.iconAllowsOverlap = NSExpression(forConstantValue: true)
61+
layer.iconIgnoresPlacement = NSExpression(forConstantValue: true)
62+
layer.symbolZOrder = NSExpression(forConstantValue: "source")
63+
style.addLayer(layer)
64+
}
65+
}

0 commit comments

Comments
 (0)