private async void ContentPage_AppearingAsync(object sender, EventArgs e)
        {
            var customMap = this.FindByName <CustomMap>("MapRouteOverview");

            /*var points = await vm.GetPointsForOverviewRouteAsync();
             * customMap.Points = points.Select(x => new PointForMap()
             * {
             *  Latitude = x.Latitude, Longitude = x.Longitude, PathToPicture = x.ImagePreviewPathForList, Name = x.Name, Description = x.Description
             * }).ToList();*/
            TrackFileManager trackFileManager = new TrackFileManager();
            var track = trackFileManager.GetTrackByRoute(_routeId);

            customMap.Points = track.Select(t => new PointForMap()
            {
                Latitude  = t.Item1 ?? 0.0,
                Longitude = t.Item2 ?? 0.0
            }).ToList();
            Pin           pin           = new Pin();
            CustomMapView customMapView = new CustomMapView(customMap, 15);

            if (customMap.Points.Any())
            {
                await centerMap(customMapView, customMap.Points.First().Latitude, customMap.Points.First().Longitude);
            }
        }
Example #2
0
 public CustomMapPage(CustomMapView customMapView, string title)
 {
     Title          = title;
     _customMapView = customMapView;
     _customMapView.HorizontalOptions = LayoutOptions.FillAndExpand;
     _customMapView.VerticalOptions   = LayoutOptions.FillAndExpand;
     Content = _customMapView;
 }
        private async Task centerMap(CustomMapView customMap, double Latitude, double Longitude)
        {
            if (!customMap.CenterMapToPosition(Latitude, Longitude, 10))
            {
                bool answerRetry = await DisplayAlert("Ошибка", customMap.LastError + " Повторить?", "Да", "Нет");

                if (answerRetry)
                {
                    await centerMap(customMap, Latitude, Longitude);
                }
            }
        }
        private async Task CenterMap(double latitude, double longitude, string name, string address)
        {
            CustomMapView customMap = new CustomMapView(PointMapOverview, 15);

            if (customMap.CenterMapToPosition(latitude, longitude, 1))
            {
                customMap.ClearPins();
                customMap.AddPin(latitude, longitude, name, address);
            }
            else
            {
                await DisplayAlert("Error while centering map", customMap.LastError, "Ок");
            }
            //await PointMapOverview.CenterMap(latitude, longitude);

            /*mapControl.RoutePoints = points;
             * var trackPlaces = _vm.GetTrackPlaces();
             * if (trackPlaces.Any())
             * {
             *  await mapControl.UpdateTrackOnMap(trackPlaces);
             * }
             * mapControl.IsShowConnectedRoutePointsLines = !trackPlaces.Any();
             * await mapControl.UpdatePointsOnMap(RoutePoint_MarkerClicked);*/
        }