private async void HandleWatchPositionReceived(object sender, GeolocationEventArgs e) { LastWatchPositionResult = e.GeolocationResult; if (LastWatchPositionResult.IsSuccess) { var latlng = LastWatchPositionResult.Position.ToLeafletLatLng(); var marker = new Marker(latlng, null); if (WatchPath is null) { WatchMarkers = new List <Marker> { marker }; WatchPath = new Polyline(WatchMarkers.Select(m => m.LatLng), new PolylineOptions()); await WatchPath.BindToJsRuntime(JSRuntime); await WatchPath.AddTo(WatchMap); } else { WatchMarkers.Add(marker); await WatchPath.AddLatLng(latlng); } await marker.BindToJsRuntime(JSRuntime); await marker.AddTo(WatchMap); } StateHasChanged(); }
public async void ShowCurrentPosition() { if (CurrentPositionMarker != null) { await CurrentPositionMarker.Remove(); } CurrentPositionResult = await GeolocationService.GetCurrentPosition(); if (CurrentPositionResult.IsSuccess) { CurrentPositionMarker = new Marker( CurrentPositionResult.Position.ToLeafletLatLng(), null ); await CurrentPositionMarker.AddTo(PositionMap); } StateHasChanged(); }
protected async void AddMarkerAtMapCenter() { var mapCentre = await PositionMap.GetCenter(); var marker = new Marker(mapCentre, new MarkerOptions { Keyboard = MarkerViewModel.Keyboard, Title = MarkerViewModel.Title, Alt = MarkerViewModel.Alt, ZIndexOffset = MarkerViewModel.ZIndexOffset, Opacity = MarkerViewModel.Opacity, RiseOnHover = MarkerViewModel.RiseOnHover, RiseOffset = MarkerViewModel.RiseOffset, }); await marker.AddTo(PositionMap); }