public static MGLShape ToShape(this GeoJSON.Net.IGeoJSONObject geoJSONObject) { if (geoJSONObject == null) { return(null); } var json = JsonConvert.SerializeObject(geoJSONObject); var data = NSData.FromString(json); var shape = MGLShape.ShapeWithData(data, (int)NSStringEncoding.UTF8, out var error); // TODO Handle error if (error != null) { return(null); } return(shape); }
void DrawPolyline() { var jsonPath = NSBundle.MainBundle.PathForResource("example", "geojson"); NSData data = NSFileManager.DefaultManager.Contents(jsonPath); NSError err; MGLShapeCollectionFeature shapeCollectionFeature = (MGLShapeCollectionFeature)MGLShape.ShapeWithData(data, (uint)NSStringEncoding.UTF8, out err); MGLPolylineFeature polyline = (MGLPolylineFeature)shapeCollectionFeature.Shapes.First(); mapView.AddAnnotation(polyline); }