Skip to content

Commit

Permalink
#152 A desperate request for addPolylines in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Aug 3, 2017
1 parent 6bebf98 commit dbd2655
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/mapbox.ios.ts
Expand Up @@ -375,7 +375,23 @@ export class Mapbox extends MapboxCommon implements MapboxApi {

addPolyline(options: AddPolylineOptions, nativeMap?): Promise<any> {
return new Promise((resolve, reject) => {
reject("not implemented for iOS");
let theMap: MGLMapView = nativeMap || _mapbox.mapView;
const points = options.points;
if (points === undefined) {
reject("Please set the 'points' parameter");
return;
}

// TODO this is not sufficient
for (let p in points) {
let point = points[p];
const coord = CLLocationCoordinate2DMake(point.lat, point.lng);
const coordRef = new interop.Reference<CLLocationCoordinate2D>(coord);
const polyline = MGLPolyline.polylineWithCoordinatesCount(coordRef, 1);
theMap.addAnnotation(polyline);
}

resolve();
});
}

Expand Down

0 comments on commit dbd2655

Please sign in to comment.