public override bool OnVectorTileClicked(VectorTileClickInfo clickInfo) { LocalVectorDataSource source = (LocalVectorDataSource)layer.DataSource; source.Clear(); Color color = new Color(0, 100, 200, 150); Feature feature = clickInfo.Feature; Geometry geometry = feature.Geometry; PointStyleBuilder pointBuilder = new PointStyleBuilder(); pointBuilder.Color = color; LineStyleBuilder lineBuilder = new LineStyleBuilder(); lineBuilder.Color = color; PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder(); polygonBuilder.Color = color; if (geometry is PointGeometry) { source.Add(new Point((PointGeometry)geometry, pointBuilder.BuildStyle())); } else if (geometry is LineGeometry) { source.Add(new Line((LineGeometry)geometry, lineBuilder.BuildStyle())); } else if (geometry is PolygonGeometry) { source.Add(new Polygon((PolygonGeometry)geometry, polygonBuilder.BuildStyle())); } else if (geometry is MultiGeometry) { GeometryCollectionStyleBuilder collectionBuilder = new GeometryCollectionStyleBuilder(); collectionBuilder.PointStyle = pointBuilder.BuildStyle(); collectionBuilder.LineStyle = lineBuilder.BuildStyle(); collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle(); source.Add(new GeometryCollection((MultiGeometry)geometry, collectionBuilder.BuildStyle())); } BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); /// Set a higher placement priority so it would always be visible builder.PlacementPriority = 10; string message = feature.Properties.ToString(); BalloonPopup popup = new BalloonPopup(clickInfo.ClickPos, builder.BuildStyle(), "Click", message); source.Add(popup); return(true); }
// Creates a line from GraphHopper response protected Line CreatePolyline(MapPos start, MapPos end, RoutingResult result) { LineStyleBuilder lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = new Carto.Graphics.Color(Android.Graphics.Color.DarkGray); lineStyleBuilder.Width = 12; return(new Line(result.Points, lineStyleBuilder.BuildStyle())); }
// Creates a line from GraphHopper response protected Line CreatePolyline(MapPos start, MapPos end, RoutingResult result, Color color) { LineStyleBuilder lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = color; lineStyleBuilder.Width = 7; return(new Line(result.Points, lineStyleBuilder.BuildStyle())); }
protected Line CreatePolyline(RoutingResult result, Color color) { LineStyleBuilder builder = new LineStyleBuilder(); builder.Color = color; builder.Width = 10; return(new Line(result.Points, builder.BuildStyle())); }
// creates Nutiteq line from GraphHopper response protected Line createPolyline(MapPos start, MapPos end, RoutingResult result) { LineStyleBuilder lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = new Nutiteq.Graphics.Color(Android.Graphics.Color.DarkGray); lineStyleBuilder.LineJointType = LineJointType.LineJointTypeRound; lineStyleBuilder.StretchFactor = 2; lineStyleBuilder.Width = 12; return(new Line(result.Points, lineStyleBuilder.BuildStyle())); }
public static void AddLine(this LocalVectorDataSource source, MapPosVector positions) { LineStyleBuilder builder = new LineStyleBuilder(); builder.Width = 20; builder.ClickWidth = 40; builder.Color = new Color(255, 0, 0, 255); Line line = new Line(positions, builder.BuildStyle()); source.Add(line); }
public static void Add2DPolygon(LocalVectorDataSource source, Projection projection) { LineStyleBuilder lineBuilder = new LineStyleBuilder(); lineBuilder.Color = new Color(0, 0, 0, 255); // Black lineBuilder.Width = 1.0f; // Create polygon style and poses PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder(); polygonBuilder.Color = new Color(255, 0, 0, 255); // Red polygonBuilder.LineStyle = lineBuilder.BuildStyle(); MapPosVector polygonPoses = new MapPosVector(); polygonPoses.Add(projection.FromWgs84(new MapPos(24.650930, 59.421659))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.657453, 59.416354))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.661187, 59.414607))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.667667, 59.418123))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.665736, 59.421703))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.661444, 59.421245))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.660199, 59.420677))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.656552, 59.420175))); polygonPoses.Add(projection.FromWgs84(new MapPos(24.654010, 59.421472))); // Create 2 polygon holes MapPosVector holePoses1 = new MapPosVector(); holePoses1.Add(projection.FromWgs84(new MapPos(24.658409, 59.420522))); holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.418896))); holePoses1.Add(projection.FromWgs84(new MapPos(24.662207, 59.417411))); holePoses1.Add(projection.FromWgs84(new MapPos(24.659524, 59.417171))); holePoses1.Add(projection.FromWgs84(new MapPos(24.657615, 59.419834))); MapPosVector holePoses2 = new MapPosVector(); holePoses2.Add(projection.FromWgs84(new MapPos(24.665640, 59.421243))); holePoses2.Add(projection.FromWgs84(new MapPos(24.668923, 59.419463))); holePoses2.Add(projection.FromWgs84(new MapPos(24.662893, 59.419365))); MapPosVectorVector polygonHoles = new MapPosVectorVector(); polygonHoles.Add(holePoses1); polygonHoles.Add(holePoses2); // Add polygon Polygon polygon = new Polygon(polygonPoses, polygonHoles, polygonBuilder.BuildStyle()); polygon.SetMetaDataElement("ClickText", new Variant("Polygon")); source.Add(polygon); }
public static void AddOverlyingLines(MapView map, LocalVectorDataSource source, Projection projection) { // Initialize a second vector data source and vector layer // This secondary vector layer will be used for drawing borders for // line elements (by drawing the same line twice, with different widths) // Drawing order withing a layer is currently undefined // Using multiple layers is the only way to guarantee // that point, line and polygon elements are drawn in a specific order LocalVectorDataSource source2 = new LocalVectorDataSource(projection); VectorLayer vectorLayer2 = new VectorLayer(source2); map.Layers.Add(vectorLayer2); vectorLayer2.VisibleZoomRange = new MapRange(10, 24); // Create line style, and line poses LineStyleBuilder lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = new Color(255, 255, 255, 255); // White lineStyleBuilder.Width = 8; MapPosVector linePoses = new MapPosVector(); linePoses.Add(projection.FromWgs84(new MapPos(24.645565, 59.422074))); linePoses.Add(projection.FromWgs84(new MapPos(24.643076, 59.420502))); linePoses.Add(projection.FromWgs84(new MapPos(24.645351, 59.419149))); linePoses.Add(projection.FromWgs84(new MapPos(24.648956, 59.420393))); linePoses.Add(projection.FromWgs84(new MapPos(24.650887, 59.422707))); // Add first line Line line1 = new Line(linePoses, lineStyleBuilder.BuildStyle()); line1.SetMetaDataElement("ClickText", new Variant("Line nr 1")); source2.Add(line1); // Create another line style, use the same lines poses lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = new Color(204, 15, 0, 255); lineStyleBuilder.Width = 12; // Add second line to the second layer. Line line2 = new Line(linePoses, lineStyleBuilder.BuildStyle()); line2.SetMetaDataElement("ClickText", new Variant("Line nr 2")); source.Add(line2); }
public void ShowAt(double latitude, double longitude, float accuracy) { var positiion = projection.FromWgs84(new MapPos(longitude, latitude)); if (focus) { map.FocusPos = positiion; map.Zoom = 16; } var builder = new PolygonStyleBuilder(); // Light transparent apple blue builder.Color = new Carto.Graphics.Color(14, 122, 254, 70); var borderBuilder = new LineStyleBuilder(); // Dark transparent apple blue borderBuilder.Color = new Carto.Graphics.Color(14, 122, 254, 150); borderBuilder.Width = 1; builder.LineStyle = borderBuilder.BuildStyle(); var points = GetCirclePoints(latitude, longitude, accuracy); if (accuracyMarker == null) { var holes = new MapPosVectorVector(); accuracyMarker = new Polygon(points, holes, builder.BuildStyle()); source.Add(accuracyMarker); } else { accuracyMarker.Style = builder.BuildStyle(); accuracyMarker.Geometry = new PolygonGeometry(points); } if (userMarker == null) { var pointBuilder = new PointStyleBuilder(); // Apple blue pointBuilder.Color = new Carto.Graphics.Color(14, 122, 254, 255); pointBuilder.Size = 16.0f; userMarker = new Point(positiion, pointBuilder.BuildStyle()); source.Add(userMarker); } }
// Creates a line from GraphHopper response protected Line CreatePolyline(MapPos start, MapPos end, RoutingResult result, Color darkGray) { LineStyleBuilder lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Color = darkGray; lineStyleBuilder.Width = 12; return new Line(result.Points, lineStyleBuilder.BuildStyle()); }
async public static void AddMapOverlays(IMapView mapView) { // Create overlay layer for markers var dataSource = new LocalVectorDataSource(proj); var overlayLayer = new VectorLayer(dataSource); mapView.Layers.Add(overlayLayer); // Create line style, and line poses var lineStyleBuilder = new LineStyleBuilder(); lineStyleBuilder.Width = 8; var linePoses = new MapPosVector(); // proj.FromWgs84 returns (spherical) Mercator projection linePoses.Add(proj.FromWgs84(new MapPos(0, 0))); linePoses.Add(proj.FromWgs84(new MapPos(0, 80))); linePoses.Add(proj.FromWgs84(new MapPos(45, 45))); var line = new Line(linePoses, lineStyleBuilder.BuildStyle()); dataSource.Add(line); // Create balloon popup var balloonPopupStyleBuilder = new BalloonPopupStyleBuilder(); balloonPopupStyleBuilder.CornerRadius = 3; balloonPopupStyleBuilder.TitleFontName = "Helvetica"; balloonPopupStyleBuilder.TitleFontSize = 55; balloonPopupStyleBuilder.TitleColor = new Color(200, 0, 0, 255); balloonPopupStyleBuilder.StrokeColor = new Color(200, 120, 0, 255); balloonPopupStyleBuilder.StrokeWidth = 1; balloonPopupStyleBuilder.PlacementPriority = 1; var popup = new BalloonPopup( proj.FromWgs84(new MapPos(0, 20)), balloonPopupStyleBuilder.BuildStyle(), "Title", "Description"); dataSource.Add(popup); // Load NML file model from a file BinaryData modelFile = AssetUtils.LoadAsset("fcd_auto.nml"); // set location for model, and create NMLModel object with this var modelPos = proj.FromWgs84(new MapPos(24.646469, 59.423939)); var model = new NMLModel(modelPos, modelFile); mapView.FocusPos = modelPos; mapView.Zoom = 15; // Oversize it 20*, just to make it more visible (optional) model.Scale = 20; // Add metadata for click handling (optional) model.SetMetaDataElement("ClickText", new Variant("Single model")); // Add it to normal datasource dataSource.Add(model); // Create and set map listener mapView.MapEventListener = new MapListener(dataSource); await AnimateModel(model); }
public static void ShowResult(this LocalVectorDataSource source, MapView map, GeocodingResult result, string title, string description, bool goToPosition) { source.Clear(); var builder = new BalloonPopupStyleBuilder(); builder.LeftMargins = new BalloonPopupMargins(0, 0, 0, 0); builder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3); builder.CornerRadius = 5; // Make sure this label is shown on top of all other labels builder.PlacementPriority = 10; FeatureCollection collection = result.FeatureCollection; int count = collection.FeatureCount; MapPos position = new MapPos(); Geometry geometry; for (int i = 0; i < count; i++) { geometry = collection.GetFeature(i).Geometry; var color = new Carto.Graphics.Color(0, 100, 200, 150); var pointBuilder = new PointStyleBuilder(); pointBuilder.Color = color; var lineBuilder = new LineStyleBuilder(); lineBuilder.Color = color; var polygonBuilder = new PolygonStyleBuilder(); polygonBuilder.Color = color; VectorElement element = null; if (geometry is PointGeometry) { element = new Point(geometry as PointGeometry, pointBuilder.BuildStyle()); } else if (geometry is LineGeometry) { element = new Line(geometry as LineGeometry, lineBuilder.BuildStyle()); } else if (geometry is PolygonGeometry) { element = new Polygon(geometry as PolygonGeometry, polygonBuilder.BuildStyle()); } else if (geometry is MultiGeometry) { var collectionBuilder = new GeometryCollectionStyleBuilder(); collectionBuilder.PointStyle = pointBuilder.BuildStyle(); collectionBuilder.LineStyle = lineBuilder.BuildStyle(); collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle(); element = new GeometryCollection(geometry as MultiGeometry, collectionBuilder.BuildStyle()); } if (element != null) { position = geometry.CenterPos; source.Add(element); } } if (goToPosition) { map.SetFocusPos(position, 1.0f); map.SetZoom(16, 1.0f); } var popup = new BalloonPopup(position, builder.BuildStyle(), title, description); source.Add(popup); }
public override bool OnVectorTileClicked(Carto.Ui.VectorTileClickInfo clickInfo) { source.Clear(); Color color = new Color(0, 100, 200, 150); Feature feature = clickInfo.Feature; Geometry geometry = feature.Geometry; PointStyleBuilder pointBuilder = new PointStyleBuilder(); pointBuilder.Color = color; LineStyleBuilder lineBuilder = new LineStyleBuilder(); lineBuilder.Color = color; PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder(); polygonBuilder.Color = color; if (geometry is PointGeometry) { source.Add(new Point((PointGeometry)geometry, pointBuilder.BuildStyle())); } else if (geometry is LineGeometry) { source.Add(new Line((LineGeometry)geometry, lineBuilder.BuildStyle())); } else if (geometry is PolygonGeometry) { source.Add(new Polygon((PolygonGeometry)geometry, polygonBuilder.BuildStyle())); } else if (geometry is MultiGeometry) { GeometryCollectionStyleBuilder collectionBuilder = new GeometryCollectionStyleBuilder(); collectionBuilder.PointStyle = pointBuilder.BuildStyle(); collectionBuilder.LineStyle = lineBuilder.BuildStyle(); collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle(); source.Add(new GeometryCollection((MultiGeometry)geometry, collectionBuilder.BuildStyle())); } BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); // Set a higher placement priority so it would always be visible builder.PlacementPriority = 10; string id = clickInfo.FeatureId.ToString(); string name = "Info (id: " + id + ")"; if (feature.Properties.GetObjectElement("name").String != "null") { name += " about " + feature.Properties.GetObjectElement("name").String; } string description = feature.Properties.ToString(); BalloonPopup popup = new BalloonPopup(clickInfo.ClickPos, builder.BuildStyle(), name, description); source.Add(popup); return(true); }
public override bool OnVectorTileClicked(VectorTileClickInfo clickInfo) { LocalVectorDataSource source = (LocalVectorDataSource)layer.DataSource; source.Clear(); Color color = new Color(0, 100, 200, 150); Feature feature = clickInfo.Feature; Geometry geometry = feature.Geometry; PointStyleBuilder pointBuilder = new PointStyleBuilder(); pointBuilder.Color = color; LineStyleBuilder lineBuilder = new LineStyleBuilder(); lineBuilder.Color = color; PolygonStyleBuilder polygonBuilder = new PolygonStyleBuilder(); polygonBuilder.Color = color; if (geometry is PointGeometry) { source.Add(new Point((PointGeometry)geometry, pointBuilder.BuildStyle())); } else if (geometry is LineGeometry) { source.Add(new Line((LineGeometry)geometry, lineBuilder.BuildStyle())); } else if (geometry is PolygonGeometry) { source.Add(new Polygon((PolygonGeometry)geometry, polygonBuilder.BuildStyle())); } else if (geometry is MultiGeometry) { GeometryCollectionStyleBuilder collectionBuilder = new GeometryCollectionStyleBuilder(); collectionBuilder.PointStyle = pointBuilder.BuildStyle(); collectionBuilder.LineStyle = lineBuilder.BuildStyle(); collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle(); source.Add(new GeometryCollection((MultiGeometry)geometry, collectionBuilder.BuildStyle())); } BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); // Set a higher placement priority so it would always be visible builder.PlacementPriority = 10; string id = clickInfo.FeatureId.ToString(); string message = "(Id: " + id + ") "; string name = feature.Properties.GetObjectElement("name").String; string description = feature.Properties.GetObjectElement("description").String.ToMax200Characters(); if (name.Equals("null")) { string facility = feature.Properties.GetObjectElement("facility").String; if (!facility.Equals("null")) { message += facility; } else { message += feature.Properties.ToString(); } } else { message += name; if (!description.Equals("null")) { message += "\n" + description; } } BalloonPopup popup = new BalloonPopup(clickInfo.ClickPos, builder.BuildStyle(), "", message); source.Add(popup); if (IsForce) { Console.WriteLine("Force touch"); return(false); } Console.WriteLine("Non-force"); return(true); }