Example #1
0
 public static void addCustomMap(CustomMap cm)
 {
     m_customMaps.Add(cm);
     DynamicObjectCreateCallback(cm);                            // takes care of displaying it on LayerCustomMap
 }
Example #2
0
 public MapDelegate(CustomMap formsMap, MKMapView nativeMap)
 {
     this.formsMap  = formsMap;
     this.nativeMap = nativeMap;
 }
Example #3
0
 public IEnumerable <ProductView> GetAll()
 {
     return(_unitOfWork.Products.GetAll().Select(x => CustomMap.GetProductView(x)));
 }
 public HeatMapManager(MapView nativeMap, GoogleMap googleMap, CustomMap formsMap)
     : base(formsMap)
 {
     _nativeMap = nativeMap;
     _googleMap = googleMap;
 }
Example #5
0
        private async void CreateLayout()
        {
            customMap = new CustomMap
            {
                IsShowingUser     = true,
                HeightRequest     = App.ScreenSize.Height / 5,
                WidthRequest      = 960,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var place = locator.GetLocation();

            if (place == null)
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromKilometers(1)));
            }
            else
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(place.Latitude, place.Longitude), Distance.FromKilometers(1)));
            }

            var lastTrail = await apiServices.GetLastTrail();

            if (lastTrail != null)
            {
                if (!String.IsNullOrEmpty(lastTrail.Name))
                {
                    foreach (var poi in lastTrail.Poi)
                    {
                        var pin = new CustomPin()
                        {
                            Position = new Position(poi.Latitude, poi.Longitude),
                            Label    = poi.Type.ToString(),
                            Id       = poi.Type,
                            IconUrl  = poi.IconUlr,
                            Poi      = new POI()
                            {
                                Description = poi.Description,
                                Type        = poi.Type
                            }
                        };

                        pin.InfoClicked += (sender) =>
                        {
                            var pinSelected = sender;
                            Navigation.PushModalAsync(new POIView(pinSelected));
                        };

                        customMap.PinsCoordinates.Add(pin);
                    }

                    foreach (var pos in lastTrail.TrailPath)
                    {
                        customMap.RouteCoordinates.Add(new Position(pos.Latitude, pos.Longitude));
                    }
                }
            }

            lblHour = new Label()
            {
                Text     = "00",
                FontSize = 50
            };
            lblMinute = new Label()
            {
                Text     = "00",
                FontSize = 50
            };
            lblSecond = new Label()
            {
                Text     = "00",
                FontSize = 30
            };

            lblDistace = new Label()
            {
                Text              = "0.0 Km",
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center
            };

            var info = new RaceInfo()
            {
                StartTime   = DateTime.Now,
                Poi         = new System.Collections.Generic.List <POI>(),
                TrailPath   = new System.Collections.Generic.List <Location>(),
                Description = "Esta é minha mais nova trilha! =D",
                Name        = "Nova trilha"
            };
            var state = false;

            btnBegin = new Button()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text            = "Iniciar",
                BackgroundColor = Color.FromHex("#4CAF50"),
                TextColor       = Color.White
            };
            btnBegin.Clicked += async delegate
            {
                state = !state;
                if (state)
                {
                    btnBegin.Text            = "Parar";
                    btnBegin.BackgroundColor = Color.FromHex("#F44336");
                    Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
                    {
                        info.Time = info.Time.AddSeconds(1);

                        lblSecond.Text = info.Time.Second.ToString();
                        lblMinute.Text = info.Time.Minute.ToString();
                        lblHour.Text   = info.Time.Hour.ToString();

                        return(state);
                    });
                }
                else
                {
                    await Navigation.PushAsync(new RunDetailPage(info));

                    state = !state;
                }
            };

            btnDanger = new Button()
            {
                Text              = "SOCORRO!",
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor         = Color.White,
                BackgroundColor   = Color.FromHex("#F44336")
            };
            btnDanger.Clicked += async delegate
            {
                await DisplayAlert("Aguente Firme!", "Não se preocupe!\nOs trilheiros mais próximos a você serão alertados!", "OKAY!");

                intents.Call("192");
            };

            Content = new StackLayout()
            {
                Children =
                {
                    customMap,
                    new StackLayout()
                    {
                        Padding  = new Thickness(5,                             5, 5, 5),
                        Children =
                        {
                            new Frame()
                            {
                                VerticalOptions = LayoutOptions.Center,
                                Content         = new StackLayout()
                                {
                                    Children =
                                    {
                                        new StackLayout()
                                        {
                                            Orientation       = StackOrientation.Horizontal,
                                            VerticalOptions   = LayoutOptions.Center,
                                            HorizontalOptions = LayoutOptions.Center,
                                            Children          =
                                            {
                                                lblHour,
                                                new Label()
                                                {
                                                    Text            = ":",
                                                    FontSize        = 25,
                                                    VerticalOptions = LayoutOptions.Center
                                                },
                                                lblMinute,
                                                new Label()
                                                {
                                                    Text            = ":",
                                                    FontSize        = 25,
                                                    VerticalOptions = LayoutOptions.Center
                                                },
                                                lblSecond
                                            }
                                        },
                                        lblDistace
                                    }
                                }
                            },
                            new StackLayout()
                            {
                                Orientation       = StackOrientation.Horizontal,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                                VerticalOptions   = LayoutOptions.FillAndExpand,
                                Children          =
                                {
                                    new StackLayout()
                                    {
                                        HorizontalOptions = LayoutOptions.FillAndExpand,
                                        VerticalOptions   = LayoutOptions.FillAndExpand,
                                        Children          =
                                        {
                                            btnBegin
                                        }
                                    },
                                    btnDanger
                                }
                            }
                        }
                    }
                }
            };
        }
 public HeatMapManager(MapControl nativeMap, CustomMap formsMap)
     : base(formsMap)
 {
     _nativeMap = nativeMap;
 }
Example #7
0
 public IEnumerable <ArticleView> GetAllArticle()
 {
     return(CustomMap.GetListArticle(repo.Articles.GetList()));
 }
Example #8
0
        public MapPage()
        {
            map = new CustomMap
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            map.Shapes.Add(new List <Position>());
            map.Shapes[0].Add(new Position(33.5, -101.8));
            map.Shapes[0].Add(new Position(33.5, -101.9));
            map.Shapes[0].Add(new Position(33.6, -101.9));
            map.Shapes[0].Add(new Position(33.6, -101.8));

            map.Shapes.Add(new List <Position>());
            map.Shapes[1].Add(new Position(43.5, -101.8));
            map.Shapes[1].Add(new Position(43.5, -101.9));
            map.Shapes[1].Add(new Position(43.6, -101.9));
            map.Shapes[1].Add(new Position(43.6, -101.8));

            map.Shapes.Add(new List <Position>());
            map.Shapes[2].Add(new Position(33.5, -111.8));
            map.Shapes[2].Add(new Position(33.5, -111.9));
            map.Shapes[2].Add(new Position(33.6, -111.9));
            map.Shapes[2].Add(new Position(33.6, -111.8));

            // You can use MapSpan.FromCenterAndRadius

            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(33.57, -101.85), Distance.FromMiles(1000.0)));

            // map terrain buttons
            var Street = new Button
            {
                Text = "Street"
            };
            var Satellite = new Button
            {
                Text = "Satellite"
            };

            Street.Clicked    += HandleClicked;
            Satellite.Clicked += HandleClicked;

            var segments = new StackLayout
            {
                Spacing           = 30,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Children          =
                {
                    Street,
                    Satellite
                }
            };
            // create pin
            var pin = new Pin
            {
                Position = new Position(30.57, -99.85),
                Label    = "Texas"
            };

            pin.Clicked += PinSelect;
            map.Pins.Add(pin);

            // Assemble the page
            var stack = new StackLayout
            {
                Spacing = 0
            };

            stack.Children.Add(map);
            stack.Children.Add(segments);
            //       stack.Children.Add(pin);
            Content = stack;
        }
Example #9
0
        void CreateUI()
        {
            stack = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                WidthRequest    = App.ScreenSize.Width,
                HeightRequest   = App.ScreenSize.Height - 48,
                VerticalOptions = LayoutOptions.StartAndExpand
            };

            innerStack = new StackLayout
            {
                VerticalOptions     = LayoutOptions.Start,
                HorizontalOptions   = LayoutOptions.Start,
                Orientation         = StackOrientation.Horizontal,
                MinimumWidthRequest = App.ScreenSize.Width,
                WidthRequest        = App.ScreenSize.Width,
                HeightRequest       = App.ScreenSize.Height - 48,
                InputTransparent    = true,
            };

            var topbar = new TopBar(true, "", this, 1, "burger_menu", "refresh_icon", innerStack).CreateTopBar();

            stack.HeightRequest = App.ScreenSize.Height - topbar.HeightRequest;

            var spinner = new ActivityIndicator
            {
                BackgroundColor = Color.White,
                HeightRequest   = 40,
                IsRunning       = true
            };

            spinner.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            var map = new CustomMap
            {
                WidthRequest    = App.ScreenSize.Width,
                HeightRequest   = App.ScreenSize.Height,
                VerticalOptions = LayoutOptions.FillAndExpand,
                MapType         = MapType.Hybrid,
            };

            map.RouteCoordinates = ViewModel.LocData;
            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(ViewModel.JourneyData.GPSData[0].Latitude, ViewModel.JourneyData.GPSData[0].Longitude), Distance.FromMiles(1)));
            map.CustomPins = new List <CustomPin>();
            if (ViewModel.JourneyEvents != null)
            {
                if (ViewModel.JourneyEvents.Count != 0)
                {
                    foreach (var je in ViewModel.JourneyEvents)
                    {
                        var pin = new CustomPin
                        {
                            Pin = new Pin
                            {
                                Position = new Position(je.Latitude, je.Longitude),
                                Type     = PinType.Place,
                                Address  = je.Location.Replace('\n', ' '),
                                Label    = $"Speed {je.Speed} (Road speed {je.RoadSpeed})"
                            },
                            Id = je.Id.ToString()
                        };
                        map.CustomPins.Add(pin);
                        map.Pins.Add(pin.Pin);
                    }
                }
            }

            stack.Children.Add(spinner);
            stack.Children.Add(map);
            innerStack.Children.Add(stack);

            var masterStack = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                WidthRequest    = App.ScreenSize.Width,
                VerticalOptions = LayoutOptions.Start,
                Spacing         = 0,
                Children        =
                {
                    topbar,
                    new StackLayout
                    {
                        Children = { innerStack }
                    }
                }
            };

            Content = masterStack;
        }
Example #10
0
 public void doSomething(CustomMap myMap)
 {
     MessagingCenter.Send <CustomMap>(this, "Hi");
 }
        private void inicializarComponente()
        {
            _AcaoButton = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Margin            = new Thickness(8, 0),
                Style             = Estilo.Current[Estilo.BTN_PRINCIPAL],
                Text = (_Situacao == FreteSituacaoEnum.PegandoEncomenda ? "Peguei a encomenda" : "Entreguei a encomenda")
            };
            _AcaoButton.Clicked += (sender, e) => {
                confirmaPegaEntregaAsync();
            };

            _AbrirRota = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Margin            = new Thickness(8, 0),
                Style             = Estilo.Current[Estilo.BTN_PRINCIPAL],
                Text = "Ver rota externamente"
            };
            _AbrirRota.Clicked += (sender, e) => {
                _PickerRota.Focus();
            };

            _PickerRota = new Picker()
            {
                ItemsSource = new List <string>()
                {
                    "Waze",
                    "Maps"
                },
                HeightRequest = 0,
                IsVisible     = false
            };
            _PickerRota.SelectedIndexChanged += async(sender2, e2) =>
            {
                UserDialogs.Instance.ShowLoading("Aguarde...");
                var infoEntrega = await FreteFactory.create().pegar(_IdFrete);

                UserDialogs.Instance.HideLoading();
                switch ((string)_PickerRota.SelectedItem)
                {
                case "Maps":
                    Device.OpenUri(new Uri("http://maps.google.com/maps?daddr=" + infoEntrega.EnderecoDestino));
                    break;

                case "Waze":
                    Device.OpenUri(new Uri("waze://?q=" + infoEntrega.EnderecoDestino));
                    break;
                }
            };

            _ContatoButton = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Margin            = new Thickness(8, 0),
                Style             = Estilo.Current[Estilo.BTN_PRINCIPAL],
                Text = "Ver dados do pedido"
            };
            _ContatoButton.Clicked += (sender, e) => {
                mostraDadosEntrega();
            };


            _Distancia = new Label()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                HeightRequest     = 22,
                Margin            = new Thickness(8, 0),
                FontSize          = 18,
                TextColor         = Color.Black
            };
            _Tempo = new Label()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Margin            = new Thickness(8, 0),
                HeightRequest     = 22,
                FontSize          = 18,
                TextColor         = Color.Black
            };

            _CustomMap = new CustomMap
            {
                MapType           = MapType.Street,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Fill,
                IsShowingUser     = true
            };
        }
Example #12
0
 public ResponderManager(MapControl nativeMap, CustomMap formsMap, RouteManager routeManager, PushpinManager pushpinManager)
     : base(formsMap, routeManager, pushpinManager)
 {
     _nativeMap = nativeMap;
 }
Example #13
0
 public GameObjectEditorHandler(CustomMap map) : base(map)
 {
 }
Example #14
0
 public static void deleteCustomMap(CustomMap cm)
 {
     DynamicObjectDeleteCallback(cm);
     m_customMaps.Remove(cm);
     cm.cleanup();
 }
Example #15
0
        private void inicializarComponente()
        {
            _mainLayout = new AbsoluteLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            _mapaLayout = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Spacing           = 0
            };
            AbsoluteLayout.SetLayoutBounds(_mapaLayout, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(_mapaLayout, AbsoluteLayoutFlags.All);
            _mainLayout.Children.Add(_mapaLayout);

            _barraLateralLayout = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Spacing           = 4,
                //BackgroundColor = Color.Green
            };
            AbsoluteLayout.SetLayoutBounds(_barraLateralLayout, new Rectangle(0.98, 0.5, 0.2, 0.6));
            AbsoluteLayout.SetLayoutFlags(_barraLateralLayout, AbsoluteLayoutFlags.All);
            _mainLayout.Children.Add(_barraLateralLayout);

            _palavraChaveSearchBar = new SearchBar()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                BackgroundColor   = Color.White,
                Placeholder       = "Pesquisar...",
                FontSize          = 20,
                HeightRequest     = 42
            };
            _palavraChaveSearchBar.SearchButtonPressed += async(sender, e) => {
                await buscarLocalporPalavraChave(_palavraChaveSearchBar.Text);
            };

            _mapaLayout.Children.Add(_palavraChaveSearchBar);
            _mapaLayout.Children.Add(new BoxView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                BackgroundColor   = Estilo.Current.PrimaryColor,
                HeightRequest     = 1
            });

            _resultadoBuscaListView = new ListView {
                HasUnevenRows = true,
                RowHeight     = -1,
                //SeparatorVisibility = SeparatorVisibility.None,
                SeparatorVisibility = SeparatorVisibility.Default,
                SeparatorColor      = Estilo.Current.PrimaryColor,
                ItemTemplate        = new DataTemplate(typeof(ResultadoBuscaCell))
            };
            _resultadoBuscaListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
            _resultadoBuscaListView.ItemTapped += resultadoBuscaItemTapped;

            _Mapa = new CustomMap()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                IsShowingUser     = false
            };
            _Mapa.aoClicar += (sender, e) => {
                try
                {
                    fixarPontoNoMapa(new Pin
                    {
                        Type     = PinType.Place,
                        Position = e.Position,
                        Label    = TituloPadrao,
                        Address  = TituloPadrao
                    });
                }
                catch (Exception erro)
                {
                    UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi");
                }
            };
            _mapaLayout.Children.Add(_Mapa);

            _excluirPontoButton = new CircleIconButton
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                BackgroundColor   = Estilo.Current.DangerColor,
                TextColor         = Color.White,
                WidthRequest      = 50,
                HeightRequest     = 50,
                FontSize          = 22,
                BorderRadius      = 50,
                Text = "fa-remove"
            };
            _excluirPontoButton.Clicked += (sender, e) => {
                try
                {
                    if (_Mapa.Pins.Count() > 0)
                    {
                        var pins = new List <Pin>();
                        foreach (var pin in _Mapa.Pins)
                        {
                            pins.Add(pin);
                        }
                        pins.RemoveAt(pins.Count() - 1);
                        if (pins.Count() > 0)
                        {
                            var pin = pins[pins.Count() - 1];
                            _Mapa.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.5)));
                        }
                        _Mapa.Pins.Clear();
                        foreach (var pin in pins)
                        {
                            _Mapa.Pins.Add(pin);
                        }
                        _Mapa.Polyline = Polyline;
                    }
                }
                catch (Exception erro)
                {
                    UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi");
                }
            };
            _barraLateralLayout.Children.Add(_excluirPontoButton);

            _limparButton = new CircleIconButton
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                BackgroundColor   = Estilo.Current.WarningColor,
                TextColor         = Color.White,
                WidthRequest      = 50,
                HeightRequest     = 50,
                FontSize          = 22,
                BorderRadius      = 50,
                Text = "fa-trash"
            };
            _limparButton.Clicked += async(sender, e) => {
                if (await UserDialogs.Instance.ConfirmAsync("Deseja limpar a rota?", "Aviso", "Sim", "Não"))
                {
                    try {
                        _Mapa.Pins.Clear();
                        _Mapa.Polyline = Polyline;
                    }
                    catch (Exception erro) {
                        UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi");
                    }
                }
            };
            _barraLateralLayout.Children.Add(_limparButton);

            _visualizarButton = new CircleIconButton
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                BackgroundColor   = Estilo.Current.SuccessColor,
                TextColor         = Color.White,
                WidthRequest      = 50,
                HeightRequest     = 50,
                FontSize          = 22,
                BorderRadius      = 50,
                Text = "fa-eye"
            };
            _visualizarButton.Clicked += (sender, e) => {
                try
                {
                    _Mapa.zoomPolyline(true);
                }
                catch (Exception erro) {
                    UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi");
                }
            };
            _barraLateralLayout.Children.Add(_visualizarButton);

            _confirmarButton = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.End,
                BackgroundColor   = Estilo.Current.PrimaryColor,
                TextColor         = Color.White,
                BorderRadius      = 45,
                Text = "Confirmar"
            };
            _confirmarButton.Pressed += (sender, e) => {
                if (_Mapa.Pins.Count() >= 2)
                {
                    AoSelecionar?.Invoke(this, Polyline);
                }
                else
                {
                    DisplayAlert("Atenção", "Você precisa selecionar pelomenos uma origem e um destino.", "Entendi");
                }
            };
            AbsoluteLayout.SetLayoutBounds(_confirmarButton, new Rectangle(0.5, 0.98, 0.5, 0.1));
            AbsoluteLayout.SetLayoutFlags(_confirmarButton, AbsoluteLayoutFlags.All);
            _mainLayout.Children.Add(_confirmarButton);
        }
Example #16
0
 public CellEditorHandler(CustomMap map) : base(map)
 {
 }
Example #17
0
        static async void TrackingLoop()
        {
            Trkr.RestServices.RestService _restService;
            _restService = new Trkr.RestServices.RestService();

            CustomMap iCustomMap   = new CustomMap();
            CustomMap havetoListTo = new CustomMap();

            while (true)
            {
                LocationData locationParameter = null;


                try
                {
                    var      request  = new GeolocationRequest(GeolocationAccuracy.Best);
                    Location location = await Geolocation.GetLocationAsync(request);

                    if (location != null)
                    {
                        Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                        locationParameter = new LocationData
                        {
                            Guid      = Guid.NewGuid(),
                            Latitude  = location.Latitude,
                            Longitude = location.Longitude,
                            Velocity  = (double)location.Speed,
                            Timestamp = DateTime.Now.ToString(),
                            UserId    = App.logedInUser.Email
                        };
                    }


                    // chechs if i moving faster than 1 m/s^
                    if (locationParameter.Velocity > 1)
                    {
                        LocationData locationData = await _restService.CreateLocation(GenerateLocationUri(Constants.locationAdress), locationParameter);

                        iCustomMap.RouteCoordinates.Add(new Position(locationParameter.Latitude, locationParameter.Longitude));
                        iCustomMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(locationParameter.Latitude, locationParameter.Longitude), Distance.FromKilometers(1.5)));

                        havetoListTo.RouteCoordinates.Add(new Position(locationParameter.Latitude, locationParameter.Longitude));
                    }
                }

                catch (FeatureNotSupportedException fnsEx)
                {
                    // Handle not supported on device exception
                }
                catch (FeatureNotEnabledException fneEx)
                {
                    // Handle not enabled on device exception
                }
                catch (PermissionException pEx)
                {
                    // Handle permission exception
                }
                catch (Exception ex)
                {
                    // Unable to get location
                }

                await Task.Delay(10000);
            }


            string GenerateLocationUri(string endpoint)
            {
                string requestUri = endpoint;

                requestUri += $"?apiKey={Constants.APIKey}";

                return(requestUri);
            }
        }
Example #18
0
        private void inicializarComponente()
        {
            _BarraBusca = new SearchBar()
            {
                BackgroundColor = Color.White,
                Placeholder     = "Pesquisar...",
                HeightRequest   = 42
            };
            _BarraBusca.SearchButtonPressed += (sender, e) => {
                iniciaBuscaAsync();
            };

            _Mapa = new CustomMap()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                IsShowingUser     = true
            };
            _Mapa.aoClicar += (sender, e) => {
                pegarManualAsync(e.Position);
            };

            _EntregarButton = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Style             = Estilo.Current[Estilo.BTN_PRINCIPAL],
                Text = "Confirmar"
            };
            _EntregarButton.Pressed += (sender, e) => {
                if (_Mapa.Pins.Count() > 0)
                {
                    _ponto.Text    = _Mapa.Pins.First().Address;
                    _ponto.Posicao = _Mapa.Pins.First().Position;
                    if (_ponto.Tipo == TipoPontoTransporteEnum.Add)
                    {
                        _ponto.Tipo = TipoPontoTransporteEnum.Trecho;
                        _Pai.Add(new PontoTransporteInfo()
                        {
                            Text = "", Tipo = TipoPontoTransporteEnum.Add
                        });
                    }
                    _ListaLocais.ItemsSource = null;
                    _ListaLocais.ItemsSource = _Pai;
                    Navigation.PopAsync();
                }
                else
                {
                    DisplayAlert("Atenção", "Selecione um ponto", "Entendi");
                }
            };
            _LocaisLista = new ListView();
            _LocaisLista.HasUnevenRows = true;
            _LocaisLista.RowHeight     = -1;
            _LocaisLista.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
            _LocaisLista.ItemTemplate = new DataTemplate(typeof(ResultadoBuscaCell));
            _LocaisLista.ItemTapped  += async(sender, e) =>
            {
                if (e == null)
                {
                    return;
                }
                var item = (PesquisaLocalizacaoInfo)((ListView)sender).SelectedItem;
                if (_ListaNaTela)
                {
                    _ListaNaTela = false;
                    ((StackLayout)this.Content).Children.Remove((_LocaisLista));
                    ((StackLayout)this.Content).Children.Add((_Mapa));
                    ((StackLayout)this.Content).Children.Add((_EntregarButton));
                }
                UserDialogs.Instance.ShowLoading("Carregando...");
                using (var client = new HttpClient())
                {
                    HttpResponseMessage response = await client.GetAsync(HttpUtils.montaLinkGet(
                                                                             "https://maps.googleapis.com/maps/api/geocode/json",
                                                                             new List <KeyValuePair <string, string> >()
                    {
                        new KeyValuePair <string, string>("address", item.Text),
                        new KeyValuePair <string, string>("key", "AIzaSyCYqp1ZAiX0M8Lqth1kFYRh6wju0Y4vAm8")
                    }
                                                                             ));

                    response.EnsureSuccessStatusCode();
                    var strResposta = await response.Content.ReadAsStringAsync();

                    var retGeocoder = JsonConvert.DeserializeObject <GoogleGeocodingInfo>(strResposta);
                    UserDialogs.Instance.HideLoading();
                    if (retGeocoder != null && retGeocoder.status == "OK")
                    {
                        var mapaPosicao = new Position(retGeocoder.results.First().geometry.location.lat, retGeocoder.results.First().geometry.location.lng);
                        _Mapa.MoveToRegion(MapSpan.FromCenterAndRadius(mapaPosicao, Distance.FromMiles(0.3)));
                        var pin = new Pin
                        {
                            Type     = PinType.Place,
                            Position = mapaPosicao,
                            Label    = "Partida",
                            Address  = item.Text
                        };
                        _Mapa.Pins.Clear();
                        _Mapa.Pins.Add(pin);
                    }
                    else
                    {
                        await DisplayAlert("Falha", "Ocorreu uma falha, tente novamente.", "Entendi");
                    }
                }
            };
        }
Example #19
0
 public IEnumerable <WriterView> GetList()
 {
     return(CustomMap.GetListWriter(repo.Writers.GetList()));
 }
Example #20
0
        public void AddStuffToList(List <Polygon> shapes, List <ParkingLotInfo> LotList, CustomMap map)
        {
            // List of polygons
            shapes.Add(lotA);
            shapes.Add(lotB);
            shapes.Add(lotC);
            shapes.Add(lotD);
            shapes.Add(lotE);
            shapes.Add(lotF);
            shapes.Add(lotG);
            shapes.Add(lotH);
            shapes.Add(lotK);
            shapes.Add(lotL);
            shapes.Add(lotN);
            // Pins
            map.Pins.Add(pinA);
            map.Pins.Add(pinB);
            map.Pins.Add(pinC);
            map.Pins.Add(pinD);
            map.Pins.Add(pinE);
            map.Pins.Add(pinF);
            map.Pins.Add(pinG);
            map.Pins.Add(pinH);
            map.Pins.Add(pinK);
            map.Pins.Add(pinL);
            map.Pins.Add(pinN);
            // Database values: Name, TotalCapacity, CurrentCapacity
            //LotList.Add(L_Lot);
            //LotList.Add(A_Lot);
            //LotList.Add(K_Lot);
            //LotList.Add(B_Lot);
            //LotList.Add(C_Lot);
            //LotList.Add(D_Lot);
            //LotList.Add(F_Lot);
            //LotList.Add(G_Lot);
            //LotList.Add(H_Lot);
            //LotList.Add(E_Lot);
            //LotList.Add(N_Lot);

            // Polygons being added to map
            map.MapElements.Add(lotA);
            map.MapElements.Add(lotB);
            map.MapElements.Add(lotC);
            map.MapElements.Add(lotD);
            map.MapElements.Add(lotE);
            map.MapElements.Add(lotF);
            map.MapElements.Add(lotG);
            map.MapElements.Add(lotH);
            map.MapElements.Add(lotK);
            map.MapElements.Add(lotL);
            map.MapElements.Add(lotN);
            // Adds Pins to List of Pins
            PinList.Add(pinA);
            PinList.Add(pinB);
            PinList.Add(pinC);
            PinList.Add(pinD);
            PinList.Add(pinE);
            PinList.Add(pinF);
            PinList.Add(pinG);
            PinList.Add(pinH);
            PinList.Add(pinK);
            PinList.Add(pinL);
            PinList.Add(pinN);
        }
Example #21
0
 public IEnumerable <BookView> GetAllBook()
 {
     return(CustomMap.GetListBook(repo.Books.GetList()));
 }
Example #22
0
 protected AbstractHeatMapManager(CustomMap formsMap)
 {
     FormsMap = formsMap;
 }
Example #23
0
 public RouteManager(GoogleMap nativeMap, CustomMap formsMap, MarkerManager pushpinManager)
     : base(formsMap, pushpinManager)
 {
     _nativeMap = nativeMap;
 }
 public ResponderManager(MKMapView nativeMap, CustomMap formsMap, RouteManager routeManager, AnnotationManager annotationManager)
     : base(formsMap, routeManager, annotationManager)
 {
     _nativeMap = nativeMap;
 }
Example #25
0
 protected AbstractPushpinManager(CustomMap formsMap)
 {
     FormsMap = formsMap;
 }
Example #26
0
        public MapPage()
        {
            Title     = "Mapa";
            customMap = new CustomMap
            {
                IsShowingUser     = true,
                HeightRequest     = 100,
                WidthRequest      = 960,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            // Custom Pin
            var pin = new CustomPin()
            {
                Position = new Position(-23.359233, -46.735372),
                Label    = "Teste",
                Address  = "Teste",
                Id       = DataAndHelper.Data.PinType.Danger,
                IconUrl  = DataAndHelper.Data.DANGER_MAP_ICON,
                Poi      = new POI()
                {
                    Description = "Aviso de perigo na trilha, esse aviso pode ser de extrema importância para perigos na trilha",
                    Type        = DataAndHelper.Data.PinType.Danger
                }
            };

            pin.InfoClicked += (sender) =>
            {
                var pinSelected = sender;
                Navigation.PushModalAsync(new POIView(pinSelected));
            };

            customMap.PinsCoordinates = new List <CustomPin> {
                pin
            };
            customMap.Pins.Add(pin);

            var place = locator.GetLocation();

            if (place == null)
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromKilometers(1)));
            }
            else
            {
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(place.Latitude, place.Longitude), Distance.FromKilometers(1)));
            }

            btnShowLocation = new Button()
            {
                Text = "Get My Location"
            };
            btnShowLocation.Pressed += delegate
            {
                place = locator.GetLocation();
                if (place == null)
                {
                    DisplayAlert("Localização", "Localização não disponivel", "Kay");
                }
                else
                {
                    DisplayAlert("Localização", "Latitude = " + place.Latitude + "\nLongitude = " + place.Longitude, "Kay");
                }
            };

            // put the page together
            var stack = new StackLayout {
                Spacing = 0
            };

            stack.Children.Add(customMap);
            stack.Children.Add(btnShowLocation);

            Content = stack;
        }
Example #27
0
        public MapPage(Bid bid)
        {
            _bidsService = DependencyService.Get <IBidsService>();

            _bidsService.Token = new UserToken
            {
                Token = (string)App.User.UserToken.Token.Clone()
            };


            _map = new CustomMap
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                HasZoomEnabled  = true,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            _map.Pins.Add(new Pin
            {
                Label    = "Тревога",
                Position = new Position(bid.Location.Latitude, bid.Location.Longitude)
            });

            // You can use MapSpan.FromCenterAndRadius
            //map.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (37, -122), Distance.FromMiles (0.3)));
            // or create a new MapSpan object directly
            double degrees = 360 / Math.Pow(2, 14);

            _map.ZoomLevel = new Distance(250);
            _map.MoveToRegion(new MapSpan(new Position(bid.Location.Latitude, bid.Location.Longitude), degrees, degrees));

            // create map style buttons
            var street = new Button {
                Text = "Street"
            };
            var hybrid = new Button {
                Text = "Hybrid"
            };
            var satellite = new Button {
                Text = "Satellite"
            };

            street.Clicked    += HandleClicked;
            hybrid.Clicked    += HandleClicked;
            satellite.Clicked += HandleClicked;
            var segments = new StackLayout
            {
                Spacing           = 30,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Children          = { street, hybrid, satellite }
            };

            // put the page together
            var stack = new StackLayout {
                Spacing = 0
            };

            stack.Children.Add(_map);
            stack.Children.Add(segments);
            Content = stack;

            Timer timer = new Timer(UpdateAlertLocation, bid, 0, 10000);
        }
Example #28
0
 protected AbstractRouteManager(CustomMap formsMap, AbstractPushpinManager pushpinManager)
 {
     FormsMap       = formsMap;
     PushpinManager = pushpinManager;
     _routeUpdater  = new RoutesUpdater();
 }
        public RequestDrive()
        {
            InitializeComponent();



            var customMap = new CustomMap
            {
                MapType = MapType.Hybrid,
            };

            var position1 = new Position(36.8961, 10.1865);
            var position2 = new Position(36.891, 10.181);
            var position3 = new Position(36.892, 10.182);
            var position4 = new Position(36.893, 10.183);
            var position5 = new Position(36.891, 10.185);
            var position6 = new Position(36.892, 10.187);

            var customPin1 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.Place,
                    Position = position1,
                    Label    = "IntilaQ",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.intilaq.tn",
            };


            var customPin2 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.SearchResult,
                    Position = position2,
                    Label    = "Telnet R&D",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.groupe-telnet.com"
            };

            var customPin3 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.SearchResult,
                    Position = position3,
                    Label    = "Kromberg&Schubert",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.kromberg-schubert.com"
            };

            var customPin4 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.SearchResult,
                    Position = position4,
                    Label    = "Via Mobile",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.kromberg-schubert.com"
            };

            var customPin5 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.SearchResult,
                    Position = position5,
                    Label    = "Via Mobile",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.kromberg-schubert.com"
            };

            var customPin6 = new CustomPin
            {
                Pin = new Pin
                {
                    Type     = PinType.SearchResult,
                    Position = position6,
                    Label    = "Via Mobile",
                    Address  = "Technopark Elgazala, Tunisia"
                },
                Url = "www.kromberg-schubert.com"
            };

            customMap.CustomPins = new List <CustomPin>
            {
                customPin1,
                customPin2,
                customPin3,
                customPin4,
                customPin5,
                customPin6,
            };

            var Pin = new Pin
            {
                Type     = PinType.SearchResult,
                Position = position6,
                Label    = "Via Mobile",
                Address  = "Technopark Elgazala, Tunisia"
            };


            customMap.Pins.Add(Pin);
            //CustomPin p = new CustomPin();
            //p.Pin();
            //customMap.CustomPins();
            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(
                                       new Position(36.8961, 10.1865), Distance.FromMiles(0.5)));

            Content = customMap;
            // MainMap = customMap;
        }
Example #30
0
 public static void AddCustomMap(CustomMap cm)
 {
     m_customMaps.Add(cm);
 }