-
-
Save incanus/2f6dac071f2a744ae8bf55fa35ab454a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m | |
index 42398ff..2f96522 100644 | |
--- a/platform/macos/app/MapDocument.m | |
+++ b/platform/macos/app/MapDocument.m | |
@@ -99,6 +99,37 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio | |
[self.mapView addGestureRecognizer:pressGestureRecognizer]; | |
[self applyPendingState]; | |
+ | |
+ [self performSelector:@selector(addTestShape) withObject:nil afterDelay:1]; | |
+} | |
+ | |
+- (void)addTestShape { | |
+ CLLocationCoordinate2D center = self.mapView.centerCoordinate; | |
+ CLLocationCoordinate2D lineCoordinates[2] = { | |
+ CLLocationCoordinate2DMake(45, -122), | |
+ center | |
+ }; | |
+ MGLPolyline *line = [MGLPolyline polylineWithCoordinates:lineCoordinates count:2]; | |
+ [self.mapView addAnnotation:line]; | |
+} | |
+ | |
+- (void)mapView:(MGLMapView *)mapView cameraDidChangeAnimated:(BOOL)animated { | |
+// update tail coordinate | |
+// CLLocationCoordinate2D center = mapView.centerCoordinate; | |
+// MGLPolyline *line = (MGLPolyline *)mapView.annotations.firstObject; | |
+// CLLocationCoordinate2D *coordinates = malloc(2 * sizeof(CLLocationCoordinate2D)); | |
+// [line getCoordinates:coordinates range:NSMakeRange(0, 2)]; | |
+// coordinates[1] = center; | |
+// [line setCoordinates:coordinates range:NSMakeRange(0, 2)]; | |
+// free(coordinates); | |
+ | |
+ // append coordinate to tail | |
+ CLLocationCoordinate2D center = mapView.centerCoordinate; | |
+ MGLPolyline *line = (MGLPolyline *)mapView.annotations.firstObject; | |
+ CLLocationCoordinate2D *coordinates = malloc(1 * sizeof(CLLocationCoordinate2D)); | |
+ coordinates[0] = center; | |
+ [line setCoordinates:coordinates range:NSMakeRange(line.pointCount, 1)]; | |
+ free(coordinates); | |
} | |
- (NSWindow *)window { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment