Beispiel #1
0
 private void Geoposition_PositionChange(object sender, Position e)
 {
     if (e.Success)
     {
         if (_finishposition)
         {
             _finishposition = false;
             if (!_search)
             {
                 GridMap.Children.Clear();
                 var position = new Xamarin.Forms.Maps.Position(e.Latitude, e.Longitude);
                 var map      = new Xamarin.Forms.Maps.Map(Xamarin.Forms.Maps.MapSpan.FromCenterAndRadius(position, Xamarin.Forms.Maps.Distance.FromMiles(0.7)))
                 {
                     IsShowingUser   = true,
                     VerticalOptions = LayoutOptions.FillAndExpand
                 };
                 map.Pins.Clear();
                 var pin = Pin(position, "Tu posición actual");
                 map.Pins.Add(pin);
                 GridMap.Children.Add(map);
                 _finishposition = false;
             }
             else
             {
                 _finishposition = true;
             }
         }
     }
 }
Beispiel #2
0
        private async void BoxSearch_SearchButtonPressed(object sender, EventArgs e)
        {
            SearchText = BoxSearch.Text ?? "";

            if (await this.TextValidate(App.AppName, "Aceptar",
                                        new ValidateItem(SearchText, "Ingresa una dirección")))
            {
                var geoCoder             = new Xamarin.Forms.Maps.Geocoder();
                var approximateLocations = await geoCoder.GetPositionsForAddressAsync(SearchText);

                if (approximateLocations.Count() > 0)
                {
                    _search = true;
                    GridMap.Children.Clear();
                    var location = approximateLocations.ElementAt(0);
                    var map      = new Xamarin.Forms.Maps.Map(Xamarin.Forms.Maps.MapSpan.FromCenterAndRadius(location, Xamarin.Forms.Maps.Distance.FromMiles(0.7)))
                    {
                        IsShowingUser   = true,
                        VerticalOptions = LayoutOptions.FillAndExpand
                    };
                    map.Pins.Clear();
                    var pin = Pin(location, SearchText);
                    map.Pins.Add(pin);
                    GridMap.Children.Add(map);
                }
            }
        }
        public MainViewModel()
        {
            var mapSpan = Xamarin.Forms.Maps.MapSpan.FromCenterAndRadius(new Xamarin.Forms.Maps.Position(50.043604d, 22.0261172d), Xamarin.Forms.Maps.Distance.FromKilometers(3));


            MapControl               = new Xamarin.Forms.Maps.Map(mapSpan);
            MapControl.MapClicked   += MapControl_MapClicked;
            MapControl.IsShowingUser = true;
        }
Beispiel #4
0
        public MapPicker()
        {
            map = new Xamarin.Forms.Maps.Map()
            {
                IsShowingUser     = true,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
            };
            //var location = await locator.GetPositionAsync(TimeSpan.FromTicks(10000));

            //MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromMiles(3)));

            //Position position = new Position(location.La)
            getMyLocation();
            Content = new StackLayout
            {
                Children = { map }
            };
        }
        private async Task InitializeGoogleMap()
        {
            Map = new Xamarin.Forms.Maps.Map();
            Map.HasZoomEnabled = true;
            Map.IsShowingUser  = true;

            var currentLoc = await GetUserLocation();

            if (currentLoc != null)
            {
                var pos = new Xamarin.Forms.Maps.Position(currentLoc.Latitude, currentLoc.Longitude);

                Map.Pins.Add(new Xamarin.Forms.Maps.Pin
                {
                    Label    = $"Here I am",
                    Position = pos,
                });
            }

            //Defaults to current
            //Map.
            Map.MoveToRegion(Xamarin.Forms.Maps.MapSpan.FromCenterAndRadius(
                                 new Xamarin.Forms.Maps.Position(28.644800, 77.216721), Xamarin.Forms.Maps.Distance.FromKilometers(5000)));
        }
Beispiel #6
0
        public FindVenuesControl(bool isMapByDefault = true)
        {
            this.Padding           = new Thickness(0);
            this.RowSpacing        = 0;
            this.ColumnSpacing     = 0;
            this.VerticalOptions   = LayoutOptions.FillAndExpand;
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.BackgroundColor   = Config.ColorGrayBackground;

            /// Map, list
            ///
            this.map = new Xamarin.Forms.Maps.Map()
            {
                HorizontalOptions    = LayoutOptions.FillAndExpand,
                VerticalOptions      = LayoutOptions.FillAndExpand,
                IsShowingUser        = true,
                MinimumHeightRequest = 200,
            };

            this.panelForMap = new Frame()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0),
                BackgroundColor   = Color.Transparent
            };
            this.panelForMap.Content = this.map;

            this.listOfVenuesControl = new ListOfVenuesControl();
            this.listOfVenuesControl.TextForFailedToLoad = ""; // do not show this error text, because this control will show something
            this.listOfVenuesControl.UserClickedOnVenue += (s1, e1) => {
                if (this.UserClickedOnVenue != null)
                {
                    this.UserClickedOnVenue(this, e1);
                }
            };
            this.layoutForTheList = new ScrollView()
            {
                Padding         = new Thickness(0, 0, 0, 0),
                BackgroundColor = Config.ColorGrayBackground,
                Content         = listOfVenuesControl
            };

            this.buttonMapOrList = new BybButton()
            {
                Text              = "Map",
                Style             = (Style)App.Current.Resources["SimpleButtonStyle"],
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
            };
            this.buttonMapOrList.Clicked += (s1, e1) =>
            {
                this.IsShowingMap = !this.IsShowingMap;
            };

            /// Status
            ///

            this.labelStatus = new BybLabel()
            {
                HorizontalOptions       = LayoutOptions.Center,
                VerticalOptions         = LayoutOptions.Center,
                HeightRequest           = 40,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor = Config.ColorBlackTextOnWhite,
                //BackgroundColor = Color.Yellow
            };

            this.panelStatus = new StackLayout
            {
                Orientation         = StackOrientation.Vertical,
                Padding             = new Thickness(0, 5, 0, 5),
                Spacing             = 0,
                MinimumWidthRequest = 300,
                HorizontalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor     = Config.ColorGrayBackground,
                IsVisible           = false,
                Children            =
                {
                    labelStatus
                }
            };

            /// Filters
            ///

            // community
            this.communitySelectorControl = new CommunitySelectorControl();
            this.communitySelectorControl.SelectionChanged += communitySelectorControl_SelectionChanged;

            // search
            this.entrySearch = new BybNoBorderEntry()
            {
                Placeholder       = Config.IsAndroid ? "Search" : "Search by name",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center
            };
            this.entrySearch.TextChanged += (s1, e1) => {
                this.buttonClearFilters.IsVisible = string.IsNullOrEmpty(this.entrySearch.Text) == false;
            };
            this.entrySearch.Completed += (s1, e1) =>
            {
                this.needToSearchAgain = true;
            };
            this.buttonClearFilters = new BybButton()
            {
                Text = "x", IsVisible = false, Style = (Style)App.Current.Resources["SimpleButtonStyle"], WidthRequest = 30
            };
            this.buttonClearFilters.Clicked += (s, e) =>
            {
                this.entrySearch.Text = "";
            };

            /// Content
            ///

            this.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(Config.LargeButtonsHeight * 2 + 10, GridUnitType.Absolute)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(Config.IsTablet ? 50 : 30, GridUnitType.Absolute)
            });
            this.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            this.Children.Add(new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 0,
                Padding     = new Thickness(0, 0, 0, 0),
                Children    =
                {
                    new StackLayout()
                    {
                        Orientation     = StackOrientation.Horizontal,
                        Padding         = new Thickness(0, 5, 0, 5),
                        HeightRequest   = Config.LargeButtonsHeight,//40,
                        Spacing         = 1,
                        BackgroundColor = Config.ColorGrayBackground,
                        Children        =
                        {
                            communitySelectorControl,
                        }
                    },

                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HeightRequest     = Config.LargeButtonsHeight,//40,
                        Padding           = new Thickness(Config.IsIOS ? 15 : 5, 0, 10, 0),
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Spacing           = 1,
                        BackgroundColor   = Config.ColorBackgroundWhite,
                        Children          =
                        {
                            this.entrySearch,
                            this.buttonClearFilters,
                            this.buttonMapOrList,
                        }
                    }
                },
            }, 0, 0);
            this.Children.Add(panelForMap, 0, 1, 1, 3);
            this.Children.Add(layoutForTheList, 0, 1, 1, 3);

            this.Children.Add(panelStatus, 0, 1);

            this.IsShowingMap = isMapByDefault;
        }