public void OnStyleLoaded(Style p0) { symbolManager = new SymbolManager(mapView, mapbox, p0); Com.Mapbox.Geojson.Point point = Com.Mapbox.Geojson.Point.FromLngLat(105.505, 21.033); mapbox.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(point.Latitude(), point.Longitude()), 8)); var options = new SymbolOptions(); options.WithIconImage("fire-station-11"); options.WithGeometry(point); options.WithIconSize(new Float(2f)) .WithDraggable(true); var symbol = symbolManager.Create(options); Com.Mapbox.Geojson.Point point2 = Com.Mapbox.Geojson.Point.FromLngLat(25.8672299, 85.1720807); var options2 = new SymbolOptions() .WithIconImage("fire-station-11") .WithGeometry(point2) .WithIconSize(new Float(2f)) .WithDraggable(true); var symbol2 = symbolManager.Create(options2); symbolManager.AddClickListener(this); }
private async void BtnLoc_Click(object sender, EventArgs e) { try { currentLocation = await Geolocation.GetLastKnownLocationAsync(); if (currentLocation != null) { txtLoc.Text = $"Latitude={currentLocation.Latitude} , Longitude={currentLocation.Longitude} "; Console.WriteLine($"Latitude: {currentLocation.Latitude}, Longitude: {currentLocation.Longitude}, Altitude: {currentLocation.Altitude}"); //mapView.GetMapAsync(this); Com.Mapbox.Geojson.Point point = Com.Mapbox.Geojson.Point.FromLngLat(currentLocation.Longitude, currentLocation.Latitude); mapbox.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(point.Latitude(), point.Longitude()), 15)); var options = new SymbolOptions(); options.WithIconImage("airport-15"); options.WithGeometry(point); options.WithIconSize(new Float(2f)) .WithDraggable(true); var symbol = symbolManager.Create(options); } } catch { } }
public static SymbolOptions ToSymbolOptions(this SymbolAnnotation symbolAnnotation) { var symbolOptions = new SymbolOptions() .WithLatLng(symbolAnnotation.Coordinates.ToLatLng()); if (!string.IsNullOrWhiteSpace(symbolAnnotation.IconAnchor)) { symbolOptions.WithIconImage(symbolAnnotation.IconAnchor); } if (symbolAnnotation.IconColor.HasValue) { symbolOptions.WithIconColor(symbolAnnotation.IconColor.Value.ToRGBAString()); } if (symbolAnnotation.IconHaloBlur.HasValue) { symbolOptions.WithIconHaloBlur(new Float(symbolAnnotation.IconHaloBlur.Value)); } if (symbolAnnotation.IconHaloColor.HasValue) { symbolOptions.WithIconHaloColor(symbolAnnotation.IconHaloColor.Value.ToRGBAString()); } if (symbolAnnotation.IconHaloWidth.HasValue) { symbolOptions.WithIconHaloWidth(new Float(symbolAnnotation.IconHaloWidth.Value)); } if (symbolAnnotation.IconImage != null) { symbolOptions.WithIconImage(symbolAnnotation.IconImage.Id); } if (symbolAnnotation.IconOffset?.Length > 0) { symbolOptions.WithIconOffset(symbolAnnotation.IconOffset.Select(x => new Float(x)).ToArray()); } if (symbolAnnotation.IconOpacity.HasValue) { symbolOptions.WithIconOpacity(new Float(symbolAnnotation.IconOpacity.Value)); } if (symbolAnnotation.IconRotate.HasValue) { symbolOptions.WithIconRotate(new Float(symbolAnnotation.IconRotate.Value)); } if (symbolAnnotation.IconSize.HasValue) { symbolOptions.WithIconSize(new Float(symbolAnnotation.IconSize.Value)); } if (symbolAnnotation.IsDraggable.HasValue) { symbolOptions.WithDraggable(symbolAnnotation.IsDraggable.Value); } if (symbolAnnotation.SymbolSortKey.HasValue) { symbolOptions.WithSymbolSortKey(new Float(symbolAnnotation.SymbolSortKey.Value)); } if (!string.IsNullOrWhiteSpace(symbolAnnotation.TextAnchor)) { symbolOptions.WithTextAnchor(symbolAnnotation.TextAnchor); } if (symbolAnnotation.TextColor.HasValue) { symbolOptions.WithTextColor(symbolAnnotation.TextColor.Value.ToRGBAString()); } if (!string.IsNullOrWhiteSpace(symbolAnnotation.TextField)) { symbolOptions.WithTextField(symbolAnnotation.TextField); } if (symbolAnnotation.TextFont?.Length > 0) { symbolOptions.WithTextFont(symbolAnnotation.TextFont); } if (symbolAnnotation.TextHaloBlur.HasValue) { symbolOptions.WithTextHaloBlur(new Float(symbolAnnotation.TextHaloBlur.Value)); } if (symbolAnnotation.TextHaloColor.HasValue) { symbolOptions.WithTextHaloColor(symbolAnnotation.TextHaloColor.Value.ToRGBAString()); } if (symbolAnnotation.TextHaloWidth.HasValue) { symbolOptions.WithTextHaloWidth(new Float(symbolAnnotation.TextHaloWidth.Value)); } if (!string.IsNullOrWhiteSpace(symbolAnnotation.TextJustify)) { symbolOptions.WithTextJustify(symbolAnnotation.TextJustify); } if (symbolAnnotation.TextLetterSpacing.HasValue) { symbolOptions.WithTextLetterSpacing(new Float(symbolAnnotation.TextLetterSpacing.Value)); } if (symbolAnnotation.TextMaxWidth.HasValue) { symbolOptions.WithTextMaxWidth(new Float(symbolAnnotation.TextMaxWidth.Value)); } if (symbolAnnotation.TextOffset?.Length > 0) { symbolOptions.WithTextOffset(symbolAnnotation.TextOffset.Select(x => new Float(x)).ToArray()); } if (symbolAnnotation.TextOpacity.HasValue) { symbolOptions.WithTextOpacity(new Float(symbolAnnotation.TextOpacity.Value)); } if (symbolAnnotation.TextRadialOffset.HasValue) { symbolOptions.WithTextRadialOffset(new Float(symbolAnnotation.TextRadialOffset.Value)); } if (symbolAnnotation.TextRotate.HasValue) { symbolOptions.WithTextRotate(new Float(symbolAnnotation.TextRotate.Value)); } if (symbolAnnotation.TextSize.HasValue) { symbolOptions.WithTextSize(new Float(symbolAnnotation.TextSize.Value)); } if (!string.IsNullOrWhiteSpace(symbolAnnotation.TextTransform)) { symbolOptions.WithTextTransform(symbolAnnotation.TextTransform); } return(symbolOptions); }