public override VectorElement BuildClusterElement(MapPos pos, VectorElementVector elements) { BalloonPopupStyle style = balloonPopupStyleBuilder.BuildStyle(); var popup = new BalloonPopup(pos, style, elements.Count.ToString(), ""); return popup; }
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 override bool OnVectorElementClicked(VectorElementClickInfo clickInfo) { if (previous != null) { source.Remove(previous); } VectorElement element = clickInfo.VectorElement; BalloonPopupStyleBuilder builder = new BalloonPopupStyleBuilder(); builder.LeftMargins = new BalloonPopupMargins(0, 0, 0, 0); builder.RightMargins = new BalloonPopupMargins(6, 3, 6, 3); builder.PlacementPriority = 10; BalloonPopupStyle style = builder.BuildStyle(); string title = element.GetMetaDataElement("ClickText").String; string description = ""; for (int i = 0; i < element.MetaData.Count; i++) { string key = element.MetaData.Keys.ToList()[i]; description += key + " = " + element.GetMetaDataElement(key) + "; "; } BalloonPopup popup; if (element is BalloonPopup) { Billboard billboard = (Billboard)element; popup = new BalloonPopup(billboard, style, title, description); } else { MapPos position = clickInfo.ClickPos; popup = new BalloonPopup(position, style, title, description); } source.Add(popup); previous = popup; return true; }
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(), "Clicked", desc); vectorDataSource.Add(clickPopup); return true; }
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 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 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 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); }
void AddMarker(string title, string subtitle, float latitude, float longitude) { // Define the location of the marker, it must be converted to base map coordinate system MapPos location = MapView.Options.BaseProjection.FromWgs84(new MapPos(longitude, latitude)); // Load default market style MarkerStyleBuilder markerBuilder = new MarkerStyleBuilder(); // Add the label to the Marker positionMarker = new Marker(location, markerBuilder.BuildStyle()); // Define label what is shown when you click on marker, with default style var balloonBuilder = new BalloonPopupStyleBuilder(); positionLabel = new BalloonPopup(positionMarker, balloonBuilder.BuildStyle(), title, subtitle); // Add the marker and label to the layer markerSource.Add(positionMarker); markerSource.Add(positionLabel); // Center the map in the current location MapView.FocusPos = location; // Zoom in the map in the current location MapView.Zoom = 19f; }
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; }
protected 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, balloonPopupStyleBuilder.BuildStyle(), str, ""); source.Add(popup2); source.Add(marker); } }
public static void SetAttachedPopup(DependencyObject obj, BalloonPopup value) { obj.SetValue(AttachedPopupProperty, value); }
public override bool OnVectorElementClicked(VectorElementClickInfo clickInfo) { if (previous != null) { source.Remove(previous); } VectorElement element = clickInfo.VectorElement; 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 = 12; builder.DescriptionFontSize = 10; var navy = new Color(22, 41, 69, 255); builder.TitleColor = navy; builder.DescriptionColor = navy; var animationBuilder = new AnimationStyleBuilder(); animationBuilder.RelativeSpeed = 2.0f; animationBuilder.SizeAnimationType = AnimationType.AnimationTypeSpring; builder.AnimationStyle = animationBuilder.BuildStyle(); BalloonPopupStyle style = builder.BuildStyle(); string title = element.GetMetaDataElement("ClickText").String; string description = ""; if (!element.GetMetaDataElement(RouteSearchTitle).String.Equals(NullString)) { // Route search has a special click text title = element.GetMetaDataElement(RouteSearchTitle).String; description = element.GetMetaDataElement(RouteSearchDescription).String; } else { for (int i = 0; i < element.MetaData.Count; i++) { string key = element.MetaData.Keys.ToList()[i]; description += key + " = " + element.GetMetaDataElement(key) + "; "; } } BalloonPopup popup; if (element is BalloonPopup) { Billboard billboard = (Billboard)element; popup = new BalloonPopup(billboard, style, title, description); } else { MapPos position = clickInfo.ClickPos; popup = new BalloonPopup(position, style, title, description); } source.Add(popup); previous = 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); }