diff --git a/Examples.xcodeproj/project.pbxproj b/Examples.xcodeproj/project.pbxproj index 5925a1b7..9e10bd48 100644 --- a/Examples.xcodeproj/project.pbxproj +++ b/Examples.xcodeproj/project.pbxproj @@ -91,8 +91,6 @@ 646B62AE1DEF7155000AA523 /* LineStyleLayerExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 646B62AD1DEF7155000AA523 /* LineStyleLayerExample.swift */; }; 646B62B01DEF7161000AA523 /* AnimatedLineExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 646B62AF1DEF7161000AA523 /* AnimatedLineExample.swift */; }; 64BBDAF01DF22D9600BB705D /* third_party_vector_style.json in Resources */ = {isa = PBXBuildFile; fileRef = 64BBDAEF1DF22D9600BB705D /* third_party_vector_style.json */; }; - 64BBDAF61DF232FD00BB705D /* SelectFeatureExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BBDAF51DF232FD00BB705D /* SelectFeatureExample.swift */; }; - 64BBDAF81DF2330B00BB705D /* SelectFeatureExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 64BBDAF71DF2330B00BB705D /* SelectFeatureExample.m */; }; 64BBDAFD1DF24DEB00BB705D /* WebAPIDataExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 64BBDAFC1DF24DEB00BB705D /* WebAPIDataExample.m */; }; 64BBDB031DF24E0900BB705D /* WebAPIDataExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BBDB021DF24E0900BB705D /* WebAPIDataExample.swift */; }; 64CF97101DF224E400C3C27B /* ThirdPartyVectorStyleExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64CF970F1DF224E400C3C27B /* ThirdPartyVectorStyleExample.swift */; }; @@ -292,9 +290,6 @@ 646B62AF1DEF7161000AA523 /* AnimatedLineExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedLineExample.swift; sourceTree = ""; }; 646B62BB1DEF964A000AA523 /* RuntimeCircleStylesExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RuntimeCircleStylesExample.h; sourceTree = ""; }; 64BBDAEF1DF22D9600BB705D /* third_party_vector_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = third_party_vector_style.json; sourceTree = ""; }; - 64BBDAF51DF232FD00BB705D /* SelectFeatureExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectFeatureExample.swift; sourceTree = ""; }; - 64BBDAF71DF2330B00BB705D /* SelectFeatureExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SelectFeatureExample.m; sourceTree = ""; }; - 64BBDAFA1DF2331600BB705D /* SelectFeatureExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SelectFeatureExample.h; sourceTree = ""; }; 64BBDAFB1DF24DD700BB705D /* WebAPIDataExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAPIDataExample.h; sourceTree = ""; }; 64BBDAFC1DF24DEB00BB705D /* WebAPIDataExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebAPIDataExample.m; sourceTree = ""; }; 64BBDB021DF24E0900BB705D /* WebAPIDataExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebAPIDataExample.swift; sourceTree = ""; }; @@ -518,7 +513,6 @@ 3EBCD70C1DC28240001E342F /* DraggableAnnotationViewExample.swift */, 3E3BFAD81E81D7A300D0BEA1 /* FeatureSelectionExample.swift */, 3EBCD7121DC28240001E342F /* PointConversionExample.swift */, - 64BBDAF51DF232FD00BB705D /* SelectFeatureExample.swift */, 646B62961DEF6DAF000AA523 /* ShowHideLayerExample.swift */, 3EBCD7151DC28240001E342F /* UserTrackingModesExample.swift */, ); @@ -617,7 +611,6 @@ 960A21601D344F9F00BB348B /* DraggableAnnotationViewExample.m */, 3E3BFADB1E81D7BB00D0BEA1 /* FeatureSelectionExample.m */, 96BAED2D1FE304DD00A58BEB /* PointConversionExample.m */, - 64BBDAF71DF2330B00BB705D /* SelectFeatureExample.m */, 646B629B1DEF6DF1000AA523 /* ShowHideLayerExample.m */, 969E7FDC1D25C31700663F84 /* UserTrackingModesExample.m */, ); @@ -835,7 +828,6 @@ 055ABCBF1EFB139C0063BACA /* PolygonPatternExample.h */, 64CF97191DF2252C00C3C27B /* RasterImageryExample.h */, 646B62BB1DEF964A000AA523 /* RuntimeCircleStylesExample.h */, - 64BBDAFA1DF2331600BB705D /* SelectFeatureExample.h */, 646B629E1DEF6DFD000AA523 /* ShowHideLayerExample.h */, 9691AAA51C5AAD8F006A58C6 /* SimpleMapViewExample.h */, 3EA5AA001FAD2E95007073C0 /* StaticSnapshotExample.h */, @@ -1383,10 +1375,8 @@ 05FA539B1FE2FA00001F3D7D /* StudioClassicStyleExample.m in Sources */, 3EBCD7221DC28240001E342F /* LineAnnotationGeoJSONExample.swift in Sources */, 3E9EF27C209CFD460053D1D7 /* HeatmapExample.swift in Sources */, - 64BBDAF61DF232FD00BB705D /* SelectFeatureExample.swift in Sources */, 1F07015C225422B90045E061 /* LabelPlacementExample.swift in Sources */, CA3B162E2098CA7E005C087B /* TestingSupport.m in Sources */, - 64BBDAF81DF2330B00BB705D /* SelectFeatureExample.m in Sources */, 3E3FB66B1F05888E004512C6 /* BuildingLightExample.swift in Sources */, 05FA539A1FE2FA00001F3D7D /* DefaultStylesExample.m in Sources */, 64CF97121DF224F600C3C27B /* RasterImageryExample.swift in Sources */, diff --git a/Examples/Examples.h b/Examples/Examples.h index b8836b50..2a3d61f0 100644 --- a/Examples/Examples.h +++ b/Examples/Examples.h @@ -47,7 +47,6 @@ extern NSString *const MBXExamplePointConversion; extern NSString *const MBXExamplePolygonAnnotation; extern NSString *const MBXExamplePolygonPattern; extern NSString *const MBXExampleRasterImagery; -extern NSString *const MBXExampleSelectFeature; extern NSString *const MBXExampleShowHideLayer; extern NSString *const MBXExampleSimpleMapView; extern NSString *const MBXExampleStaticSnapshot; diff --git a/Examples/Examples.m b/Examples/Examples.m index 6c1be292..ab82530b 100644 --- a/Examples/Examples.m +++ b/Examples/Examples.m @@ -60,7 +60,6 @@ + (NSArray *)groups { @{@"className": MBXExamplePointConversion, @"title": @"Point conversion"}, @{@"className": MBXExampleShowHideLayer, @"title": @"Show and hide a layer"}, @{@"className": MBXExampleFeatureSelection, @"title": @"Select a feature within a layer"}, - @{@"className": MBXExampleSelectFeature, @"title": @"Select a water feature"}, @{@"className": MBXExampleUserTrackingModes, @"title": @"Switch between user tracking modes"}, ] }, diff --git a/Examples/ObjectiveC/Headers/SelectFeatureExample.h b/Examples/ObjectiveC/Headers/SelectFeatureExample.h deleted file mode 100644 index b4415147..00000000 --- a/Examples/ObjectiveC/Headers/SelectFeatureExample.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SelectFeatureExample.h -// Examples -// -// Created by Eric Wolfe on 12/2/16. -// Copyright © 2016 Mapbox. All rights reserved. -// - -#import - -@interface SelectFeatureExample : UIViewController - -@end diff --git a/Examples/ObjectiveC/SelectFeatureExample.m b/Examples/ObjectiveC/SelectFeatureExample.m deleted file mode 100644 index b0890600..00000000 --- a/Examples/ObjectiveC/SelectFeatureExample.m +++ /dev/null @@ -1,72 +0,0 @@ -#import "SelectFeatureExample.h" -@import Mapbox; - -NSString *const MBXExampleSelectFeature = @"SelectFeatureExample"; - -@interface SelectFeatureExample () -@property (nonatomic) MGLMapView *mapView; -@property (nonatomic) MGLShapeSource *selectedFeaturesSource; -@end - -@implementation SelectFeatureExample - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds]; - self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - - [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(45.5076, -122.6736) zoomLevel:11 animated:NO]; - - // Add our own gesture recognizer to handle taps on our custom map features. This gesture requires the built-in MGLMapView tap gestures (such as those for zoom and annotation selection) to fail. - UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMap:)]; - for (UIGestureRecognizer *recognizer in self.mapView.gestureRecognizers) { - if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) { - [singleTap requireGestureRecognizerToFail:recognizer]; - } - } - [self.mapView addGestureRecognizer:singleTap]; - - self.mapView.delegate = self; - - [self.view addSubview:self.mapView]; -} - -- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { - // Create a placeholder MGLShapeSource that will hold copies of any features we’ve selected. - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"selected-features" features:@[] options:nil]; - [style addSource:source]; - - // Keep a reference to the source so we can update it when the map is tapped. - self.selectedFeaturesSource = source; - - // Color any selected features red on the map. - MGLFillStyleLayer *selectedFeaturesLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"selected-features" source:source]; - selectedFeaturesLayer.fillColor = [NSExpression expressionForConstantValue:[UIColor redColor]]; - - [style addLayer:selectedFeaturesLayer]; -} - -- (IBAction)didTapMap:(UITapGestureRecognizer *)recognizer { - if (recognizer.state == UIGestureRecognizerStateEnded) { - // A tap’s center coordinate may not intersect a feature exactly, so let’s make a 44x44 rect that represents a touch and select all features that interesect. - CGRect pointRect = { [recognizer locationInView:recognizer.view], CGSizeZero }; - CGRect touchRect = CGRectInset(pointRect, -22.0, -22.0); - - // Let’s only select water near the rect. There’s a layer within the Mapbox Streets style with "id" = "water". You can see all of the layers used within the default mapbox styles by creating a new style using Mapbox Studio. - NSSet *layerIdentifiers = [NSSet setWithObject:@"water"]; - - // Query the current mapview for any features that intersect our rect. - NSMutableArray *features = [NSMutableArray array]; - for (id f in [self.mapView visibleFeaturesInRect:touchRect inStyleLayersWithIdentifiers:layerIdentifiers]) { - [features addObject:f]; - } - - MGLShapeCollectionFeature *shapes = [MGLShapeCollectionFeature shapeCollectionWithShapes:features]; - - // Update our MGLShapeSource to match our selected features. - self.selectedFeaturesSource.shape = shapes; - } -} - -@end diff --git a/Examples/Swift/SelectFeatureExample.swift b/Examples/Swift/SelectFeatureExample.swift deleted file mode 100644 index 5502401c..00000000 --- a/Examples/Swift/SelectFeatureExample.swift +++ /dev/null @@ -1,61 +0,0 @@ -import Mapbox - -@objc(SelectFeatureExample_Swift) - -class SelectFeatureExample_Swift: UIViewController, MGLMapViewDelegate { - var mapView: MGLMapView! - var selectedFeaturesSource: MGLShapeSource? - - override func viewDidLoad() { - super.viewDidLoad() - - mapView = MGLMapView(frame: view.bounds) - mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - mapView.setCenter(CLLocationCoordinate2D(latitude: 45.5076, longitude: -122.6736), zoomLevel: 11, animated: false) - mapView.delegate = self - view.addSubview(mapView) - - // Add a single tap gesture recognizer. This gesture requires the built-in MGLMapView tap gestures (such as those for zoom and annotation selection) to fail. - let singleTap = UITapGestureRecognizer(target: self, action: #selector(handleMapTap(sender:))) - for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer { - singleTap.require(toFail: recognizer) - } - mapView.addGestureRecognizer(singleTap) - } - - func mapView(_ didFinishLoadingmapView: MGLMapView, didFinishLoading style: MGLStyle) { - // Create a placeholder MGLShapeSource that will hold copies of any features we’ve selected. - let selectedFeaturesSource = MGLShapeSource(identifier: "selected-features", features: [], options: nil) - style.addSource(selectedFeaturesSource) - - // Keep a reference to the source so we can update it when the map is tapped. - self.selectedFeaturesSource = selectedFeaturesSource - - // Color any selected features red on the map. - let selectedFeaturesLayer = MGLFillStyleLayer(identifier: "selected-features", source: selectedFeaturesSource) - selectedFeaturesLayer.fillColor = NSExpression(forConstantValue: UIColor.red) - - style.addLayer(selectedFeaturesLayer) - } - - @objc @IBAction func handleMapTap(sender: UITapGestureRecognizer) throws { - if sender.state == .ended { - // A tap’s center coordinate may not intersect a feature exactly, so let’s make a 44x44 rect that represents a touch and select all features that intersect. - let point = sender.location(in: sender.view!) - let touchRect = CGRect(origin: point, size: .zero).insetBy(dx: -22.0, dy: -22.0) - - // Let’s only select water near the rect. There’s a layer within the Mapbox Streets style with "id" = "water". You can see all of the layers used within the default mapbox styles by creating a new style using Mapbox Studio. - let layerIdentifiers = Set(["water"]) - - // Query the map view for any visible features that intersect our rect. - guard let features = mapView.visibleFeatures(in: touchRect, styleLayerIdentifiers: layerIdentifiers) as? [MGLShape & MGLFeature] else { - fatalError("Could not cast to specified MGLShape/MGLFeature") - } - let shapes = MGLShapeCollectionFeature(shapes: features) - - // Update our MGLShapeSource to match our selected features. - selectedFeaturesSource?.shape = shapes - } - } - -}