Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
05FA53A91FE2FB46001F3D7D /* CustomCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FA53A81FE2FB46001F3D7D /* CustomCalloutView.m */; };
05FA53AB1FE2FB9C001F3D7D /* CustomCalloutViewExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FA53AA1FE2FB9B001F3D7D /* CustomCalloutViewExample.m */; };
05FA53AD1FE2FBB3001F3D7D /* DefaultCalloutExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 05FA53AC1FE2FBB2001F3D7D /* DefaultCalloutExample.m */; };
072BC2A121AF5D0D0056F4AE /* symbol-z-order.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 072BC2A021AF5D0D0056F4AE /* symbol-z-order.xcassets */; };
079E77C51E1C4E2100F92FA8 /* camera.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 079E77C41E1C4E2100F92FA8 /* camera.xcassets */; };
07C138C01E6F646F00D6F678 /* MultipleShapesExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 07C138BF1E6F646F00D6F678 /* MultipleShapesExample.m */; };
07C138C21E6F65D000D6F678 /* MultipleShapesExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07C138C11E6F65D000D6F678 /* MultipleShapesExample.swift */; };
Expand All @@ -40,6 +41,8 @@
07F53B851E00D02100B58DB3 /* AnnotationViewsAndImagesExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 07F53B841E00D02100B58DB3 /* AnnotationViewsAndImagesExample.m */; };
1F1F84751E538ABB00332CC3 /* BlockingGesturesDelegateExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F1F84741E538ABB00332CC3 /* BlockingGesturesDelegateExample.m */; };
1F1F84771E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1F84761E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift */; };
2F00FCD121750D5A0028FC69 /* SymbolLayerZOrderExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */; };
2F00FCD3217511760028FC69 /* SymbolLayerZOrderExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */; };
3E085B801EC526C500163C99 /* BuildingsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E085B7F1EC526C500163C99 /* BuildingsExample.swift */; };
3E085B831EC526E500163C99 /* BuildingsExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E085B821EC526E500163C99 /* BuildingsExample.m */; };
3E1806101EAA800A004DB131 /* UserLocationAnnotationExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E18060F1EAA800A004DB131 /* UserLocationAnnotationExample.m */; };
Expand Down Expand Up @@ -216,6 +219,7 @@
05FA53A81FE2FB46001F3D7D /* CustomCalloutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomCalloutView.m; sourceTree = "<group>"; };
05FA53AA1FE2FB9B001F3D7D /* CustomCalloutViewExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomCalloutViewExample.m; sourceTree = "<group>"; };
05FA53AC1FE2FBB2001F3D7D /* DefaultCalloutExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultCalloutExample.m; sourceTree = "<group>"; };
072BC2A021AF5D0D0056F4AE /* symbol-z-order.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "symbol-z-order.xcassets"; sourceTree = "<group>"; };
079E77C41E1C4E2100F92FA8 /* camera.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = camera.xcassets; sourceTree = "<group>"; };
07C138BE1E6F646F00D6F678 /* MultipleShapesExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MultipleShapesExample.h; sourceTree = "<group>"; };
07C138BF1E6F646F00D6F678 /* MultipleShapesExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MultipleShapesExample.m; sourceTree = "<group>"; };
Expand All @@ -232,6 +236,9 @@
1F1F84761E53A3B700332CC3 /* BlockingGesturesDelegateExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockingGesturesDelegateExample.swift; sourceTree = "<group>"; };
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>"; };
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>"; };
2F00FCCF21750D5A0028FC69 /* SymbolLayerZOrderExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SymbolLayerZOrderExample.h; sourceTree = "<group>"; };
2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SymbolLayerZOrderExample.m; sourceTree = "<group>"; };
2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolLayerZOrderExample.swift; sourceTree = "<group>"; };
3E085B7F1EC526C500163C99 /* BuildingsExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BuildingsExample.swift; sourceTree = "<group>"; };
3E085B811EC526E500163C99 /* BuildingsExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuildingsExample.h; sourceTree = "<group>"; };
3E085B821EC526E500163C99 /* BuildingsExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BuildingsExample.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -476,6 +483,7 @@
3EBCD70D1DC28240001E342F /* ImageAnnotationExample.swift */,
3E1806111EAA804B004DB131 /* UserLocationAnnotationExample.swift */,
64BBDB021DF24E0900BB705D /* WebAPIDataExample.swift */,
2F00FCD2217511760028FC69 /* SymbolLayerZOrderExample.swift */,
);
name = "Markers and callouts";
sourceTree = "<group>";
Expand Down Expand Up @@ -577,6 +585,7 @@
96D431FB1C84B4F7007D09D1 /* ImageAnnotationExample.m */,
3E18060F1EAA800A004DB131 /* UserLocationAnnotationExample.m */,
64BBDAFC1DF24DEB00BB705D /* WebAPIDataExample.m */,
2F00FCD021750D5A0028FC69 /* SymbolLayerZOrderExample.m */,
);
name = "Markers and callouts";
sourceTree = "<group>";
Expand Down Expand Up @@ -811,6 +820,7 @@
3EC92DB61E78C431001D0503 /* metro-line.geojson */,
3E25C5DE2056E7E2005B031E /* nps-icons.xcassets */,
96D432051C84B9CF007D09D1 /* pisavector.xcassets */,
072BC2A021AF5D0D0056F4AE /* symbol-z-order.xcassets */,
DDF9432A1E5DEACC00545D0F /* ports.geojson */,
3E4574EC1FA3D8F1000C8CF1 /* radar.gif */,
64BBDAEF1DF22D9600BB705D /* third_party_vector_style.json */,
Expand Down Expand Up @@ -864,6 +874,7 @@
968247011C5BDCBB00494AB8 /* StudioClassicStyleExample.h */,
9691AAA11C5AAD8F006A58C6 /* StudioStyleExample.h */,
05536CB3200F9B4900657097 /* SwitchStylesExample.h */,
2F00FCCF21750D5A0028FC69 /* SymbolLayerZOrderExample.h */,
64CF970E1DF224D400C3C27B /* ThirdPartyVectorStyleExample.h */,
3E18060E1EAA800A004DB131 /* UserLocationAnnotationExample.h */,
969E7FDB1D25C31700663F84 /* UserTrackingModesExample.h */,
Expand Down Expand Up @@ -1127,6 +1138,7 @@
3EC92DB71E78C431001D0503 /* metro-line.geojson in Resources */,
9619629F1C581700002D3DAB /* LaunchScreen.storyboard in Resources */,
DD5939E61E6778480009BEB2 /* clustering.xcassets in Resources */,
072BC2A121AF5D0D0056F4AE /* symbol-z-order.xcassets in Resources */,
079E77C51E1C4E2100F92FA8 /* camera.xcassets in Resources */,
9619629C1C581700002D3DAB /* Assets.xcassets in Resources */,
9682471D1C5C123B00494AB8 /* example.geojson in Resources */,
Expand Down Expand Up @@ -1390,6 +1402,7 @@
3EBCD7221DC28240001E342F /* LineAnnotationGeoJSONExample.swift in Sources */,
3E085B831EC526E500163C99 /* BuildingsExample.m in Sources */,
3E9EF27C209CFD460053D1D7 /* HeatmapExample.swift in Sources */,
2F00FCD3217511760028FC69 /* SymbolLayerZOrderExample.swift in Sources */,
64BBDAF61DF232FD00BB705D /* SelectFeatureExample.swift in Sources */,
CA3B162E2098CA7E005C087B /* TestingSupport.m in Sources */,
64BBDAF81DF2330B00BB705D /* SelectFeatureExample.m in Sources */,
Expand Down Expand Up @@ -1436,6 +1449,7 @@
05FA53A61FE2FA34001F3D7D /* OfflinePackExample.m in Sources */,
3E22EF521F8821F800605203 /* ImageSourceExample.m in Sources */,
05FA53A71FE2FA34001F3D7D /* StaticSnapshotExample.m in Sources */,
2F00FCD121750D5A0028FC69 /* SymbolLayerZOrderExample.m in Sources */,
3EBCD71C1DC28240001E342F /* CustomCalloutViewExample.swift in Sources */,
05FA53AD1FE2FBB3001F3D7D /* DefaultCalloutExample.m in Sources */,
CA39B2C1209B881300D37037 /* AnnotationViewExample+UITesting.m in Sources */,
Expand Down Expand Up @@ -1724,6 +1738,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = GJZR2MEM28;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -1734,6 +1749,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
SWIFT_VERSION = 4.0;
};
Expand All @@ -1747,6 +1763,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = GJZR2MEM28;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -1757,6 +1774,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.examples;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Examples/Examples-Bridging-Header.h";
SWIFT_VERSION = 4.0;
};
Expand Down
1 change: 1 addition & 0 deletions Examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern NSString *const MBXExampleStaticSnapshot;
extern NSString *const MBXExampleStudioClassicStyle;
extern NSString *const MBXExampleStudioStyle;
extern NSString *const MBXExampleSwitchStyles;
extern NSString *const MBXExampleSymbolLayerZOrder;
extern NSString *const MBXExampleThirdPartyVectorStyle;
extern NSString *const MBXExampleUserLocationAnnotation;
extern NSString *const MBXExampleUserTrackingModes;
Expand Down
1 change: 1 addition & 0 deletions Examples/Examples.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ + (NSArray *)groups {
@{@"className": MBXExamplePolygonAnnotation, @"title": @"Add a polygon annotation"},
@{@"className": MBXExampleLineStyleLayer, @"title": @"Add a line style layer from GeoJSON"},
@{@"className": MBXExampleAnimatedLine, @"title": @"Animate a line"},
@{@"className": MBXExampleSymbolLayerZOrder, @"title": @"Specify z order of features in a symbol layer"}
]
},
@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"idiom" : "universal",
"filename" : "marker.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"idiom" : "universal",
"filename" : "squircle.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"idiom" : "universal",
"filename" : "star.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
Expand Down
6 changes: 6 additions & 0 deletions Examples/Files/symbol-z-order.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "green-triangle.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "purple-triangle.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "yellow-triangle-image.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Examples/ObjectiveC/Headers/SymbolLayerZOrderExample.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface SymbolLayerZOrderExample : UIViewController

@end

NS_ASSUME_NONNULL_END
107 changes: 107 additions & 0 deletions Examples/ObjectiveC/SymbolLayerZOrderExample.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#import "SymbolLayerZOrderExample.h"
@import Mapbox;

NSString *const MBXExampleSymbolLayerZOrder = @"SymbolLayerZOrderExample";

@interface SymbolLayerZOrderExample () <MGLMapViewDelegate>

@property (nonatomic) MGLMapView *mapView;
@property (nonatomic) MGLSymbolStyleLayer *layer;

@end

@implementation SymbolLayerZOrderExample

- (void)viewDidLoad {
[super viewDidLoad];

// Create a new map view using the Mapbox Light style.
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
styleURL:[MGLStyle lightStyleURL]];

self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.tintColor = [UIColor darkGrayColor];

// Set the map’s center coordinate and zoom level.
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(-41.292650,174.778768);
self.mapView.zoomLevel = 11.5;

self.mapView.delegate = self;
[self.view addSubview: self.mapView];
}

// Wait until the style is loaded before modifying the map style.
- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {

// Add icons to the map's style.
// Note that adding icons to the map's style does not mean they have
// been added to the map yet.
[style setImage:([UIImage imageNamed:@"yellow-triangle-image"]) forName:@"yellow-triangle"];
[style setImage:([UIImage imageNamed:@"green-triangle-image"]) forName:@"green-triangle"];
[style setImage:([UIImage imageNamed:@"purple-triangle-image"]) forName:@"purple-triangle"];

MGLPointFeature *yellow = [MGLPointFeature alloc];
yellow.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768);
yellow.attributes = @{@"id": @"yellow-triangle"};

MGLPointFeature *green = [MGLPointFeature alloc];
green.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768);
green.attributes = @{@"id": @"green-triangle"};

MGLPointFeature *purple = [MGLPointFeature alloc];
purple.coordinate = CLLocationCoordinate2DMake(-41.292650, 174.778768);
purple.attributes = @{@"id": @"purple-triangle"};

MGLShapeCollectionFeature *shapeCollection = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[yellow, green, purple]];
MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"symbol-layer-z-order-example" shape:shapeCollection options:nil];

[style addSource:source];
self.layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"points-style" source:source];
self.layer.sourceLayerIdentifier = @"symbol-layer-z-order-example";
// Create a stops dictionary with keys that are possible values for 'id', paired with icon images that will represent those features.
NSDictionary *icons = @{
@"yellow-triangle": @"yellow-triangle",
@"green-triangle": @"green-triangle",
@"purple-triangle": @"purple-triangle"};
// Use the stops dictionary to assign an icon based on the "POITYPE" for each feature.
self.layer.iconImageName = [NSExpression expressionWithFormat:@"FUNCTION(%@, 'valueForKeyPath:', id)", icons];
self.layer.iconAllowsOverlap = [NSExpression expressionForConstantValue:@(YES)];
self.layer.symbolZOrder = [NSExpression expressionForConstantValue:@"source"];
[style addLayer:self.layer];

[self addToggleButton];
}

- (void)addToggleButton {
UISegmentedControl *styleToggle =[[UISegmentedControl alloc] initWithItems:@[@"viewport-y", @"source"]];
styleToggle.translatesAutoresizingMaskIntoConstraints = NO;
styleToggle.backgroundColor = [UIColor colorWithRed:0.83 green:0.84 blue:0.95 alpha:1.0];
styleToggle.tintColor = [UIColor colorWithRed:0.26 green:0.39 blue:0.98 alpha:1.0];
styleToggle.layer.cornerRadius = 4;
styleToggle.clipsToBounds = YES;
styleToggle.selectedSegmentIndex = 1;
[self.view insertSubview:styleToggle aboveSubview:self.mapView];
[styleToggle addTarget:self action:@selector(changeStyle:) forControlEvents:UIControlEventValueChanged];

// Configure autolayout constraints for the UISegmentedControl to align
// at the bottom of the map view and above the Mapbox logo and attribution
NSMutableArray *constraints = [NSMutableArray array];

[constraints addObject:[NSLayoutConstraint constraintWithItem:styleToggle attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.mapView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:1.0]];
[constraints addObject:[NSLayoutConstraint constraintWithItem:styleToggle attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.mapView.logoView attribute:NSLayoutAttributeTop multiplier:1 constant:-20]];

[self.view addConstraints:constraints];
}

// Change the map style based on the selected index of the UISegmentedControl
- (void)changeStyle:(UISegmentedControl *)sender {
switch(sender.selectedSegmentIndex){
case 0:
self.layer.symbolZOrder = [NSExpression expressionForConstantValue:@"viewport-y"];
break;
case 1:
self.layer.symbolZOrder = [NSExpression expressionForConstantValue:@"source"];;
break;
}
}
@end
Loading