public void DrawPolygon(MKPolygon polygon,MKMapRect mapRect, float zoomScale, CGContext context) { CGPath path = this.polyPath (polygon,mapRect,zoomScale,context); if (path != null) { this.ApplyFillProperties (context, zoomScale); context.BeginPath (); context.AddPath (path); // CGContextAddPath(context, path); context.DrawPath (CGPathDrawingMode.EOFill); // CGContextDrawPath(context, kCGPathEOFill); this.ApplyStrokeProperties (context, zoomScale); context.BeginPath (); // CGContextBeginPath(context); context.AddPath (path); // CGContextAddPath(context, path); context.StrokePath (); // CGContextStrokePath(context); } }
public CGPath polyPath(MKPolygon polygon,MKMapRect mapRect, float zoomScale, CGContext context) { MKMapPoint[] points = polygon.Points; Int32 pointCount = polygon.PointCount; Int32 i; if (pointCount < 3) return null; CGPath path = new CGPath (); PointF relativePoint = this.PointForMapPoint (points[0]); path.MoveToPoint (relativePoint.X, relativePoint.Y); for (i = 1; i < pointCount; i++) { relativePoint = this.PointForMapPoint (points[i]); path.AddLineToPoint(relativePoint); //path.CGPathAddLineToPoint (relativePoint.X, relativePoint.Y); } return path; }
/// <summary> /// Initializes a new instance of the <see cref="TreeWatch.iOS.ColorPolygon"/> class. /// DrawOutlines is set to true; /// </summary> /// <param name="polygon">Polygon to extend</param> public ColorPolygon(MKPolygon polygon) { this.Polygon = polygon; this.DrawOutlines = true; }
/// <summary> /// Gets the poly path for a polygon. /// </summary> /// <returns>The path.</returns> /// <param name="polygon">Polygon to get the path for.</param> public CGPath PolyPath(MKPolygon polygon) { var path = new CGPath(); foreach (var item in polygon.InteriorPolygons) { var interiorPath = this.PolyPath(item); path.AddPath(interiorPath); } var relativePoint = PointForMapPoint(polygon.Points[0]); path.MoveToPoint(relativePoint); foreach (var point in polygon.Points) { path.AddLineToPoint(this.PointForMapPoint(point)); } return path; }
protected override void OnDetached() { mapView.DidUpdateUserLocation -= DidUpdateUserLocation; mapView.MapLoaded -= MapView_MapLoaded; // mapView.RemoveGestureRecognizer(tapGesture); // tapGesture.Dispose(); // tapGesture = null; mapView = null; behavior = null; polygon?.Dispose(); polygon = null; polygonRenderer?.Dispose(); polygonRenderer = null; }
private void UpdatePolygon() { if(mapView?.UserLocation?.Coordinate == null) return; if(polygon != null) { mapView.RemoveOverlay(polygon); polygon.Dispose(); } polygon = MKPolygon.FromCoordinates(new[] { mapView.UserLocation.Coordinate, new CLLocationCoordinate2D(mapView.UserLocation.Coordinate.Latitude + 5, mapView.UserLocation.Coordinate.Longitude + 5), new CLLocationCoordinate2D(mapView.UserLocation.Coordinate.Latitude - 5, mapView.UserLocation.Coordinate.Longitude + 3), }); mapView.AddOverlay(polygon); }
public PolygonOverlay(MKPolygon polygon) { _polygon = polygon; }
public void FromPoints_Interior_Empty() { MKPolygon pg = MKPolygon.FromPoints(new MKMapPoint [] { }, new MKPolygon [] { }); CheckEmpty(pg); }
public void FromPoints_Null() { MKPolygon.FromPoints(null); }
public void FromCoordinates_Interior_Empty() { MKPolygon pg = MKPolygon.FromCoordinates(new CLLocationCoordinate2D [] { }, new MKPolygon [] { }); CheckEmpty(pg); }