summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-07-17 17:43:04 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2018-07-23 11:59:23 -0700
commitbc452b95af578f96ad6e619dd82b366435d00e21 (patch)
treec12864ec5efc6824f480f670353f64c14d17ccc8
parent3545a40183cfda97bcc300d05df6214cd7414b5f (diff)
downloadqtlocation-mapboxgl-bc452b95af578f96ad6e619dd82b366435d00e21.tar.gz
[ios] Improve showsBuildings inspectable.
-rw-r--r--platform/ios/src/MGLMapView+IBAdditions.h2
-rw-r--r--platform/ios/src/MGLMapView.h2
-rw-r--r--platform/ios/src/MGLMapView.mm249
3 files changed, 128 insertions, 125 deletions
diff --git a/platform/ios/src/MGLMapView+IBAdditions.h b/platform/ios/src/MGLMapView+IBAdditions.h
index 6b9d400803..2c18388832 100644
--- a/platform/ios/src/MGLMapView+IBAdditions.h
+++ b/platform/ios/src/MGLMapView+IBAdditions.h
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) IBInspectable BOOL showsHeading;
@property (nonatomic) IBInspectable BOOL showsScale;
@property (nonatomic) IBInspectable BOOL showsBuildings;
-@property (nonatomic) IBInspectable BOOL showsPointOfInterest;
+@property (nonatomic) IBInspectable BOOL showsPointsOfInterest;
@property (nonatomic) IBInspectable BOOL showsTraffic;
@end
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 35f7c05a52..8ca4b306d6 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -445,7 +445,7 @@ MGL_EXPORT IB_DESIGNABLE
The default value of this property is `YES`.
*/
-@property (nonatomic, assign) BOOL showsPointOfInterest;
+@property (nonatomic, assign) BOOL showsPointsOfInterest;
/**
The geographic coordinate that is the subject of observation as the user
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 2323ef9d30..b2165a75a4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -578,7 +578,7 @@ public:
[MGLMapboxEvents pushEvent:MMEEventTypeMapLoad withAttributes:@{}];
}
- _showsPointOfInterest = YES;
+ _showsPointsOfInterest = YES;
_showsTraffic = YES;
}
@@ -2310,126 +2310,6 @@ public:
heading:heading];
}
-- (void)setZoomEnabled:(BOOL)zoomEnabled
-{
- _zoomEnabled = zoomEnabled;
- self.pinch.enabled = zoomEnabled;
- self.doubleTap.enabled = zoomEnabled;
- self.quickZoom.enabled = zoomEnabled;
- self.twoFingerTap.enabled = zoomEnabled;
-}
-
-- (void)setScrollEnabled:(BOOL)scrollEnabled
-{
- _scrollEnabled = scrollEnabled;
- self.pan.enabled = scrollEnabled;
-}
-
-- (void)setRotateEnabled:(BOOL)rotateEnabled
-{
- _rotateEnabled = rotateEnabled;
- self.rotate.enabled = rotateEnabled;
-}
-
-- (void)setPitchEnabled:(BOOL)pitchEnabled
-{
- _pitchEnabled = pitchEnabled;
- self.twoFingerDrag.enabled = pitchEnabled;
-}
-
-- (void)setShowsScale:(BOOL)showsScale
-{
- _showsScale = showsScale;
- self.scaleBar.hidden = !showsScale;
-
- if (showsScale)
- {
- [self updateScaleBar];
- }
-}
-
-- (void)setShowsBuildings:(BOOL)showsBuildings
-{
- if (_showsBuildings == showsBuildings) return;
-
- NSString *layerIdentifier = @"extrudedBuildings";
- if (showsBuildings) {
- MGLSource *source = [self.style sourceWithIdentifier:@"composite"];
- if (source) {
-
- MGLFillExtrusionStyleLayer* layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:layerIdentifier source:source];
- layer.sourceLayerIdentifier = @"building";
- layer.predicate = [NSPredicate predicateWithFormat:@"extrude == 'true' AND CAST(height, 'NSNumber') > 0"];
- layer.fillExtrusionBase = [NSExpression expressionForKeyPath:@"min_height"];
- layer.fillExtrusionHeight = [NSExpression expressionForKeyPath:@"height"];
-
- // Set the fill color to that of the existing building footprint layer, if it exists.
- MGLFillStyleLayer* buildingLayer = (MGLFillStyleLayer*)[self.style layerWithIdentifier:@"building"];
- if (buildingLayer) {
- if (buildingLayer.fillColor) {
- layer.fillExtrusionColor = buildingLayer.fillColor;
- } else {
- layer.fillExtrusionColor = [NSExpression expressionForConstantValue:[UIColor whiteColor]];
- }
-
- layer.fillExtrusionOpacity = [NSExpression expressionForConstantValue:@0.75];
- }
-
- MGLStyleLayer* labelLayer = [self.style layerWithIdentifier:@"waterway-label"];
- if (labelLayer) {
- [self.style insertLayer:layer belowLayer:labelLayer];
- } else {
- [self.style addLayer:layer];
- }
- }
- } else {
- MGLStyleLayer *layer = [self.style layerWithIdentifier:layerIdentifier];
- if (layer) [self.style removeLayer:layer];
- }
- _showsBuildings = showsBuildings;
-}
-
-- (BOOL)showsTraffic {
- NSString *sourceIdentifier = @"mapbox://mapbox.mapbox-traffic-v1";
-
- for (MGLStyleLayer *layer in self.style.layers) {
- if ([layer isKindOfClass:[MGLForegroundStyleLayer class]]) {
- MGLForegroundStyleLayer *trafficLayer = (MGLForegroundStyleLayer *)layer;
- if ([trafficLayer.sourceIdentifier isEqualToString:sourceIdentifier]) {
- _showsTraffic = layer.isVisible;
- return _showsTraffic;
- }
-
- }
- }
- _showsTraffic = NO;
- return _showsTraffic;
-}
-
-- (void)setShowsTraffic:(BOOL)showsTraffic
-{
- _showsTraffic = showsTraffic;
- NSString *sourceIdentifier = @"mapbox://mapbox.mapbox-traffic-v1";
- for (MGLStyleLayer *layer in self.style.layers) {
- if ([layer isKindOfClass:[MGLForegroundStyleLayer class]]) {
- MGLForegroundStyleLayer *trafficLayer = (MGLForegroundStyleLayer *)layer;
- if ([trafficLayer.sourceIdentifier isEqualToString:sourceIdentifier]) {
- [layer setVisible:showsTraffic];
- }
-
- }
- }
-}
-
-- (void)setShowsPointOfInterest:(BOOL)showsPointOfInterest {
- _showsPointOfInterest = showsPointOfInterest;
- for (MGLStyleLayer *layer in self.style.layers) {
- if ([layer.identifier hasPrefix:@"poi"]) {
- [layer setVisible:_showsPointOfInterest];
- }
- }
-}
-
#pragma mark - Accessibility -
- (NSString *)accessibilityValue
@@ -5741,8 +5621,8 @@ public:
}
// POI's are enabled by default, if it is disabled it will force an update.
- if (!_showsPointOfInterest) {
- self.showsPointOfInterest = _showsPointOfInterest;
+ if (!_showsPointsOfInterest) {
+ self.showsPointsOfInterest = _showsPointsOfInterest;
}
if ([self.delegate respondsToSelector:@selector(mapView:didFinishLoadingStyle:)])
@@ -6484,4 +6364,127 @@ private:
self.showsUserHeadingIndicator = showsHeading;
}
+- (void)setZoomEnabled:(BOOL)zoomEnabled
+{
+ _zoomEnabled = zoomEnabled;
+ self.pinch.enabled = zoomEnabled;
+ self.doubleTap.enabled = zoomEnabled;
+ self.quickZoom.enabled = zoomEnabled;
+ self.twoFingerTap.enabled = zoomEnabled;
+}
+
+- (void)setScrollEnabled:(BOOL)scrollEnabled
+{
+ _scrollEnabled = scrollEnabled;
+ self.pan.enabled = scrollEnabled;
+}
+
+- (void)setRotateEnabled:(BOOL)rotateEnabled
+{
+ _rotateEnabled = rotateEnabled;
+ self.rotate.enabled = rotateEnabled;
+}
+
+- (void)setPitchEnabled:(BOOL)pitchEnabled
+{
+ _pitchEnabled = pitchEnabled;
+ self.twoFingerDrag.enabled = pitchEnabled;
+}
+
+- (void)setShowsScale:(BOOL)showsScale
+{
+ _showsScale = showsScale;
+ self.scaleBar.hidden = !showsScale;
+
+ if (showsScale)
+ {
+ [self updateScaleBar];
+ }
+}
+
+- (void)setShowsBuildings:(BOOL)showsBuildings
+{
+ if (_showsBuildings == showsBuildings) return;
+
+ NSString *layerIdentifier = @"extrudedBuildings";
+ MGLFillExtrusionStyleLayer* layer = (MGLFillExtrusionStyleLayer *)[self.style layerWithIdentifier:layerIdentifier];
+ MGLSource *source = [self.style sourceWithIdentifier:@"composite"];
+
+ if (showsBuildings && source) {
+ if (!layer) {
+ layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:layerIdentifier source:source];
+ layer.sourceLayerIdentifier = @"building";
+ layer.predicate = [NSPredicate predicateWithFormat:@"extrude == 'true' AND CAST(height, 'NSNumber') > 0"];
+ layer.fillExtrusionBase = [NSExpression expressionForKeyPath:@"min_height"];
+ layer.fillExtrusionHeight = [NSExpression expressionForKeyPath:@"height"];
+
+ // Set the fill color to that of the existing building footprint layer, if it exists.
+ MGLFillStyleLayer* buildingLayer = (MGLFillStyleLayer*)[self.style layerWithIdentifier:@"building"];
+ if (buildingLayer) {
+ if (buildingLayer.fillColor) {
+ layer.fillExtrusionColor = buildingLayer.fillColor;
+ } else {
+ layer.fillExtrusionColor = [NSExpression expressionForConstantValue:[UIColor whiteColor]];
+ }
+
+ layer.fillExtrusionOpacity = [NSExpression expressionForConstantValue:@0.75];
+ }
+
+ MGLStyleLayer* labelLayer = [self.style layerWithIdentifier:@"waterway-label"];
+ if (labelLayer) {
+ [self.style insertLayer:layer belowLayer:labelLayer];
+ } else {
+ [self.style addLayer:layer];
+ }
+ }
+ layer.visible = YES;
+
+ } else if (!showsBuildings && layer) {
+ layer.visible = NO;
+
+ }
+ _showsBuildings = showsBuildings;
+}
+
+- (BOOL)showsTraffic {
+ NSString *sourceIdentifier = @"mapbox://mapbox.mapbox-traffic-v1";
+
+ for (MGLStyleLayer *layer in self.style.layers) {
+ if ([layer isKindOfClass:[MGLForegroundStyleLayer class]]) {
+ MGLForegroundStyleLayer *trafficLayer = (MGLForegroundStyleLayer *)layer;
+ if ([trafficLayer.sourceIdentifier isEqualToString:sourceIdentifier]) {
+ _showsTraffic = layer.isVisible;
+ return _showsTraffic;
+ }
+
+ }
+ }
+ _showsTraffic = NO;
+ return _showsTraffic;
+}
+
+- (void)setShowsTraffic:(BOOL)showsTraffic
+{
+ _showsTraffic = showsTraffic;
+ NSString *sourceIdentifier = @"mapbox://mapbox.mapbox-traffic-v1";
+ for (MGLStyleLayer *layer in self.style.layers) {
+ if ([layer isKindOfClass:[MGLForegroundStyleLayer class]]) {
+ MGLForegroundStyleLayer *trafficLayer = (MGLForegroundStyleLayer *)layer;
+ if ([trafficLayer.sourceIdentifier isEqualToString:sourceIdentifier]) {
+ [layer setVisible:showsTraffic];
+ }
+
+ }
+ }
+}
+
+- (void)setShowsPointsOfInterest:(BOOL)showsPointsOfInterest {
+ _showsPointsOfInterest = showsPointsOfInterest;
+ for (MGLStyleLayer *layer in self.style.layers) {
+ if ([layer.identifier hasPrefix:@"poi"]) {
+ [layer setVisible:_showsPointsOfInterest];
+ }
+ }
+}
+
@end