diff --git a/Examples.xcodeproj/project.pbxproj b/Examples.xcodeproj/project.pbxproj index ee0f9bed..6800c998 100644 --- a/Examples.xcodeproj/project.pbxproj +++ b/Examples.xcodeproj/project.pbxproj @@ -80,6 +80,10 @@ 3EC92DB71E78C431001D0503 /* metro-line.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 3EC92DB61E78C431001D0503 /* metro-line.geojson */; }; 3ED403411E006B5200230C95 /* CameraFlyToExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ED403401E006B5200230C95 /* CameraFlyToExample.swift */; }; 3ED403481E006BE800230C95 /* CameraFlyToExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ED403471E006BE800230C95 /* CameraFlyToExample.m */; }; + 58AC6B9C23478646002665E1 /* mapbox_access_token in Resources */ = {isa = PBXBuildFile; fileRef = 58AC6B9B23478646002665E1 /* mapbox_access_token */; }; + 58AC6B9E23478BA6002665E1 /* FilterMapSymbolsExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 58AC6B9D23478BA6002665E1 /* FilterMapSymbolsExample.m */; }; + 58AC6BA023478D81002665E1 /* FilterMapSymbolsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58AC6B9F23478D81002665E1 /* FilterMapSymbolsExample.swift */; }; + 58AC6BE82347D47B002665E1 /* iOS.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 58AC6BE72347D47B002665E1 /* iOS.geojson */; }; 60E0DCA0CEED683C3A4F18F2 /* Pods_Examples.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9EC12D8F1A97963D68BFA871 /* Pods_Examples.framework */; }; 646B62971DEF6DAF000AA523 /* ShowHideLayerExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 646B62961DEF6DAF000AA523 /* ShowHideLayerExample.swift */; }; 646B629C1DEF6DF1000AA523 /* ShowHideLayerExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 646B629B1DEF6DF1000AA523 /* ShowHideLayerExample.m */; }; @@ -270,6 +274,11 @@ 3ED403471E006BE800230C95 /* CameraFlyToExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraFlyToExample.m; sourceTree = ""; }; 532FB53EE0142E4DAC3FB49B /* Pods-Shared-Examples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-Examples.release.xcconfig"; path = "Pods/Target Support Files/Pods-Shared-Examples/Pods-Shared-Examples.release.xcconfig"; sourceTree = ""; }; 589ABF8859560819F8B431C7 /* Pods-ExamplesTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExamplesTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExamplesTests/Pods-ExamplesTests.debug.xcconfig"; sourceTree = ""; }; + 58AC6B9B23478646002665E1 /* mapbox_access_token */ = {isa = PBXFileReference; lastKnownFileType = text; path = mapbox_access_token; sourceTree = ""; }; + 58AC6B9D23478BA6002665E1 /* FilterMapSymbolsExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FilterMapSymbolsExample.m; sourceTree = ""; }; + 58AC6B9F23478D81002665E1 /* FilterMapSymbolsExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterMapSymbolsExample.swift; sourceTree = ""; }; + 58AC6BE62347D38A002665E1 /* FilterMapSymbols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FilterMapSymbols.h; sourceTree = ""; }; + 58AC6BE72347D47B002665E1 /* iOS.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = iOS.geojson; sourceTree = ""; }; 646B62961DEF6DAF000AA523 /* ShowHideLayerExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowHideLayerExample.swift; sourceTree = ""; }; 646B629B1DEF6DF1000AA523 /* ShowHideLayerExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShowHideLayerExample.m; sourceTree = ""; }; 646B629E1DEF6DFD000AA523 /* ShowHideLayerExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShowHideLayerExample.h; sourceTree = ""; }; @@ -315,7 +324,6 @@ 962B450D1D1C8520007B7454 /* AnnotationViewExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnnotationViewExample.h; sourceTree = ""; }; 962B450E1D1C8520007B7454 /* AnnotationViewExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnnotationViewExample.m; sourceTree = ""; }; 9637341B2139B30A00BE4B39 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = SOURCE_ROOT; }; - 964CB5171E445AE1004549EA /* mapbox_access_token */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mapbox_access_token; sourceTree = SOURCE_ROOT; }; 968247011C5BDCBB00494AB8 /* StudioClassicStyleExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StudioClassicStyleExample.h; sourceTree = ""; }; 968247111C5C0F0F00494AB8 /* DefaultCalloutExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultCalloutExample.h; sourceTree = ""; }; 968247251C5C1DC700494AB8 /* CameraAnimationExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraAnimationExample.h; sourceTree = ""; }; @@ -492,6 +500,7 @@ 3EBCD7121DC28240001E342F /* PointConversionExample.swift */, 646B62961DEF6DAF000AA523 /* ShowHideLayerExample.swift */, 3EBCD7151DC28240001E342F /* UserTrackingModesExample.swift */, + 58AC6B9F23478D81002665E1 /* FilterMapSymbolsExample.swift */, ); name = "User interaction"; sourceTree = ""; @@ -586,6 +595,7 @@ 96BAED2D1FE304DD00A58BEB /* PointConversionExample.m */, 646B629B1DEF6DF1000AA523 /* ShowHideLayerExample.m */, 969E7FDC1D25C31700663F84 /* UserTrackingModesExample.m */, + 58AC6B9D23478BA6002665E1 /* FilterMapSymbolsExample.m */, ); name = "User interaction"; sourceTree = ""; @@ -676,6 +686,7 @@ 961962831C581700002D3DAB = { isa = PBXGroup; children = ( + 58AC6B9B23478646002665E1 /* mapbox_access_token */, 9619628E1C581700002D3DAB /* Examples */, 961962A81C581700002D3DAB /* ExamplesTests */, 961962B31C581700002D3DAB /* ExamplesUITests */, @@ -727,7 +738,6 @@ 9637341B2139B30A00BE4B39 /* .swiftlint.yml */, 9691AAAA1C5AB546006A58C6 /* Examples-Bridging-Header.h */, 961962901C581700002D3DAB /* main.m */, - 964CB5171E445AE1004549EA /* mapbox_access_token */, ); name = "Supporting Files"; sourceTree = ""; @@ -753,6 +763,7 @@ 9682471B1C5C123B00494AB8 /* Files */ = { isa = PBXGroup; children = ( + 58AC6BE72347D47B002665E1 /* iOS.geojson */, DD5939E51E6778480009BEB2 /* clustering.xcassets */, 3EC92DB61E78C431001D0503 /* metro-line.geojson */, 3E25C5DE2056E7E2005B031E /* nps-icons.xcassets */, @@ -810,6 +821,7 @@ 3E18060E1EAA800A004DB131 /* UserLocationAnnotationExample.h */, 969E7FDB1D25C31700663F84 /* UserTrackingModesExample.h */, 64BBDAFB1DF24DD700BB705D /* WebAPIDataExample.h */, + 58AC6BE62347D38A002665E1 /* FilterMapSymbols.h */, ); path = Headers; sourceTree = ""; @@ -1080,6 +1092,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 58AC6BE82347D47B002665E1 /* iOS.geojson in Resources */, 3E25C5DF2056E7E2005B031E /* nps-icons.xcassets in Resources */, 3E4574ED1FA3D8F1000C8CF1 /* radar.gif in Resources */, 1F0701632255789D0045E061 /* missing_icon.json in Resources */, @@ -1087,6 +1100,7 @@ 3EC92DB71E78C431001D0503 /* metro-line.geojson in Resources */, 9619629F1C581700002D3DAB /* LaunchScreen.storyboard in Resources */, DD5939E61E6778480009BEB2 /* clustering.xcassets in Resources */, + 58AC6B9C23478646002665E1 /* mapbox_access_token in Resources */, 9619629C1C581700002D3DAB /* Assets.xcassets in Resources */, 1F07016522557B0B0045E061 /* icons.xcassets in Resources */, 075AFB7823393DBA0091FF0A /* example.geojson in Resources */, @@ -1357,6 +1371,7 @@ 3E52ACD31EE8D8AF0056242C /* LiveDataExample.m in Sources */, 3EA5AA041FAD2EC7007073C0 /* StaticSnapshotExample.swift in Sources */, 05FA53A91FE2FB46001F3D7D /* CustomCalloutView.m in Sources */, + 58AC6BA023478D81002665E1 /* FilterMapSymbolsExample.swift in Sources */, 05FA53A31FE2FA1E001F3D7D /* LineStyleLayerExample.m in Sources */, 3E44BA55203B54120072DE4B /* MultipleImagesExample.swift in Sources */, 3E1806101EAA800A004DB131 /* UserLocationAnnotationExample.m in Sources */, @@ -1384,6 +1399,7 @@ DDF943291E5DE63300545D0F /* ClusteringExample.m in Sources */, 3E44BA58203B54260072DE4B /* MultipleImagesExample.m in Sources */, 3EBCD7171DC28240001E342F /* DefaultCalloutExample.swift in Sources */, + 58AC6B9E23478BA6002665E1 /* FilterMapSymbolsExample.m in Sources */, 64BBDAFD1DF24DEB00BB705D /* WebAPIDataExample.m in Sources */, 055ABCC31EFB14AE0063BACA /* PolygonPatternExample.swift in Sources */, 646B62AE1DEF7155000AA523 /* LineStyleLayerExample.swift in Sources */, diff --git a/Examples/Examples.h b/Examples/Examples.h index fdad2058..39c7edcc 100644 --- a/Examples/Examples.h +++ b/Examples/Examples.h @@ -31,6 +31,7 @@ extern NSString *const MBXExampleDefaultCallout; extern NSString *const MBXExampleDefaultStyles; extern NSString *const MBXExampleDraggableAnnotationView; extern NSString *const MBXExampleFeatureSelection; +extern NSString *const MBXExampleFilterMapSymbols; extern NSString *const MBXExampleFormattingExpression; extern NSString *const MBXExampleHeatmap; extern NSString *const MBXExampleImageSource; diff --git a/Examples/Examples.m b/Examples/Examples.m index c25de13d..75505f22 100644 --- a/Examples/Examples.m +++ b/Examples/Examples.m @@ -58,6 +58,7 @@ + (NSArray *)groups { @{@"className": MBXExampleShowHideLayer, @"title": @"Show and hide a layer"}, @{@"className": MBXExampleFeatureSelection, @"title": @"Select a feature within a layer"}, @{@"className": MBXExampleUserTrackingModes, @"title": @"Switch between user tracking modes"}, + @{@"className": MBXExampleFilterMapSymbols, @"title": @"Filter locations marked by symbols on a map"}, ] }, @{ diff --git a/Examples/Files/iOS.geojson b/Examples/Files/iOS.geojson new file mode 100644 index 00000000..0777d0d7 --- /dev/null +++ b/Examples/Files/iOS.geojson @@ -0,0 +1,67 @@ +{ + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "properties": { + "icon": "theatre" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.038659, 38.931567] + } + }, { + "type": "Feature", + "properties": { + "icon": "theatre" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.003168, 38.894651] + } + }, { + "type": "Feature", + "properties": { + "icon": "bar" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.090372, 38.881189] + } + }, { + "type": "Feature", + "properties": { + "icon": "bicycle" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.052477, 38.943951] + } + }, { + "type": "Feature", + "properties": { + "icon": "music" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.031706, 38.914581] + } + }, { + "type": "Feature", + "properties": { + "icon": "music" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.020945, 38.878241] + } + }, { + "type": "Feature", + "properties": { + "icon": "music" + }, + "geometry": { + "type": "Point", + "coordinates": [-77.007481, 38.876516] + } + }] +} diff --git a/Examples/ObjectiveC/FilterMapSymbolsExample.m b/Examples/ObjectiveC/FilterMapSymbolsExample.m new file mode 100644 index 00000000..2ebbf349 --- /dev/null +++ b/Examples/ObjectiveC/FilterMapSymbolsExample.m @@ -0,0 +1,112 @@ + +#import "FilterMapSymbols.h" + +NSString *const MBXExampleFilterMapSymbols = @"FilterMapSymbolsExample"; + +@import Mapbox; +@interface FilterMapSymbolsExample () + +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic) MGLSymbolStyleLayer *symbolLayer; +@property (nonatomic) MGLStyle *style; + + +@end + + +@implementation FilterMapSymbolsExample + +- (void)viewDidLoad { +[super viewDidLoad]; + + self.mapView = [[MGLMapView alloc] initWithFrame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; + self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + + // Set the map's initial style, center coordinate, and zoom level + self.mapView.styleURL = [NSURL URLWithString:@"mapbox://styles/zizim/ck12h05if04ha1co4qr1ra9l2"]; + [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(38.897435, -77.039679) + zoomLevel:11 + animated:NO]; + _mapView.delegate = self; + [self.view addSubview:self.mapView]; + + [self toggleSet]; + +} + +-(void)toggleSet { + // Create a UISegmentedControl to toggle between map styles + UISegmentedControl *styleToggle =[[UISegmentedControl alloc] initWithItems:@[@"theatre", @"bar", @"music", @"biking"]]; + styleToggle.translatesAutoresizingMaskIntoConstraints = NO; + styleToggle.tintColor = [UIColor colorWithRed:0.976 green:0.843 blue:0.831 alpha:1]; + styleToggle.backgroundColor = [UIColor colorWithRed:0.09 green:0.568 blue:0.514 alpha:0.56]; + styleToggle.layer.cornerRadius = 4; + styleToggle.clipsToBounds = YES; + [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]; +} + + +- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { + + NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"iOS" ofType:@"geojson"]]; + + + MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"icons" URL:url options:@{}]; + [style addSource:source]; + + self.symbolLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"icons" source:source]; + +// Create a stops dictionary with keys that are possible values for 'POITYPE', paired with icon images that will represent those features. + NSDictionary *stops = @{ +@"theatre": [NSExpression expressionForConstantValue:@"theatre-15"], + @"bar": [NSExpression expressionForConstantValue:@"alcohol-shop-15"], + @"music": [NSExpression expressionForConstantValue:@"music-15"], + @"bicycle":[NSExpression expressionForConstantValue:@"bicycle-15"] + }; + +// Use the stops dictionary to assign an icon based on the "icon" for each feature. + self.symbolLayer.iconImageName = [NSExpression expressionWithFormat:@"FUNCTION(%@, 'valueForKeyPath:', icon)", stops]; + + NSLog(@"%@", stops); + + +[style addLayer:_symbolLayer]; +} + +// Change the map style based on the selected index of the UISegmentedControl +- (void)changeStyle:(UISegmentedControl *)sender { +switch(sender.selectedSegmentIndex){ + case 0: + NSLog(@"%@", @"ummm"); + + self.symbolLayer.iconImageName = [NSExpression expressionForConstantValue:@"theatre-15"]; + self.symbolLayer.predicate = [NSPredicate predicateWithFormat:@"icon = 'theatre'"]; + + break; + case 1: + _symbolLayer.iconImageName =[NSExpression expressionForConstantValue:@"alcohol-shop-15"]; + _symbolLayer.predicate = [NSPredicate predicateWithFormat:@"icon = 'bar'"]; + break; + case 2: + _symbolLayer.iconImageName = [NSExpression expressionForConstantValue:@"music-15"]; + _symbolLayer.predicate =[NSPredicate predicateWithFormat:@"icon = 'music'"]; + break; + case 3: + _symbolLayer.iconImageName = [NSExpression expressionForConstantValue:@"bicycle-15"]; + _symbolLayer.predicate =[NSPredicate predicateWithFormat:@"icon = 'bicycle'"]; + break; + } +} + + +@end diff --git a/Examples/ObjectiveC/Headers/FilterMapSymbols.h b/Examples/ObjectiveC/Headers/FilterMapSymbols.h new file mode 100644 index 00000000..75e54441 --- /dev/null +++ b/Examples/ObjectiveC/Headers/FilterMapSymbols.h @@ -0,0 +1,14 @@ +// +// FilterMapSymbols.h +// Examples +// +// Created by ZiZi Miles on 10/4/19. +// Copyright © 2019 Mapbox. All rights reserved. +// + +#import + +@interface FilterMapSymbolsExample : UIViewController + + +@end diff --git a/Examples/Swift/FilterMapSymbolsExample.swift b/Examples/Swift/FilterMapSymbolsExample.swift new file mode 100644 index 00000000..f76d1a39 --- /dev/null +++ b/Examples/Swift/FilterMapSymbolsExample.swift @@ -0,0 +1,134 @@ +import Mapbox +import UIKit + +@objc(FilterMapSymbolsExample_Swift) + + +class ViewController: UIViewController, MGLMapViewDelegate { + + + var mapView: MGLMapView! + var feature : MGLShapeCollectionFeature! + var style : MGLStyle! + var symbolLayer : MGLSymbolStyleLayer! + + + override func viewDidLoad() { + super.viewDidLoad() + + mapView = MGLMapView(frame: view.bounds) + mapView.styleURL = URL(string: "mapbox://styles/zizim/ck12h05if04ha1co4qr1ra9l2") + mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + mapView.tintColor = .darkGray + mapView.setCenter(CLLocationCoordinate2D(latitude: 38.897435, longitude: -77.039679), zoomLevel: 11, animated: false) + + mapView.delegate = self + view.addSubview(mapView) + + toggleSet() + + } + + func toggleSet() { + + // Create a UISegmentedControl to toggle between map icons + let styleToggle = UISegmentedControl(items: ["theatre", "bar", "music", "biking"]) + + styleToggle.translatesAutoresizingMaskIntoConstraints = false + styleToggle.tintColor = UIColor(red: 0.976, green: 0.843, blue: 0.831, alpha: 1) + styleToggle.backgroundColor = UIColor(red: 0.09, green: 0.568, blue: 0.514, alpha: 0.56) + styleToggle.layer.cornerRadius = 4 + styleToggle.clipsToBounds = true +// styleToggle.selectedSegmentIndex = 0 + + view.insertSubview(styleToggle, aboveSubview: mapView) + styleToggle.addTarget(self, action: #selector(changeIcon(sender:)), for: .valueChanged) + + // Configure autolayout constraints for the UISegmentedControl to align + // at the bottom of the map view and above the Mapbox logo and attribution + NSLayoutConstraint.activate([NSLayoutConstraint(item: styleToggle, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: mapView, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1.0, constant: 0.0)]) + NSLayoutConstraint.activate([NSLayoutConstraint(item: styleToggle, attribute: .bottom, relatedBy: .equal, toItem: mapView.logoView, attribute: .top, multiplier: 1, constant: -10)]) + + } + + + func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) { + + // Parse the GeoJSON data. + DispatchQueue.global().async { + guard let url = Bundle.main.url(forResource: "iOS", withExtension: "geojson") else { + preconditionFailure("Failed to load local GeoJSON file") + } + + guard let data = try? Data(contentsOf: url) else { + preconditionFailure("Failed to decode GeoJSON file") + } + + DispatchQueue.main.async { + try? self.drawShapeCollection(data: data) + + } + + } + } + + func drawShapeCollection(data: Data) throws { + style = self.mapView.style + + // Use [MGLShape shapeWithData:encoding:error:] to create a MGLShapeCollectionFeature from GeoJSON data. + guard let feature = try? MGLShape(data: data, encoding: String.Encoding.utf8.rawValue) as? MGLShapeCollectionFeature else { + fatalError("Could not cast to specified MGLShapeCollectionFeature") + } + + // Create source and add it to the map style. + let source = MGLShapeSource(identifier: "places", shape: feature, options: nil) + style.addSource(source) + + +// //add each icon to the map + symbolLayer = MGLSymbolStyleLayer(identifier: "icons", source: source) + + let stops = [ + "theatre": NSExpression(forConstantValue: "theatre-15"), + "bar": NSExpression(forConstantValue: "alcohol-shop-15"), + "music": NSExpression(forConstantValue: "music-15"), + "bicycle": NSExpression(forConstantValue: "bicycle-15") + + ] + + symbolLayer.iconImageName = NSExpression(format: "FUNCTION(%@, 'valueForKeyPath:', icon)", stops) + print("okay ...\(stops)") + + style.addLayer(symbolLayer) + + } + + + + + // Change the map style based on the selected index of the UISegmentedControl + @objc func changeIcon(sender: UISegmentedControl) { + if symbolLayer != nil { + switch sender.selectedSegmentIndex { + case 0: + symbolLayer.iconImageName = NSExpression(forConstantValue: "theatre-15") + symbolLayer.predicate = NSPredicate(format: "icon = 'theatre'") + case 1: + symbolLayer.iconImageName = NSExpression(forConstantValue: "alcohol-shop-15") + symbolLayer.predicate = NSPredicate(format: "icon = 'bar'") + case 2: + symbolLayer.iconImageName = NSExpression(forConstantValue: "music-15") + symbolLayer.predicate = NSPredicate(format: "icon = 'music'") + case 3: + symbolLayer.iconImageName = NSExpression(forConstantValue: "bicycle-15") + symbolLayer.predicate = NSPredicate(format: "icon = 'bicycle'") + default: + symbolLayer.iconImageName = NSExpression(forConstantValue: "circle-15") + + } + + } + +} + +} diff --git a/mapbox_access_token.rtf b/mapbox_access_token.rtf new file mode 100644 index 00000000..7fc4ff50 --- /dev/null +++ b/mapbox_access_token.rtf @@ -0,0 +1,8 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf600 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +{\*\expandedcolortbl;;} +\margl1440\margr1440\vieww9000\viewh8400\viewkind0 +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 + +\f0\fs24 \cf0 pk.eyJ1Ijoieml6aW0iLCJhIjoiY2p5cmhpMXo1MGFvMjNkbGdlNW12N2ZuZyJ9.b11jHGzZRKWg-Xy84389uw} \ No newline at end of file diff --git a/mapbox_access_token.strings b/mapbox_access_token.strings new file mode 100644 index 00000000..0da8b274 --- /dev/null +++ b/mapbox_access_token.strings @@ -0,0 +1,7 @@ +/* + mapbox_access_token.strings + Examples + + Created by ZiZi Miles on 10/4/19. + Copyright © 2019 Mapbox. All rights reserved. +*/