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().ToMax300Characters(); BalloonPopup popup = new BalloonPopup(clickInfo.ClickPos, builder.BuildStyle(), "", message); source.Add(popup); return(true); }
public override void OnMapClicked(MapClickInfo mapClickInfo) { // Add default marker to the click location var styleBuilder = new MarkerStyleBuilder(); styleBuilder.Size = 10; var marker = new Marker(mapClickInfo.ClickPos, styleBuilder.BuildStyle()); _dataSource.Add(marker); }
public void SetSourcesAndElements(Bitmap olmarker, Bitmap up, Bitmap upleft, Bitmap upright, Color green, Color red, Color white) { // Define layer and datasource for route line and instructions routeDataSource = new LocalVectorDataSource(BaseProjection); VectorLayer routeLayer = new VectorLayer(routeDataSource); MapView.Layers.Add(routeLayer); // Define layer and datasource for route start and stop markers routeStartStopDataSource = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer vectorLayer = new VectorLayer(routeStartStopDataSource); // Add the previous vector layer to the map MapView.Layers.Add(vectorLayer); // Set visible zoom range for the vector layer vectorLayer.VisibleZoomRange = new MapRange(0, 22); // Create markers for start & end and a layer for them MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder(); markerBuilder.Bitmap = olmarker; markerBuilder.HideIfOverlapped = false; markerBuilder.Size = 30; markerBuilder.Color = green; startMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); startMarker.Visible = false; markerBuilder.Color = red; stopMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); stopMarker.Visible = false; routeStartStopDataSource.Add(startMarker); routeStartStopDataSource.Add(stopMarker); markerBuilder.Color = white; markerBuilder.Bitmap = up; instructionUp = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upleft; instructionLeft = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upright; instructionRight = markerBuilder.BuildStyle(); // Style for instruction balloons balloonBuilder = new BalloonPopupStyleBuilder(); balloonBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4); }
public void SetSourcesAndElements(Bitmap olmarker, Bitmap up, Bitmap upleft, Bitmap upright, Color green, Color red, Color white) { // Define layer and datasource for route line routeDataSource = new LocalVectorDataSource(Projection); routeLayer = new VectorLayer(routeDataSource); MapView.Layers.Add(routeLayer); // Define layer and datasource for route instructions routeInstructionSource = new LocalVectorDataSource(Projection); routeInstructionLayer = new VectorLayer(routeInstructionSource); MapView.Layers.Add(routeInstructionLayer); // Define layer and datasource for route start and stop markers routeStartStopDataSource = new LocalVectorDataSource(Projection); // Initialize a vector layer with the previous data source startStopLayer = new VectorLayer(routeStartStopDataSource); // Add the previous vector layer to the map MapView.Layers.Add(startStopLayer); // Create markers for start & end and a layer for them MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder(); markerBuilder.Bitmap = olmarker; markerBuilder.HideIfOverlapped = false; markerBuilder.Size = 30; markerBuilder.Color = green; startMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); startMarker.Visible = false; markerBuilder.Color = red; stopMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); stopMarker.Visible = false; routeStartStopDataSource.Add(startMarker); routeStartStopDataSource.Add(stopMarker); markerBuilder.Color = white; markerBuilder.Bitmap = up; markerBuilder.Size = 20; instructionUp = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upleft; instructionLeft = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upright; instructionRight = markerBuilder.BuildStyle(); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); // Initialize a local vector data source LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(source); // Add the previous vector layer to the map MapView.Layers.Add(layer); // Create marker style Android.Graphics.Bitmap androidMarkerBitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker); Carto.Graphics.Bitmap markerBitmap = Carto.Utils.BitmapUtils.CreateBitmapFromAndroidBitmap(androidMarkerBitmap); MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder(); markerStyleBuilder.Bitmap = markerBitmap; markerStyleBuilder.Size = 30; MarkerStyle markerStyle = markerStyleBuilder.BuildStyle(); // Add marker MapPos berlin = MapView.Options.BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704)); Marker marker = new Marker(berlin, markerStyle); source.Add(marker); // Add popup PopupStyleBuilder builder = new PopupStyleBuilder(); builder.SetAttachAnchorPoint(0.5f, 0); PopupStyle popupStyle = builder.BuildStyle(); BasicCustomPopupHandler popupHandler = new BasicCustomPopupHandler("custom popup"); CustomPopup popup = new CustomPopup(marker, popupStyle, popupHandler); popup.SetAnchorPoint(-1, 0); source.Add(popup); // Animate map to the marker MapView.SetFocusPos(berlin, 1); MapView.SetZoom(12, 1); }
public static void Add3DPolygon(LocalVectorDataSource source, Projection projection) { // Create 3d polygon style and poses Polygon3DStyleBuilder polygon3DStyleBuilder = new Polygon3DStyleBuilder(); polygon3DStyleBuilder.Color = new Color(51, 51, 255, 255); MapPosVector polygon3DPoses = new MapPosVector(); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.635930, 59.416659))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.642453, 59.411354))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646187, 59.409607))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.652667, 59.413123))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.650736, 59.416703))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646444, 59.416245))); // Create 3d polygon holes poses MapPosVector holePositions = new MapPosVector(); holePositions.Add(projection.FromWgs84(new MapPos(24.643409, 59.411922))); holePositions.Add(projection.FromWgs84(new MapPos(24.651207, 59.412896))); holePositions.Add(projection.FromWgs84(new MapPos(24.643207, 59.414411))); MapPosVectorVector holes = new MapPosVectorVector(); holes.Add(holePositions); // Add to datasource Polygon3D polygon = new Polygon3D(polygon3DPoses, holes, polygon3DStyleBuilder.BuildStyle(), 150); polygon.SetMetaDataElement("ClickText", new Variant("Polygon 3D")); source.Add(polygon); }
public override bool OnUTFGridClicked(UTFGridClickInfo clickInfo) { if (vectorDataSource == null) { vectorDataSource = (LocalVectorDataSource)vectorLayer.DataSource; } // Clear previous popups vectorDataSource.Clear(); // Multiple vector elements can be clicked at the same time, we only care about the one // Check the type of vector element BalloonPopup clickPopup = null; BalloonPopupStyleBuilder styleBuilder = new BalloonPopupStyleBuilder(); // Configure style styleBuilder.LeftMargins = new BalloonPopupMargins(0, 0, 0, 0); styleBuilder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3); // Make sure this label is shown on top all other labels styleBuilder.PlacementPriority = 10; // Show clicked element variant as JSON string string desc = clickInfo.ElementInfo.ToString(); clickPopup = new BalloonPopup(clickInfo.ClickPos, styleBuilder.BuildStyle(), "", desc); vectorDataSource.Add(clickPopup); return(true); }
void AddPinTo(MapPos position) { // 1. Initialize a local vector data source LocalVectorDataSource vectorDataSource1 = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer vectorLayer1 = new VectorLayer(vectorDataSource1); // Add the previous vector layer to the map MapView.Layers.Add(vectorLayer1); // Set visible zoom range for the vector layer vectorLayer1.VisibleZoomRange = new MapRange(0, 18); // Create marker style Carto.Graphics.Bitmap markerBitmap = BitmapUtils.CreateBitmapFromUIImage(UIImage.FromFile("marker.png")); MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder(); markerStyleBuilder.Bitmap = markerBitmap; markerStyleBuilder.Size = 30; MarkerStyle sharedMarkerStyle = markerStyleBuilder.BuildStyle(); // 3. Add marker MapPos markerPos = MapView.Options.BaseProjection.FromWgs84(position); Marker marker1 = new Marker(markerPos, sharedMarkerStyle); vectorDataSource1.Add(marker1); // Animate map to the marker MapView.SetFocusPos(markerPos, 1); MapView.SetZoom(12, 1); }
public static Marker AddMarkerToPosition(this MapView map, MapPos position) { // Initialize a local vector data source Projection projection = map.Options.BaseProjection; LocalVectorDataSource datasource = new LocalVectorDataSource(projection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(datasource); // Add layer to map map.Layers.Add(layer); // Set marker style MarkerStyleBuilder builder = new MarkerStyleBuilder(); builder.Size = 20; builder.Color = new Carto.Graphics.Color(0, 255, 0, 255); MarkerStyle style = builder.BuildStyle(); // Create marker and add it to the source Marker marker = new Marker(position, style); datasource.Add(marker); return(marker); }
public static async void AddMarkerToPosition(this MapView map, MapPos position) { await ThreadPool.RunAsync(delegate { // Initialize a local vector data source Projection projection = map.Options.BaseProjection; LocalVectorDataSource datasource = new LocalVectorDataSource(projection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(datasource); // Add layer to map map.Layers.Add(layer); MarkerStyleBuilder builder = new MarkerStyleBuilder(); builder.Size = 15; builder.Color = new Carto.Graphics.Color(0, 255, 0, 255); MarkerStyle style = builder.BuildStyle(); // Create marker and add it to the source Marker marker = new Marker(position, style); datasource.Add(marker); }); }
public static void AddBalloonPopup1(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage) { // TODO REMOVE WHEN ANDROID COMPLETE //Bitmap infoImage = BitmapFactory.decodeResource(getResources(), R.drawable.info); //Bitmap arrowImage = BitmapFactory.decodeResource(getResources(), R.drawable.arrow); //BitmapUtils.createBitmapFromAndroidBitmap(infoImage) //BitmapUtils.createBitmapFromAndroidBitmap(arrowImage); // Add popup BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6); builder.LeftImage = leftImage; builder.RightImage = rightImage; builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6); builder.CornerRadius = 20; builder.PlacementPriority = 1; MapPos position = projection.FromWgs84(new MapPos(24.655662, 59.425521)); BalloonPopup popup1 = new BalloonPopup(position, builder.BuildStyle(), "Popup with pos", "Images, round"); popup1.SetMetaDataElement("ClickText", new Variant("Popup nr 1")); source.Add(popup1); }
public void Update() { MapPos position = Projection.FromWgs84(new MapPos(Longitude, Latitude)); if (!FoundUser) { MapView.SetFocusPos(position, 0); MapView.SetZoom(17, 0); FoundUser = true; } var builder = new PolygonStyleBuilder(); builder.Color = LightTransparentAppleBlue; var borderBuilder = new LineStyleBuilder(); borderBuilder.Color = DarkTransparentAppleBlue; borderBuilder.Width = 1; MapPosVector points = GetCirclePoints(Longitude, Latitude, Accuracy); if (accuracyMarker == null) { accuracyMarker = new Polygon(points, new MapPosVectorVector(), builder.BuildStyle()); source.Add(accuracyMarker); } else { accuracyMarker.Style = builder.BuildStyle(); accuracyMarker.Geometry = new PolygonGeometry(points); } if (userMarker == null) { var markerBuilder = new PointStyleBuilder(); markerBuilder.Color = DarkTransparentAppleBlue; markerBuilder.Size = 16.0f; userMarker = new Point(position, markerBuilder.BuildStyle()); source.Add(userMarker); } else { userMarker.SetPos(position); } }
public static void AddPoint2(LocalVectorDataSource source, Projection projection) { Color red = new Color(255, 0, 0, 255); Point point2 = GetPoint(projection, new MapPos(24.655994, 59.422716), red); point2.SetMetaDataElement("ClickText", new Variant("Point nr 2")); source.Add(point2); }
public static void AddPoint1(LocalVectorDataSource source, Projection projection) { Color green = new Color(0, 255, 0, 255); Point point1 = GetPoint(projection, new MapPos(24.651488, 59.423581), green); point1.SetMetaDataElement("ClickText", new Variant("Point nr 1")); source.Add(point1); }
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); } }
public static async void AddMarkerToPosition(this MapView map, MapPos position) { await ThreadPool.RunAsync(delegate { // Initialize a local vector data source Projection projection = map.Options.BaseProjection; LocalVectorDataSource datasource = new LocalVectorDataSource(projection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(datasource); // Add layer to map map.Layers.Add(layer); MarkerStyleBuilder builder = new MarkerStyleBuilder(); builder.Size = 20; builder.Color = new Carto.Graphics.Color(0, 255, 0, 255); MarkerStyle style = builder.BuildStyle(); // Create marker and add it to the source Marker marker = new Marker(position, style); // Add text element to same location TextStyleBuilder MyStyleBuilder = new TextStyleBuilder { OrientationMode = BillboardOrientation.BillboardOrientationGround, FontSize = 12.0f, CausesOverlap = false, Color = new Carto.Graphics.Color(255, 0, 0, 255), ScalingMode = BillboardScaling.BillboardScalingWorldSize, Flippable = false, HideIfOverlapped = false, RenderScale = 8.0f }; Text text = new Text(position, MyStyleBuilder.BuildStyle(), "TEXT"); datasource.Add(marker); datasource.Add(text); }); }
public static void AddPolygon(this LocalVectorDataSource source, MapPosVector positions) { PolygonStyleBuilder builder = new PolygonStyleBuilder(); builder.Color = new Color(0, 255, 0, 255); Polygon polygon = new Polygon(positions, builder.BuildStyle()); source.Add(polygon); }
public static void AddPoint(this LocalVectorDataSource source, MapPos position) { PointStyleBuilder builder = new PointStyleBuilder(); builder.Size = 30; builder.Color = new Color(0, 0, 255, 255); Point point = new Point(position, builder.BuildStyle()); source.Add(point); }
public static void AddBalloonPopup2(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage, Bitmap markerImage) { // Add popup, but instead of giving it a position attach it to a marker BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.Color = new Color(0, 0, 0, 255); builder.CornerRadius = 0; builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6); builder.LeftImage = leftImage; builder.RightImage = rightImage; builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6); builder.TitleColor = new Color(255, 255, 255, 255); builder.TitleFontName = "HelveticaNeue-Medium"; builder.TitleFontSize = 11; builder.DescriptionColor = new Color(255, 255, 255, 255); builder.DescriptionFontName = "HelveticaNeue-Medium"; builder.DescriptionFontSize = 11; builder.StrokeColor = new Color(255, 0, 120, 255); builder.StrokeWidth = 0; builder.PlacementPriority = 1; Marker marker = GetMarker(projection, new MapPos(24.646469, 59.426939), markerImage); source.Add(marker); Marker marker2 = GetMarker(projection, new MapPos(24.666469, 59.422939), markerImage); source.Add(marker2); BalloonPopup popup = new BalloonPopup(marker, builder.BuildStyle(), "Popup attached to marker", "Black, rectangle."); popup.SetMetaDataElement("ClickText", new Variant("Popup nr 2")); source.Add(popup); }
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 AddText2(LocalVectorDataSource source, Projection projection) { TextStyleBuilder builder = new TextStyleBuilder(); builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera; MapPos position = projection.FromWgs84(new MapPos(24.633216, 59.426869)); Text popup = new Text(position, builder.BuildStyle(), "Face camera ground text"); popup.SetMetaDataElement("ClickText", new Variant("Text nr 2")); source.Add(popup); }
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); }
void OnLocationUpdate(object sender, LocationUpdatedEventArgs e) { double latitude = e.Location.Coordinate.Latitude; double longitude = e.Location.Coordinate.Longitude; string title = "Your current location"; string description = latitude.To4Decimals() + ", " + longitude.To4Decimals(); MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude)); if (IsMarkerSet) { markerLabel.Description = description; positionMarker.Geometry = new PointGeometry(location); return; } // Load default market style MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder(); // Add the label to the Marker positionMarker = new Marker(location, markerStyleBuilder.BuildStyle()); // Define label what is shown when you click on marker, with default style var builder = new BalloonPopupStyleBuilder(); markerLabel = new BalloonPopup(positionMarker, builder.BuildStyle(), title, description); // Add the marker and label to the layer markerSource.Add(positionMarker); markerSource.Add(markerLabel); // Center the map in the current location MapView.FocusPos = location; // Zoom in the map in the current location MapView.Zoom = 19f; }
public static void Add3DCar(LocalVectorDataSource source, Projection projection) { // Add a single 3D model to the vector layer // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android) string name = "milktruck.nml"; MapPos modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939)); NMLModel model = new NMLModel(modelPos, AssetUtils.LoadAsset(name)); model.Scale = 20; model.SetMetaDataElement("ClickText", new Variant("Single model")); source.Add(model); }
public static void Add3DCar(LocalVectorDataSource source, Projection projection) { // Add a single 3D model to the vector layer // Be sure to add milktruck.nml to your *Assets*, not Drawable, folder (Android) string name = "milktruck.nml"; MapPos modelPos = projection.FromWgs84(new MapPos(24.646469, 59.423939)); NMLModel model = new NMLModel(modelPos, AssetUtils.LoadAsset(name)); model.Scale = 20; model.SetMetaDataElement("ClickText", new Variant("Single model")); source.Add(model); }
public static void AddText3(LocalVectorDataSource source, Projection projection) { TextStyleBuilder builder = new TextStyleBuilder(); builder.FontSize = 22; builder.OrientationMode = BillboardOrientation.BillboardOrientationGround; MapPos position = projection.FromWgs84(new MapPos(24.646457, 59.420839)); Text popup = new Text(position, builder.BuildStyle(), "Ground text"); popup.SetMetaDataElement("ClickText", new Variant("Text nr 3")); source.Add(popup); }
public override bool OnVectorTileClicked(VectorTileClickInfo clickInfo) { if (Previous != null) { source.Remove(Previous); } var feature = clickInfo.Feature; var properties = feature.Properties; BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.LeftMargins = new BalloonPopupMargins(0, 0, 0, 0); builder.RightMargins = new BalloonPopupMargins(6, 3, 6, 3); builder.PlacementPriority = 10; builder.CornerRadius = 5; builder.TitleFontSize = 14; builder.TitleColor = new Color(20, 20, 20, 255); builder.DescriptionFontSize = 9; builder.DescriptionColor = new Color(100, 100, 100, 255); builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6); builder.LeftImage = LeftImage; builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6); var animationBuilder = new AnimationStyleBuilder(); animationBuilder.RelativeSpeed = 2.0f; animationBuilder.SizeAnimationType = AnimationType.AnimationTypeSpring; builder.AnimationStyle = animationBuilder.BuildStyle(); BalloonPopupStyle style = builder.BuildStyle(); string title = properties.GetObjectElement("title").String; string description = properties.GetObjectElement("description").String; MapPos position = clickInfo.Feature.Geometry.CenterPos; BalloonPopup popup = new BalloonPopup(position, style, title, description);; source.Add(popup); Previous = popup; string url = properties.GetObjectElement("attachment_url").String; Click?.Invoke(url, EventArgs.Empty); return(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Add default base layer AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection); VectorLayer layer = new VectorLayer(source); MapView.Layers.Add(layer); MarkerStyleBuilder builder = new MarkerStyleBuilder(); builder.Bitmap = Bitmap; builder.Size = 20; // Add marker MapPos position = BaseProjection.FromWgs84(new MapPos(24.646469, 59.426939)); Marker marker = new Marker(position, builder.BuildStyle()); source.Add(marker); // Custom popup PopupStyleBuilder popupBuilder = new PopupStyleBuilder(); popupBuilder.SetAttachAnchorPoint(0.5f, 0); // Initialize our custom handler, cf. class below MyCustomPopupHandler handler = new MyCustomPopupHandler(); CustomPopup popup = new CustomPopup(marker, popupBuilder.BuildStyle(), handler); popup.SetAnchorPoint(-1.0f, 0.0f); source.Add(popup); }
public void AddPointOfInterest(VectorTileFeature item) { var builder = new PointStyleBuilder(); builder.Size = 20.0f; builder.Color = new Carto.Graphics.Color(230, 100, 100, 200); MapPos position = (item.Geometry as PointGeometry).Pos; var point = new Point(position, builder.BuildStyle()); point.SetMetaDataElement(VectorElementListener.RouteSearchTitle, new Variant("Properties")); point.SetMetaDataElement(VectorElementListener.RouteSearchDescription, new Variant(item.Properties.ToString())); overlaySource.Add(point); }
public override void OnMapClicked(MapClickInfo mapClickInfo) { // Remove old click label if (oldClickLabel != null) { vectorDataSource.Remove(oldClickLabel); oldClickLabel = null; } BalloonPopupStyleBuilder styleBuilder = new BalloonPopupStyleBuilder(); // Make sure this label is shown on top all other labels styleBuilder.PlacementPriority = 10; // Check the type of the click string clickMsg = null; if (mapClickInfo.ClickType == ClickType.ClickTypeSingle) { clickMsg = "Single map click!"; } else if (mapClickInfo.ClickType == ClickType.ClickTypeLong) { clickMsg = "Long map click!"; } else if (mapClickInfo.ClickType == ClickType.ClickTypeDouble) { clickMsg = "Double map click!"; } else if (mapClickInfo.ClickType == ClickType.ClickTypeDual) { clickMsg = "Dual map click!"; } MapPos clickPos = mapClickInfo.ClickPos; // Show click coordinates also MapPos wgs84Clickpos = mapView.Options.BaseProjection.ToWgs84(clickPos); //string message = string.Format("%.4f, %.4f", wgs84Clickpos.Y, wgs84Clickpos.X); string message = Math.Round(wgs84Clickpos.Y, 4) + ", " + Math.Round(wgs84Clickpos.X, 4); BalloonPopupStyle style = styleBuilder.BuildStyle(); BalloonPopup popup = new BalloonPopup(mapClickInfo.ClickPos, style, clickMsg, message); vectorDataSource.Add(popup); oldClickLabel = popup; }
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 static void QueryFeatures(this MapView map, CartoSQLService service, LocalVectorDataSource source, PointStyle style, string query) { System.Threading.Tasks.Task.Run(delegate { FeatureCollection features = service.QueryFeatures(query, map.Options.BaseProjection); for (int i = 0; i < features.FeatureCount; i++) { Feature feature = features.GetFeature(i); PointGeometry geometry = (PointGeometry)feature.Geometry; var point = new Point(geometry, style); source.Add(point); } }); }
public static void QueryFeatures(this MapView map, CartoSQLService service, LocalVectorDataSource source, PointStyle style, string query) { System.Threading.Tasks.Task.Run(delegate { FeatureCollection features = service.QueryFeatures(query, map.Options.BaseProjection); for (int i = 0; i < features.FeatureCount; i++) { Feature feature = features.GetFeature(i); PointGeometry geometry = (PointGeometry)feature.Geometry; var point = new Point(geometry, style); source.Add(point); } }); }
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); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); // Initialize a local vector data source LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(source); // Add the previous vector layer to the map MapView.Layers.Add(layer); // Set visible zoom range for the vector layer layer.VisibleZoomRange = new MapRange(0, 18); // Create marker style Android.Graphics.Bitmap image = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker); Carto.Graphics.Bitmap markerBitmap = BitmapUtils.CreateBitmapFromAndroidBitmap(image); MarkerStyleBuilder builder = new MarkerStyleBuilder(); builder.Bitmap = markerBitmap; builder.Size = 30; MarkerStyle style = builder.BuildStyle(); // Add marker MapPos washington = BaseProjection.FromWgs84(new MapPos(-77.0369, 38.9072)); Marker marker = new Marker(washington, style); source.Add(marker); // Animate map to the marker MapView.SetFocusPos(washington, 1); MapView.SetZoom(8, 1); listener = new RenderListener(); MapView.MapRenderer.CaptureRendering(listener, true); }
public static void AddText2(LocalVectorDataSource source, Projection projection) { TextStyleBuilder builder = new TextStyleBuilder(); builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera; MapPos position = projection.FromWgs84(new MapPos(24.633216, 59.426869)); Text popup = new Text(position, builder.BuildStyle(), "Face camera ground text"); popup.SetMetaDataElement("ClickText", new Variant("Text nr 2")); source.Add(popup); }
public void CreateRoutePoint(MapPos pos, RoutingInstruction instruction, LocalVectorDataSource source) { MarkerStyle style = instructionUp; string str = ""; switch (instruction.Action) { case RoutingAction.RoutingActionHeadOn: str = "head on"; break; case RoutingAction.RoutingActionFinish: str = "finish"; break; case RoutingAction.RoutingActionTurnLeft: style = instructionLeft; str = "turn left"; break; case RoutingAction.RoutingActionTurnRight: style = instructionRight; str = "turn right"; break; case RoutingAction.RoutingActionUturn: str = "u turn"; break; case RoutingAction.RoutingActionNoTurn: case RoutingAction.RoutingActionGoStraight: //style = instructionUp; //str = "continue"; break; case RoutingAction.RoutingActionReachViaLocation: style = instructionUp; str = "stopover"; break; case RoutingAction.RoutingActionEnterAgainstAllowedDirection: str = "enter against allowed direction"; break; case RoutingAction.RoutingActionLeaveAgainstAllowedDirection: break; case RoutingAction.RoutingActionEnterRoundabout: str = "enter roundabout"; break; case RoutingAction.RoutingActionStayOnRoundabout: str = "stay on roundabout"; break; case RoutingAction.RoutingActionLeaveRoundabout: str = "leave roundabout"; break; case RoutingAction.RoutingActionStartAtEndOfStreet: str = "start at end of street"; break; } if (str != "") { Marker marker = new Marker(pos, style); BalloonPopup popup2 = new BalloonPopup(marker, balloonBuilder.BuildStyle(), str, ""); source.Add(popup2); source.Add(marker); } }
public static void AddPoint2(LocalVectorDataSource source, Projection projection) { Color red = new Color(255, 0, 0, 255); Point point2 = GetPoint(projection, new MapPos(24.655994, 59.422716), red); point2.SetMetaDataElement("ClickText", new Variant("Point nr 2")); source.Add(point2); }
public static void AddText1(LocalVectorDataSource source, Projection projection) { // Create text style TextStyleBuilder builder = new TextStyleBuilder(); builder.Color = new Color(255, 0, 0, 255); // Red builder.OrientationMode = BillboardOrientation.BillboardOrientationFaceCamera; // This enables higher resolution texts for retina devices, but consumes more memory and is slower builder.ScaleWithDPI = false; // Add text MapPos position = projection.FromWgs84(new MapPos(24.653302, 59.422269)); Text popup = new Text(position, builder.BuildStyle(), "Face camera text"); popup.SetMetaDataElement("ClickText", new Variant("Text nr 1")); source.Add(popup); }
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 static void AddPoint1(LocalVectorDataSource source, Projection projection) { Color green = new Color(0, 255, 0, 255); Point point1 = GetPoint(projection, new MapPos(24.651488, 59.423581), green); point1.SetMetaDataElement("ClickText", new Variant("Point nr 1")); source.Add(point1); }
public static void AddBalloonPopup1(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage) { // TODO REMOVE WHEN ANDROID COMPLETE //Bitmap infoImage = BitmapFactory.decodeResource(getResources(), R.drawable.info); //Bitmap arrowImage = BitmapFactory.decodeResource(getResources(), R.drawable.arrow); //BitmapUtils.createBitmapFromAndroidBitmap(infoImage) //BitmapUtils.createBitmapFromAndroidBitmap(arrowImage); // Add popup BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6); builder.LeftImage = leftImage; builder.RightImage = rightImage; builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6); builder.CornerRadius = 20; builder.PlacementPriority = 1; builder.TitleFontSize = 10; builder.DescriptionFontSize = 10; MapPos position = projection.FromWgs84(new MapPos(24.655662, 59.425521)); BalloonPopup popup1 = new BalloonPopup(position, builder.BuildStyle(), "Popup with pos", "Images, round"); popup1.SetMetaDataElement("ClickText", new Variant("Popup nr 1")); source.Add(popup1); }
public static void AddBalloonPopup2(LocalVectorDataSource source, Projection projection, Bitmap leftImage, Bitmap rightImage, Bitmap markerImage) { // Add popup, but instead of giving it a position attach it to a marker BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.Color = new Color(0, 0, 0, 255); builder.CornerRadius = 0; builder.LeftMargins = new BalloonPopupMargins(6, 6, 6, 6); builder.LeftImage = leftImage; builder.RightImage = rightImage; builder.RightMargins = new BalloonPopupMargins(2, 6, 12, 6); builder.TitleColor = new Color(255, 255, 255, 255); builder.TitleFontName = "HelveticaNeue-Medium"; builder.TitleFontSize = 11; builder.DescriptionColor = new Color(255, 255, 255, 255); builder.DescriptionFontName = "HelveticaNeue-Medium"; builder.DescriptionFontSize = 11; builder.StrokeColor = new Color(255, 0, 120, 255); builder.StrokeWidth = 0; builder.PlacementPriority = 1; Marker marker = GetMarker(projection, new MapPos(24.646469, 59.426939), markerImage); source.Add(marker); Marker marker2 = GetMarker(projection, new MapPos(24.666469, 59.422939), markerImage); source.Add(marker2); BalloonPopup popup = new BalloonPopup(marker, builder.BuildStyle(), "Popup attached to marker", "Black, rectangle."); popup.SetMetaDataElement("ClickText", new Variant("Popup nr 2")); source.Add(popup); }
public static void AddBalloonPopup3(LocalVectorDataSource source, Projection projection) { // Add popup BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.DescriptionWrap = false; builder.PlacementPriority = 1; builder.TitleFontSize = 14; builder.DescriptionFontSize = 12; MapPos position = projection.FromWgs84(new MapPos(24.658662, 59.432521)); String title = "This title will be wrapped if there's not enough space on the screen."; String description = "Description is set to be truncated with three dots, unless the screen is really really big."; BalloonPopup popup = new BalloonPopup(position, builder.BuildStyle(), title, description); popup.SetMetaDataElement("ClickText", new Variant("Popup nr 3")); source.Add(popup); }
public static void Add3DPolygon(LocalVectorDataSource source, Projection projection) { // Create 3d polygon style and poses Polygon3DStyleBuilder polygon3DStyleBuilder = new Polygon3DStyleBuilder(); polygon3DStyleBuilder.Color = new Color(51, 51, 255, 255); MapPosVector polygon3DPoses = new MapPosVector(); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.635930, 59.416659))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.642453, 59.411354))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646187, 59.409607))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.652667, 59.413123))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.650736, 59.416703))); polygon3DPoses.Add(projection.FromWgs84(new MapPos(24.646444, 59.416245))); // Create 3d polygon holes poses MapPosVector holePositions = new MapPosVector(); holePositions.Add(projection.FromWgs84(new MapPos(24.643409, 59.411922))); holePositions.Add(projection.FromWgs84(new MapPos(24.651207, 59.412896))); holePositions.Add(projection.FromWgs84(new MapPos(24.643207, 59.414411))); MapPosVectorVector holes = new MapPosVectorVector(); holes.Add(holePositions); // Add to datasource Polygon3D polygon = new Polygon3D(polygon3DPoses, holes, polygon3DStyleBuilder.BuildStyle(), 150); polygon.SetMetaDataElement("ClickText", new Variant("Polygon 3D")); source.Add(polygon); }
public void SetSourcesAndElements(Bitmap olmarker, Bitmap up, Bitmap upleft, Bitmap upright, Color green, Color red, Color white) { // Define layer and datasource for route line and instructions routeDataSource = new LocalVectorDataSource(BaseProjection); VectorLayer routeLayer = new VectorLayer(routeDataSource); MapView.Layers.Add(routeLayer); // Define layer and datasource for route start and stop markers routeStartStopDataSource = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer vectorLayer = new VectorLayer(routeStartStopDataSource); // Add the previous vector layer to the map MapView.Layers.Add(vectorLayer); // Set visible zoom range for the vector layer vectorLayer.VisibleZoomRange = new MapRange(0, 22); // Create markers for start & end and a layer for them MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder(); markerBuilder.Bitmap = olmarker; markerBuilder.HideIfOverlapped = false; markerBuilder.Size = 30; markerBuilder.Color = green; startMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); startMarker.Visible = false; markerBuilder.Color = red; stopMarker = new Marker(new MapPos(0, 0), markerBuilder.BuildStyle()); stopMarker.Visible = false; routeStartStopDataSource.Add(startMarker); routeStartStopDataSource.Add(stopMarker); markerBuilder.Color = white; markerBuilder.Bitmap = up; instructionUp = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upleft; instructionLeft = markerBuilder.BuildStyle(); markerBuilder.Bitmap = upright; instructionRight = markerBuilder.BuildStyle(); // Style for instruction balloons balloonBuilder = new BalloonPopupStyleBuilder(); balloonBuilder.TitleMargins = new BalloonPopupMargins(4, 4, 4, 4); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); // Initialize a local vector data source LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(source); // Add the previous vector layer to the map MapView.Layers.Add(layer); // Create marker style Android.Graphics.Bitmap androidMarkerBitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker); Carto.Graphics.Bitmap markerBitmap = Carto.Utils.BitmapUtils.CreateBitmapFromAndroidBitmap(androidMarkerBitmap); MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder(); markerStyleBuilder.Bitmap = markerBitmap; markerStyleBuilder.Size = 30; MarkerStyle markerStyle = markerStyleBuilder.BuildStyle(); // Add marker MapPos berlin = MapView.Options.BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704)); Marker marker = new Marker(berlin, markerStyle); source.Add(marker); // Add popup PopupStyleBuilder builder = new PopupStyleBuilder(); builder.SetAttachAnchorPoint(0.5f, 0); PopupStyle popupStyle = builder.BuildStyle(); BasicCustomPopupHandler popupHandler = new BasicCustomPopupHandler("custom popup"); CustomPopup popup = new CustomPopup(marker, popupStyle, popupHandler); popup.SetAnchorPoint(-1, 0); source.Add(popup); // Animate map to the marker MapView.SetFocusPos(berlin, 1); MapView.SetZoom(12, 1); }
public static void AddText3(LocalVectorDataSource source, Projection projection) { TextStyleBuilder builder = new TextStyleBuilder(); builder.FontSize = 22; builder.OrientationMode = BillboardOrientation.BillboardOrientationGround; MapPos position = projection.FromWgs84(new MapPos(24.646457, 59.420839)); Text popup = new Text(position, builder.BuildStyle(), "Ground text"); popup.SetMetaDataElement("ClickText", new Variant("Text nr 3")); source.Add(popup); }