diff options
Diffstat (limited to 'platform/ios/app/MBXViewController.m')
-rw-r--r-- | platform/ios/app/MBXViewController.m | 316 |
1 files changed, 203 insertions, 113 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 29c5c65012..4306354030 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -34,7 +34,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsCoreRenderingRows) { MBXSettingsCoreRenderingTimestamps, MBXSettingsCoreRenderingCollisionBoxes, MBXSettingsCoreRenderingOverdrawVisualization, - MBXSettingsCoreRenderingToggleTwoMaps, }; typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) { @@ -48,6 +47,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) { MBXSettingsAnnotationsTestShapes, MBXSettingsAnnotationsCustomCallout, MBXSettingsAnnotationsQueryAnnotations, + MBXSettingsAnnotationsCustomUserDot, MBXSettingsAnnotationsRemoveAnnotations, }; @@ -73,17 +73,19 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) { MBXSettingsRuntimeStylingVectorSource, MBXSettingsRuntimeStylingRasterSource, MBXSettingsRuntimeStylingImageSource, - MBXSettingsRuntimeStylingCountryLabels, MBXSettingsRuntimeStylingRouteLine, MBXSettingsRuntimeStylingDDSPolygon, + MBXSettingsRuntimeStylingCustomLatLonGrid, }; typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { MBXSettingsMiscellaneousShowReuseQueueStats = 0, MBXSettingsMiscellaneousWorldTour, - MBXSettingsMiscellaneousCustomUserDot, MBXSettingsMiscellaneousShowZoomLevel, MBXSettingsMiscellaneousScrollView, + MBXSettingsMiscellaneousToggleTwoMaps, + MBXSettingsMiscellaneousCountryLabels, + MBXSettingsMiscellaneousShowSnapshots, MBXSettingsMiscellaneousPrintLogFile, MBXSettingsMiscellaneousDeleteLogFile, }; @@ -110,11 +112,12 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @interface MBXViewController () <UITableViewDelegate, UITableViewDataSource, - MGLMapViewDelegate> + MGLMapViewDelegate, + MGLComputedShapeSourceDataSource> @property (nonatomic) IBOutlet MGLMapView *mapView; -@property (weak, nonatomic) IBOutlet UILabel *hudLabel; +@property (weak, nonatomic) IBOutlet UIButton *hudLabel; @property (nonatomic) NSInteger styleIndex; @property (nonatomic) BOOL debugLoggingEnabled; @property (nonatomic) BOOL customUserLocationAnnnotationEnabled; @@ -162,7 +165,11 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.debugLoggingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"MGLMapboxMetricsDebugLoggingEnabled"]; self.mapView.scaleBar.hidden = NO; + self.mapView.showsUserHeadingIndicator = YES; self.hudLabel.hidden = YES; + if ([UIFont respondsToSelector:@selector(monospacedDigitSystemFontOfSize:weight:)]) { + self.hudLabel.titleLabel.font = [UIFont monospacedDigitSystemFontOfSize:10 weight:UIFontWeightRegular]; + } if ([MGLAccountManager accessToken].length) { @@ -305,8 +312,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { (debugMask & MGLMapDebugCollisionBoxesMask ? @"Hide" :@"Show")], [NSString stringWithFormat:@"%@ Overdraw Visualization", (debugMask & MGLMapDebugOverdrawVisualizationMask ? @"Hide" :@"Show")], - [NSString stringWithFormat:@"%@ Second Map", - ([self.view viewWithTag:2] == nil ? @"Show" : @"Hide")], ]]; break; case MBXSettingsAnnotations: @@ -321,6 +326,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @"Add Test Shapes", @"Add Point With Custom Callout", @"Query Annotations", + [NSString stringWithFormat:@"%@ Custom User Dot", (_customUserLocationAnnnotationEnabled ? @"Disable" : @"Enable")], @"Remove Annotations", ]]; break; @@ -347,18 +353,20 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @"Style Vector Source", @"Style Raster Source", @"Style Image Source", - [NSString stringWithFormat:@"Label Countries in %@", (_usingLocaleBasedCountryLabels ? @"Local Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])], @"Add Route Line", @"Dynamically Style Polygon", + @"Add Custom Lat/Lon Grid", ]]; break; case MBXSettingsMiscellaneous: [settingsTitles addObjectsFromArray:@[ [NSString stringWithFormat:@"%@ Reuse Queue Stats", (_reuseQueueStatsEnabled ? @"Hide" :@"Show")], @"Start World Tour", - [NSString stringWithFormat:@"%@ Custom User Dot", (_customUserLocationAnnnotationEnabled ? @"Disable" : @"Enable")], - [NSString stringWithFormat:@"%@ Zoom Level", (_showZoomLevelEnabled ? @"Hide" :@"Show")], + [NSString stringWithFormat:@"%@ Zoom/Pitch/Direction Label", (_showZoomLevelEnabled ? @"Hide" :@"Show")], @"Embedded Map View", + [NSString stringWithFormat:@"%@ Second Map", ([self.view viewWithTag:2] == nil ? @"Show" : @"Hide")], + [NSString stringWithFormat:@"Show Labels in %@", (_usingLocaleBasedCountryLabels ? @"Default Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])], + @"Show Snapshots" ]]; if (self.debugLoggingEnabled) @@ -403,81 +411,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsCoreRenderingOverdrawVisualization: self.mapView.debugMask ^= MGLMapDebugOverdrawVisualizationMask; break; - case MBXSettingsCoreRenderingToggleTwoMaps: - if ([self.view viewWithTag:2] == nil) { - MGLMapView *secondMapView = [[MGLMapView alloc] initWithFrame: - CGRectMake(0, self.view.bounds.size.height / 2, - self.view.bounds.size.width, self.view.bounds.size.height / 2)]; - secondMapView.translatesAutoresizingMaskIntoConstraints = false; - secondMapView.tag = 2; - for (NSLayoutConstraint *constraint in self.view.constraints) - { - if ((constraint.firstItem == self.mapView && constraint.firstAttribute == NSLayoutAttributeBottom) || - (constraint.secondItem == self.mapView && constraint.secondAttribute == NSLayoutAttributeBottom)) - { - [self.view removeConstraint:constraint]; - break; - } - } - [self.view addSubview:secondMapView]; - [self.view addConstraints:@[ - [NSLayoutConstraint constraintWithItem:self.mapView - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeCenterY - multiplier:1 - constant:0], - [NSLayoutConstraint constraintWithItem:secondMapView - attribute:NSLayoutAttributeCenterX - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeCenterX - multiplier:1 - constant:0], - [NSLayoutConstraint constraintWithItem:secondMapView - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeWidth - multiplier:1 - constant:0], - [NSLayoutConstraint constraintWithItem:secondMapView - attribute:NSLayoutAttributeTop - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeCenterY - multiplier:1 - constant:0], - [NSLayoutConstraint constraintWithItem:secondMapView - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:self.bottomLayoutGuide - attribute:NSLayoutAttributeTop - multiplier:1 - constant:0], - ]]; - } else { - NSMutableArray *constraintsToRemove = [NSMutableArray array]; - MGLMapView *secondMapView = (MGLMapView *)[self.view viewWithTag:2]; - for (NSLayoutConstraint *constraint in self.view.constraints) - { - if (constraint.firstItem == secondMapView || constraint.secondItem == secondMapView) - { - [constraintsToRemove addObject:constraint]; - } - } - [self.view removeConstraints:constraintsToRemove]; - [secondMapView removeFromSuperview]; - [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.mapView - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:self.bottomLayoutGuide - attribute:NSLayoutAttributeTop - multiplier:1 - constant:0]]; - } - break; default: NSAssert(NO, @"All core rendering setting rows should be implemented"); break; @@ -516,6 +449,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsAnnotationsQueryAnnotations: [self testQueryPointAnnotations]; break; + case MBXSettingsAnnotationsCustomUserDot: + [self toggleCustomUserDot]; + break; case MBXSettingsAnnotationsRemoveAnnotations: [self.mapView removeAnnotations:self.mapView.annotations]; break; @@ -590,15 +526,15 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsRuntimeStylingImageSource: [self styleImageSource]; break; - case MBXSettingsRuntimeStylingCountryLabels: - [self styleCountryLabelsLanguage]; - break; case MBXSettingsRuntimeStylingRouteLine: [self styleRouteLine]; break; case MBXSettingsRuntimeStylingDDSPolygon: [self stylePolygonWithDDS]; break; + case MBXSettingsRuntimeStylingCustomLatLonGrid: + [self addLatLonGrid]; + break; default: NSAssert(NO, @"All runtime styling setting rows should be implemented"); break; @@ -607,12 +543,12 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { case MBXSettingsMiscellaneous: switch (indexPath.row) { + case MBXSettingsMiscellaneousCountryLabels: + [self styleCountryLabelsLanguage]; + break; case MBXSettingsMiscellaneousWorldTour: [self startWorldTour]; break; - case MBXSettingsMiscellaneousCustomUserDot: - [self toggleCustomUserDot]; - break; case MBXSettingsMiscellaneousPrintLogFile: [self printTelemetryLogFile]; break; @@ -624,6 +560,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.reuseQueueStatsEnabled = !self.reuseQueueStatsEnabled; self.hudLabel.hidden = !self.reuseQueueStatsEnabled; self.showZoomLevelEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousShowZoomLevel: @@ -631,6 +568,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.showZoomLevelEnabled = !self.showZoomLevelEnabled; self.hudLabel.hidden = !self.showZoomLevelEnabled; self.reuseQueueStatsEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousScrollView: @@ -640,6 +578,86 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [self.navigationController pushViewController:embeddedMapViewController animated:YES]; break; } + case MBXSettingsMiscellaneousToggleTwoMaps: + if ([self.view viewWithTag:2] == nil) { + MGLMapView *secondMapView = [[MGLMapView alloc] initWithFrame: + CGRectMake(0, self.view.bounds.size.height / 2, + self.view.bounds.size.width, self.view.bounds.size.height / 2)]; + secondMapView.translatesAutoresizingMaskIntoConstraints = false; + secondMapView.tag = 2; + for (NSLayoutConstraint *constraint in self.view.constraints) + { + if ((constraint.firstItem == self.mapView && constraint.firstAttribute == NSLayoutAttributeBottom) || + (constraint.secondItem == self.mapView && constraint.secondAttribute == NSLayoutAttributeBottom)) + { + [self.view removeConstraint:constraint]; + break; + } + } + [self.view addSubview:secondMapView]; + [self.view addConstraints:@[ + [NSLayoutConstraint constraintWithItem:self.mapView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeCenterY + multiplier:1 + constant:0], + [NSLayoutConstraint constraintWithItem:secondMapView + attribute:NSLayoutAttributeCenterX + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeCenterX + multiplier:1 + constant:0], + [NSLayoutConstraint constraintWithItem:secondMapView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeWidth + multiplier:1 + constant:0], + [NSLayoutConstraint constraintWithItem:secondMapView + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeCenterY + multiplier:1 + constant:0], + [NSLayoutConstraint constraintWithItem:secondMapView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.bottomLayoutGuide + attribute:NSLayoutAttributeTop + multiplier:1 + constant:0], + ]]; + } else { + NSMutableArray *constraintsToRemove = [NSMutableArray array]; + MGLMapView *secondMapView = (MGLMapView *)[self.view viewWithTag:2]; + for (NSLayoutConstraint *constraint in self.view.constraints) + { + if (constraint.firstItem == secondMapView || constraint.secondItem == secondMapView) + { + [constraintsToRemove addObject:constraint]; + } + } + [self.view removeConstraints:constraintsToRemove]; + [secondMapView removeFromSuperview]; + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.mapView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.bottomLayoutGuide + attribute:NSLayoutAttributeTop + multiplier:1 + constant:0]]; + } + break; + case MBXSettingsMiscellaneousShowSnapshots: + { + [self performSegueWithIdentifier:@"ShowSnapshots" sender:nil]; + break; + } default: NSAssert(NO, @"All miscellaneous setting rows should be implemented"); break; @@ -817,6 +835,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { } MGLPolygon *polygon = [MGLPolygon polygonWithCoordinates:polygonCoordinates count:[stateCoordinatePairs count]]; + polygon.title = feature[@"properties"][@"NAME"]; [self.mapView addAnnotation:polygon]; @@ -1303,8 +1322,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)styleRasterSource { - NSArray *tileURLTemplates = @[@"https://stamen-tiles.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.jpg"]; - MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"style-raster-source-id" tileURLTemplates:tileURLTemplates options:@{ + NSString *tileURL = [NSString stringWithFormat:@"https://stamen-tiles.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}%@.jpg", UIScreen.mainScreen.nativeScale > 1 ? @"@2x" : @""]; + MGLRasterSource *rasterSource = [[MGLRasterSource alloc] initWithIdentifier:@"style-raster-source-id" tileURLTemplates:@[tileURL] options:@{ MGLTileSourceOptionTileSize: @256, }]; [self.mapView.style addSource:rasterSource]; @@ -1348,12 +1367,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { -(void)styleCountryLabelsLanguage { - NSArray<NSString *> *labelLayers = @[ - @"country-label-lg", - @"country-label-md", - @"country-label-sm", - ]; - [self styleLabelLanguageForLayersNamed:labelLayers]; + _usingLocaleBasedCountryLabels = !_usingLocaleBasedCountryLabels; + self.mapView.style.localizesLabels = _usingLocaleBasedCountryLabels; } - (void)styleRouteLine @@ -1436,6 +1451,21 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [self.mapView.style addLayer:fillStyleLayer]; } +- (void)addLatLonGrid +{ + MGLComputedShapeSource *source = [[MGLComputedShapeSource alloc] initWithIdentifier:@"latlon" + options:@{MGLShapeSourceOptionMaximumZoomLevel:@14}]; + source.dataSource = self; + [self.mapView.style addSource:source]; + MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"latlonlines" + source:source]; + [self.mapView.style addLayer:lineLayer]; + MGLSymbolStyleLayer *labelLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"latlonlabels" + source:source]; + labelLayer.text = [MGLStyleValue valueWithRawValue:@"{value}"]; + [self.mapView.style addLayer:labelLayer]; +} + - (void)styleLabelLanguageForLayersNamed:(NSArray<NSString *> *)layers { _usingLocaleBasedCountryLabels = !_usingLocaleBasedCountryLabels; @@ -1446,8 +1476,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { MGLSymbolStyleLayer *layer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:layerName]; if ([layer isKindOfClass:[MGLSymbolStyleLayer class]]) { - if ([layer.text isKindOfClass:[MGLConstantStyleValue class]]) { - MGLConstantStyleValue *label = (MGLConstantStyleValue<NSString *> *)layer.text; + if ([layer.text isKindOfClass:[MGLStyleConstantValue class]]) { + MGLStyleConstantValue *label = (MGLStyleConstantValue<NSString *> *)layer.text; if ([label.rawValue hasPrefix:@"{name"]) { layer.text = [MGLStyleValue valueWithRawValue:language]; } @@ -1455,7 +1485,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { else if ([layer.text isKindOfClass:[MGLCameraStyleFunction class]]) { MGLCameraStyleFunction *function = (MGLCameraStyleFunction<NSString *> *)layer.text; NSMutableDictionary *stops = function.stops.mutableCopy; - [stops enumerateKeysAndObjectsUsingBlock:^(NSNumber *zoomLevel, MGLConstantStyleValue<NSString *> *stop, BOOL *done) { + [stops enumerateKeysAndObjectsUsingBlock:^(NSNumber *zoomLevel, MGLStyleConstantValue<NSString *> *stop, BOOL *done) { if ([stop.rawValue hasPrefix:@"{name"]) { stops[zoomLevel] = [MGLStyleValue<NSString *> valueWithRawValue:language]; } @@ -1628,8 +1658,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [MGLStyle darkStyleURL], [MGLStyle satelliteStyleURL], [MGLStyle satelliteStreetsStyleURL], - [MGLStyle trafficDayStyleURL], - [MGLStyle trafficNightStyleURL], + [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"], + [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"], + ]; NSAssert(styleNames.count == styleURLs.count, @"Style names and URLs don’t match."); @@ -1686,7 +1717,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [sender setAccessibilityValue:nextAccessibilityValue]; } -#pragma mark - Map Delegate +#pragma mark - MGLMapViewDelegate - (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation { @@ -1904,22 +1935,81 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)mapViewRegionIsChanging:(MGLMapView *)mapView { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation { + [self updateHUD]; +} + +- (void)updateHUD { + if (!self.reuseQueueStatsEnabled && !self.showZoomLevelEnabled) return; + + NSString *hudString; + if (self.reuseQueueStatsEnabled) { NSUInteger queuedAnnotations = 0; - for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) - { + for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) { queuedAnnotations += queue.count; } - self.hudLabel.text = [NSString stringWithFormat:@" Visible: %ld Queued: %ld", (unsigned long)mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; + hudString = [NSString stringWithFormat:@"Visible: %ld Queued: %ld", (unsigned long)self.mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; } else if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; + hudString = [NSString stringWithFormat:@"%.2f ∕ ↕\U0000FE0E%.f° ∕ %.f°", self.mapView.zoomLevel, self.mapView.camera.pitch, self.mapView.direction]; } -} -- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { - if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; + [self.hudLabel setTitle:hudString forState:UIControlStateNormal]; +} + +#pragma mark - MGLComputedShapeSourceDataSource + +- (NSArray<id <MGLFeature>>*)featuresInCoordinateBounds:(MGLCoordinateBounds)bounds zoomLevel:(NSUInteger)zoom { + double gridSpacing; + if(zoom >= 13) { + gridSpacing = 0.01; + } else if(zoom >= 11) { + gridSpacing = 0.05; + } else if(zoom == 10) { + gridSpacing = .1; + } else if(zoom == 9) { + gridSpacing = 0.25; + } else if(zoom == 8) { + gridSpacing = 0.5; + } else if (zoom >= 6) { + gridSpacing = 1; + } else if(zoom == 5) { + gridSpacing = 2; + } else if(zoom >= 4) { + gridSpacing = 5; + } else if(zoom == 2) { + gridSpacing = 10; + } else { + gridSpacing = 20; } + + NSMutableArray <id <MGLFeature>> * features = [NSMutableArray array]; + CLLocationCoordinate2D coords[2]; + + for (double y = ceil(bounds.ne.latitude / gridSpacing) * gridSpacing; y >= floor(bounds.sw.latitude / gridSpacing) * gridSpacing; y -= gridSpacing) { + coords[0] = CLLocationCoordinate2DMake(y, bounds.sw.longitude); + coords[1] = CLLocationCoordinate2DMake(y, bounds.ne.longitude); + MGLPolylineFeature *feature = [MGLPolylineFeature polylineWithCoordinates:coords count:2]; + feature.attributes = @{@"value": @(y)}; + [features addObject:feature]; + } + + for (double x = floor(bounds.sw.longitude / gridSpacing) * gridSpacing; x <= ceil(bounds.ne.longitude / gridSpacing) * gridSpacing; x += gridSpacing) { + coords[0] = CLLocationCoordinate2DMake(bounds.sw.latitude, x); + coords[1] = CLLocationCoordinate2DMake(bounds.ne.latitude, x); + MGLPolylineFeature *feature = [MGLPolylineFeature polylineWithCoordinates:coords count:2]; + feature.attributes = @{@"value": @(x)}; + [features addObject:feature]; + } + + return features; } @end |