diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-17 14:39:19 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-17 15:15:55 -0800 |
commit | 110f1ec796ab46e4f16bcf9673f0aa89ae153aeb (patch) | |
tree | bee9af94074a24ec4b3ae757047747b5da1625bf /ios | |
parent | d3c92a8b5cf9a5ac89320c66cf58ff9f84ab28ee (diff) | |
download | qtlocation-mapboxgl-110f1ec796ab46e4f16bcf9673f0aa89ae153aeb.tar.gz |
[ios, android] Add methods to remove a custom layer
Diffstat (limited to 'ios')
-rw-r--r-- | ios/app/MBXViewController.mm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index 31b62ca6d0..21a6a2aeac 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -25,6 +25,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { @implementation MBXViewController { BOOL _isTouringWorld; + BOOL _isShowingCustomStyleLayer; } #pragma mark - Setup @@ -151,7 +152,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { @"Add Test Shapes", @"Start World Tour", @"Remove Annotations", - @"Insert Custom Style Layer", + @"Toggle Custom Style Layer", nil]; [sheet showFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES]; @@ -264,7 +265,14 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10) { - [self insertCustomStyleLayer]; + if (_isShowingCustomStyleLayer) + { + [self removeCustomStyleLayer]; + } + else + { + [self insertCustomStyleLayer]; + } } } @@ -310,6 +318,8 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { - (void)insertCustomStyleLayer { + _isShowingCustomStyleLayer = YES; + static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 1, 0, 1); }"; @@ -361,6 +371,12 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { } belowStyleLayerWithIdentifier:@"housenum-label"]; } +- (void)removeCustomStyleLayer +{ + _isShowingCustomStyleLayer = NO; + [self.mapView removeCustomStyleLayerWithIdentifier:@"mbx-custom"]; +} + - (void)handleLongPress:(UILongPressGestureRecognizer *)longPress { if (longPress.state == UIGestureRecognizerStateBegan) |