예제 #1
0
        public RouteViewModel()
        {
            HttpResponseMessage response;
            WebApiHelper        skladisteService = new WebApiHelper("http://localhost:2618/", "api/Skladista");
            List <Skladista>    skla             = new List <Skladista>();


            response = skladisteService.GetResponse();
            if (response.IsSuccessStatusCode)
            {
                skla = response.Content.ReadAsAsync <List <Skladista> >().Result;
            }

            _locations = new ObservableCollection <Location>();

            foreach (Skladista x in skla)
            {
                if (x.Latitude != null && x.Longitude != null)
                {
                    Location a = new Location(x.Naziv, x.Adresa, new Position(Convert.ToDouble(x.Longitude), Convert.ToDouble(x.Latitude)));

                    _locations.Add(a);
                }
                Skladistalist.Add(x);
            }
            mapa            = new Xamarin.Forms.Maps.Map();
            services        = new OSRMRouteService();
            dr              = new RouteHlpClass();
            GetRouteCommand = new Command(async() => await loadRouteAsync(Skladiste, Destinacija));
            RouteDistance   = RouteDuration = "0";
        }
예제 #2
0
        public MapPage()
        {
            InitializeComponent();


            _restService = new Trkr.RestServices.RestService();

            // create Map to view!
            var map = new Xamarin.Forms.Maps.Map(
                MapSpan.FromCenterAndRadius(
                    // ZHAW Winterthur 47.496848 / 8.729818
                    new Position(47.496848, 8.729818), Distance.FromKilometers(0.45)))
            {
                IsShowingUser = true,
                // note sure if Height and WidthRequest is necessary
                //HeightRequest = 100,
                //WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };


            if (IsLocationAvailable())
            {
                GetPosition();
                //map.MoveToRegion(MapSpan.FromCenterAndRadius(_position, Distance.FromKilometers(0.45)));
            }
            map.MapType = MapType.Street;
            var stack = new StackLayout {
                Spacing = 0
            };

            stack.Children.Add(map);
            Content = stack;
        }
예제 #3
0
        public MapPage()
        {
            InitializeComponent();
            CAPI = new CovidAPI();
            map  = new Xamarin.Forms.Maps.Map();
            map.HasZoomEnabled   = false;        //disable zoom on the map
            map.HasScrollEnabled = false;        //disable Scroll on the map
            map.Pins.Clear();                    // clear all the pins form the map

            mainStackLayout = new StackLayout(); // the main layout

            country = new Entry
            {
                Placeholder      = "Enter in the Country",
                PlaceholderColor = Color.Olive
            };
            findLocationBTN = new Button
            {
                Text = "Check Covid-19 in this Country"
            };
            findLocationBTN.Clicked += getLoction; // get the country location

            // add all the elements to the main layout
            mainStackLayout.Children.Add(map);
            mainStackLayout.Children.Add(country);
            mainStackLayout.Children.Add(findLocationBTN);

            Content = mainStackLayout; // add main layout to the page

            // Thread.Sleep(2000);
            // _ = FindTheLocation("", "", "New Zealand");
        }
예제 #4
0
        public MapPage(string latitude, string longitude)
        {
            _latitude  = (Convert.ToDouble(latitude));
            _longitude = (Convert.ToDouble(longitude));

            var map55 = new Xamarin.Forms.Maps.Map(
                MapSpan.FromCenterAndRadius(
                    new Position(Convert.ToDouble(latitude), Convert.ToDouble(longitude)), Distance.FromMiles(0.3)))
            {
                IsShowingUser   = true,
                HeightRequest   = 100,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var btn = new Button();

            btn.Text = "Save Favorite";
            var stack = new StackLayout {
                Spacing = 0
            };

            stack.Children.Add(map55);
            stack.Children.Add(btn);
            btn.Clicked += Btn_Clicked1;;
            Content      = stack;
        }
예제 #5
0
        async Task CrearMapa()
        {
            var nombrePueblo = txtNombre.Text;

            if (string.IsNullOrEmpty(nombrePueblo))
            {
                UserDialogs.Instance.Alert(Constantes.TitlePuebloRequired +
                                           " A continuación guarde el nombre antes de empezar a " +
                                           "crear contenido.", "Advertencia", "OK");
                return;
            }
            MapSpan mapSpan = await GeocoderPueblo();

            Mapa = new Map(mapSpan)
            {
                WidthRequest     = -1,
                HeightRequest    = 350,
                HasScrollEnabled = true,
                HasZoomEnabled   = true
            };
            Pin pin = new Pin
            {
                Label    = nombrePueblo,
                Type     = PinType.Place,
                Position = mapSpan.Center
            };

            Mapa.Pins.Add(pin);
            stackMapa.Children.Add(Mapa);
        }
예제 #6
0
        public KataU()
        {
            InitializeComponent();

            var mapa = new Map(MapSpan.FromCenterAndRadius(new Position(37.393355, -5.983900), Distance.FromMiles(1)))
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var pFesac       = new Position(37.371861, -5.999654);
            var pcampoFutbol = new Position(37.384217, -5.993467);
            var pin1         = new Pin
            {
                Type     = PinType.Place,
                Position = pFesac,
                Label    = "Fesac"
            };
            var pin2 = new Pin
            {
                Type     = PinType.Place,
                Position = pcampoFutbol,
                Label    = "Campo Futbol"
            };

            mapa.Pins.Add(pin1);
            mapa.Pins.Add(pin2);
            mapaLayout.Children.Add(mapa);
        }
예제 #7
0
        async void GetCashPoints()
        {
            var location = await Geolocation.GetLastKnownLocationAsync();

            MyLat  = location.Latitude;
            MyLong = location.Longitude;

            CashPoints = await accountsManager.GetCashPointsAsync();

            CashPointsMap = new Xamarin.Forms.Maps.Map();

            if (CashPoints != null)
            {
                foreach (var cashpoint in CashPoints)
                {
                    // Place a pin on the map for each cash point
                    CashPointsMap.Pins.Add(new Pin
                    {
                        Type     = PinType.Place,
                        Label    = cashpoint.AccountName,
                        Position = new Position(cashpoint.Latitude, cashpoint.Longitude)
                    });
                }
            }
            // Center the map around the list of walks entry's location
            CashPointsMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(MyLat, MyLong), Distance.FromKilometers(1.0)));
        }
예제 #8
0
        public MainPage()
        {
            GetGeo += MainPage_GetGeo;
            GetGeo?.Invoke(this, EventArgs.Empty);
            InitializeComponent();
            // var res = await GeoAsync();
            var map = new Xamarin.Forms.Maps.Map(MapSpan.FromCenterAndRadius(new Position(coordinate[0], coordinate[1]), Distance.FromMiles(1))); //можно задать местоположение человека, допилим потом

            Content = map;
            string jsonString = FileReader();
            var    data       = JsonConvert.DeserializeObject <Data>(jsonString);
            List <ConnectionWithDataBase> connection = data.Parse();
            double x                = 55.702845;
            double y                = 37.530651;
            string name             = "Moscow State University";
            int    numberOfBuidings = (int)data.count;

            map.IsShowingUser = true;
            foreach (ConnectionWithDataBase db in connection)
            {
                x    = db.x;
                y    = db.y;
                name = db.name;
                var pin = new Pin()
                {
                    Position = new Position(x, y),
                    Label    = name,
                };
                pins.Add(pin);
                pin.MarkerClicked += Pin_MarkerClicked;
                map.Pins.Add(pin);
            }
        }
예제 #9
0
        public MapPage()
        {
            InitializeComponent();

            var position = new Position(49.673971, 20.079831);

            map = new CustomMap(MapSpan.FromCenterAndRadius(position, Distance.FromMiles(0.5f)))
            {
                WidthRequest  = Application.Current.MainPage.Width,
                IsShowingUser = true
            };
            InitPins();
            GridLayout.Children.Add(map, 0, 1);
            Grid.SetColumnSpan(map, 3);

            if (App.Logged)
            {
                menuButton = new ImageButton
                {
                    Source          = "menu_icon.png",
                    Padding         = new Thickness(0, 18),
                    BackgroundColor = Color.Transparent
                };
                menuButton.Clicked += OnMenu;
                GridLayout.Children.Add(menuButton, 2, 0);
            }

            GetLocation();
        }
예제 #10
0
        public MapPage()
        {
            Xamarin.Forms.Maps.Map map = new Xamarin.Forms.Maps.Map();
            Content = map;

            /* this was to be used for showing pins with an image
             * CustomMap customMap = new CustomMap
             * {
             *  MapType = MapType.Street,
             *  WidthRequest = 8,
             *  HeightRequest=8
             * };
             *
             * var pin = new CustomPin
             * {
             *  Type = PinType.Place,
             *  Position = new Position(currentlocation.Latitude, currentlocation.Longitude),
             *  Label = "Current Location"
             *
             * };
             * customMap.CustomPins = new List<CustomPin> { pin };
             * customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(currentlocation.Latitude, currentlocation.Longitude), Distance.FromMiles(1.0)));
             *
             * Content = customMap;
             */
        }
예제 #11
0
        public static async void CenterOnCurrentLocation(this Map map)
        {
            try
            {
                var currentLocation = await Geolocation.GetLastKnownLocationAsync();

                if (currentLocation == null)
                {
                    var locationRequest = new GeolocationRequest(GeolocationAccuracy.Medium);
                    currentLocation = await Geolocation.GetLocationAsync(locationRequest);
                }

                var currentPosition = new Position(currentLocation.Latitude, currentLocation.Longitude);
                var mapSpan         = MapSpan.FromCenterAndRadius(currentPosition, Distance.FromMiles(1));
                map.MoveToRegion(mapSpan);
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                return;
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                return;
            }
            catch (Exception ex)
            {
                // Unable to get location
                return;
            }
        }
예제 #12
0
        public static void SetDefaultView(this Map map)
        {
            var defaultMapCenter = new Position(40, -95);
            var defaultMapSpan   = MapSpan.FromCenterAndRadius(defaultMapCenter, Distance.FromMiles(500));

            map.MoveToRegion(defaultMapSpan);
        }
 public CreateStopViewModel()
 {
     Map                = new Xamarin.Forms.Maps.Map();
     Map.MapClicked    += Map_Clicked;
     Map.MapType        = MapType.Street;
     Map.HasZoomEnabled = true;
     Map.IsShowingUser  = true;
 }
예제 #14
0
 public MapsViewModel()
 {
     Visible = false;
     MainMap = new Xamarin.Forms.Maps.Map()
     {
         IsShowingUser = true
     };
 }
예제 #15
0
        public MapViewModel(Xamarin.Forms.Maps.Map map, IEnumerable itemsSource, SearchBar searchBar)
        {
            this.map        = map;
            sB              = searchBar;
            currentProducts = (IEnumerable <Product>)itemsSource;

            ExecuteLoadPinsCommand();
        }
예제 #16
0
 public AbsenViewModel(Xamarin.Forms.Maps.Map mapView)
 {
     ViewCommand  = new Command(() => { Shell.Current.Navigation.PushAsync(new AbsenView()); });
     AbsenCommand = new Command(AbsenAction, CanAAbsen);
     map          = mapView;
     CrossGeolocator.Current.PositionChanged += Current_PositionChanged;
     Load();
 }
예제 #17
0
 public CustomerProfileViewModel(Xamarin.Forms.Maps.Map map, Customer cust)
 {
     IsBusy             = true;
     SaveCommand        = new Command(SaveAction);
     SetLocationCommand = new Command(SetLocation);
     _map  = map;
     Model = cust;
     Load();
 }
        public void InitializeMap(Xamarin.Forms.Maps.Map map)
        {
            map.MapType = MapType.Street;
            Position point   = new Position(37.334789, -121.888138);
            var      mapSpan = new MapSpan(point, 5, 5);

            map.MoveToRegion(mapSpan);
            map.Pins.Clear();
        }
예제 #19
0
        public AddItemViewModel(Map map)
        {
            LoadPin   = new Command(async() => await RunPin());
            Place     = new CreatePlaceRequest();
            image     = new ImageItem();
            byteimage = new byte[4];

            Map = map;
            LoadPin.Execute(null);
        }
        public void GetData()
        {
            mapPosition = new Position(userLocation.Latitude, userLocation.Longitude);
            MapSpan mapSpan = new MapSpan(mapPosition, 0.1, 0.1);

            map = new Map(mapSpan);
            map.IsShowingUser = true;

            PopulatePins();
        }
 public RegisterActivityViewModel(INavigation nav, Xamarin.Forms.Maps.Map map)
 {
     _nav     = nav;
     viewMap  = map;
     dialogs  = UserDialogs.Instance;
     Model    = new RecordActivityModel();
     locator  = CrossGeolocator.Current;
     Activity = new ActivityTimer(OnTimerTick, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1));
     LoadCommands();
 }
예제 #22
0
        private async void FindMe()
        {
            Xamarin.Forms.Maps.Map map = this.FindByName <Xamarin.Forms.Maps.Map>("map");
            var locator = CrossGeolocator.Current;

            Plugin.Geolocator.Abstractions.Position position = new Plugin.Geolocator.Abstractions.Position();
            position = await locator.GetPositionAsync();

            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position.Longitude), Distance.FromMiles(1)));
        }
 public GuideMapViewModel(string guide_id)
 {
     Map = new Xamarin.Forms.Maps.Map
     {
         MapType        = MapType.Street,
         HasZoomEnabled = true,
         IsShowingUser  = true
     };
     this.guide_id = guide_id;
 }
예제 #24
0
        public CustomerProfileViewModel(Xamarin.Forms.Maps.Map map)
        {
            IsBusy             = true;
            SaveCommand        = new Command(SaveAction);
            SetLocationCommand = new Command(SetLocation);
            _map = map;
            var profile = Account.GetProfile().Result;

            Model = Customers.Get(profile.Id).Result;
            Load();
        }
        public FullMapPage(List <RealEstate> realEstate)
        {
            InitializeComponent();

            var position = new Position(55.1694, 23.8813);
            var mapSpan  = new MapSpan(position, 4, 4);
            var map      = new Xamarin.Forms.Maps.Map(mapSpan);

            map = AddPinsToMap(realEstate, map);
            container.Children.Add(map);
        }
예제 #26
0
        private Map GetMap()
        {
            Position independanceSquare = new Position(50.450555, 30.5210808);
            MapSpan  mapSpan            = new MapSpan(independanceSquare, 0.01, 0.01);

            Map map = new Map(mapSpan)
            {
                IsShowingUser = true,
                Scale         = 1
            };

            return(map);
        }
예제 #27
0
        async Task RunPin()
        {
            Map.Pins.Add(new Pin
            {
                Label = ""
            });

            var locator = await Geolocation.GetLastKnownLocationAsync();

            Map.Pins[0].Position = new Position(locator.Latitude, locator.Longitude);

            Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(Map.Pins[0].Position.Latitude, Map.Pins[0].Position.Longitude), Distance.FromMiles(0.5)));
        }
예제 #28
0
        private Map GetMap()
        {
            Position cubic   = new Position(50.383203, 30.471007); //cubic)
            MapSpan  mapSpan = new MapSpan(cubic, 0.01, 0.01);

            Map map = new Map(mapSpan)
            {
                IsShowingUser = true,
                Scale         = 1
            };

            return(map);
        }
예제 #29
0
 private void InitializeMap(Position position)
 {
     Xamarin.Forms.Maps.Map map = new Xamarin.Forms.Maps.Map(
         MapSpan.FromCenterAndRadius(
             position, Distance.FromKilometers(0.3)))
     {
         IsShowingUser   = true,
         HeightRequest   = 100,
         WidthRequest    = 960,
         MapType         = MapType.Satellite,
         VerticalOptions = LayoutOptions.FillAndExpand
     };
     MapStackLayout.Children.Add(map);
 }
예제 #30
0
 public Map()
 {
     var map = new Xamarin.Forms.Maps.Map(
         MapSpan.FromCenterAndRadius(
             new Position(48.856614, 2.3522219000000177), Distance.FromMiles(0.3))) {
         IsShowingUser = true,
         HeightRequest = 100,
         WidthRequest = 960,
         VerticalOptions = LayoutOptions.FillAndExpand
     };
     var stack = new StackLayout { Spacing = 0 };
     stack.Children.Add(map);
     Content = stack;
 }
예제 #31
0
        public MapViewModel(Xamarin.Forms.Maps.Map map)
        {
            mapRef               = map;
            Contacts             = new List <Person>();
            PageAppearingCommand = new Command(async() => await ExecuteLoadContacts());
            //PageAppearingCommand = new Command(OnPageAppearing);
            //PageDisappearingCommand = new Command(OnPageDisappearing);
            locs = new List <Location>();
            mapLocsProperties = new List <MapLocation>();
            //if (Application.Current.Properties.ContainsKey("id"))
            //{
            //    Console.WriteLine("Map Constructor Contains id");
            //    currentIds = Application.Current.Properties["id"] as string[];

            //}
        }
예제 #32
0
        public MainMapPage()
		{
			// Use our own Navigation
            NavigationPage.SetHasNavigationBar(this, false);

			//  Create a map
            var map = new Map(
                MapSpan.FromCenterAndRadius(
                    new Xamarin.Forms.Maps.Position(37,-122), Distance.FromMiles(0.3))) {
                IsShowingUser = true,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            _map = map;

           //  Create a custom toolbar
            View toolbar = new Toolbar(this);
            toolbar.BackgroundColor = Color.White;

			//  Create a test button
            Button b = new Button { Text = "GetPosition" };

            b.Clicked += (sender, ea) => GetPosition1 ();

            var stack = new StackLayout { Spacing = 0 };
            stack.BackgroundColor = Color.White;
            stack.Children.Add (toolbar);
            stack.Children.Add(map);
            stack.Children.Add (b);
            Content = stack;



            //GetPosition1();

            #if false
            try
            {
                _map = new Xamarin.Forms.Maps.Map()
                {
                    VerticalOptions = LayoutOptions.FillAndExpand
                };                     

				// Make map large - tried to use device size but didn't work
				_map.HeightRequest = 2500; //LoginPage.ScreenHeight;
				_map.WidthRequest = 800; //LoginPage.ScreenWidth;

				this.Content = _map; //_popupLayout;

				//  Get current position
                GetPosition();
            }
            catch (Exception exception)
            {
                // error
            }
            #endif
        }
예제 #33
0
		public MainMapPage()
		{
			NavigationPage.SetHasNavigationBar(this, false);

			var map = new Map(
				MapSpan.FromCenterAndRadius(
					new Xamarin.Forms.Maps.Position(37,-122), Distance.FromMiles(0.3))) {
				IsShowingUser = true,
				VerticalOptions = LayoutOptions.FillAndExpand
			};
			_map = map;

			//View toolbar = CreateTopMenu();
			View toolbar = new Toolbar(this);

			//toolbar.WidthRequest = 1000;
			//toolbar.HeightRequest = 50;
			toolbar.BackgroundColor = Color.White;

			Button b = new Button { Text = "GetPosition" };
			lblMonthCount= new Label { Text = "Month_Steps",FontSize =8  };
			lbldayCount= new Label { Text = "Day_Steps",FontSize =8 };
			//Timer timer = new Timer(timerDelegate, s, 1000, 1000);

			b.Clicked += (sender, ea) => GetPosition1 ();

			var stack = new StackLayout { Spacing = 0 };
			stack.BackgroundColor = Color.White;
			stack.Children.Add (toolbar);
			stack.Children.Add(map);
			stack.Children.Add (b);
			stack.Children.Add (lblMonthCount);
			stack.Children.Add (lbldayCount);
			Content = stack;



			//GetPosition1();

			#if false
			try
			{
			_map = new Xamarin.Forms.Maps.Map()
			{
			VerticalOptions = LayoutOptions.FillAndExpand
			};                     

			// Make map large - tried to use device size but didn't work
			_map.HeightRequest = 2500; //LoginPage.ScreenHeight;
			_map.WidthRequest = 800; //LoginPage.ScreenWidth;

			this.Content = _map; //_popupLayout;

			//  Get current position
			GetPosition();
			}
			catch (Exception exception)
			{
			// error
			}
			#endif
		}
예제 #34
0
 public WeatherMap(Xamarin.Forms.Maps.Map weatherMap)
 {
     _weatherMap = weatherMap;
 }