Example #1
0
 private void AreaMapControl_OnLoaded(object sender, RoutedEventArgs e)
 {
     AreaMapControl.ZoomLevel     = 14;
     AreaMapControl.Style         = MapStyle.Road;
     AreaMapControl.MapProjection = MapProjection.WebMercator;
     AreaMapControl.StyleSheet    = MapStyleSheet.RoadLight();
 }
Example #2
0
        private async Task SetupMap()
        {
            MapControlls.Opacity = 0;
            Map.Opacity          = 0;
            Map.ZoomLevel        = 16;
            Map.MapServiceToken  =
                "UOBcq7qYTGSBYjpdwGvJ~ZoDecyJEsIhjGowIczjaTg~AmjcaSnBVS38715lpzn_KgdYiQf1AZ5KG-mLQHi0QWfPcl0xmo9WftqZ4fZtVUyO";
            Map.StyleSheet         = MapStyleSheet.RoadDark();
            Map.TrafficFlowVisible = false;

            switch (await Geolocator.RequestAccessAsync())
            {
            case GeolocationAccessStatus.Unspecified:
                break;

            case GeolocationAccessStatus.Allowed:
                _geolocator.DesiredAccuracy = PositionAccuracy.High;
                var position = await _geolocator.GetGeopositionAsync();

                Model.CurrentPosition = position.Coordinate.Point;
                Map.Center            = Model.CurrentPosition;
                FadeInAnimation.Begin();

                _geolocator.PositionChanged += OnGeoPositionChanged;
                break;

            case GeolocationAccessStatus.Denied:
                break;

            default:
                break;
            }
        }
Example #3
0
        private void Roads_Click(object sender, RoutedEventArgs e)
        {
            RadioButton radio = sender as RadioButton;

            switch (radio.Name)
            {
            case "Roads":
                myMap.Style = MapStyle.Road;
                break;

            case "Hybrid":
                myMap.Style = MapStyle.AerialWithRoads;
                break;

            case "Satellite":
                myMap.Style = MapStyle.Aerial;
                break;

            case "Dark":
                myMap.StyleSheet = MapStyleSheet.RoadDark();
                break;

            default:
                break;
            }
        }
Example #4
0
        async void setUpMap()
        {
            _trafficMap.MapServiceToken = Instance.TrafficAPIKey;

            // Set your current location.
            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:

                // Get the current location.
                Geolocator  geolocator = new Geolocator();
                Geoposition pos        = await geolocator.GetGeopositionAsync();

                Geopoint myLocation = pos.Coordinate.Point;

                // Set the map location.
                _trafficMap.Center           = myLocation;
                _trafficMap.LandmarksVisible = true;
                break;

            case GeolocationAccessStatus.Denied:
                // Handle the case  if access to location is denied.
                break;

            case GeolocationAccessStatus.Unspecified:
                // Handle the case if  an unspecified error occurs.
                break;
            }

            _trafficMap.ZoomLevel  = 13;
            _trafficMap.StyleSheet = MapStyleSheet.RoadDark();
        }
 private string GetMapStyleSheetName(MapStyleSheet styleSheet)
 {
     if (styleSheet == MapStyleSheet.Aerial())
     {
         return("Aerial");
     }
     else if (styleSheet == MapStyleSheet.AerialWithOverlay())
     {
         return("AerialWithOverlay");
     }
     else if (styleSheet == MapStyleSheet.RoadDark())
     {
         return("RoadDark");
     }
     else if (styleSheet == MapStyleSheet.RoadLight())
     {
         return("RoadLight");
     }
     else if (styleSheet == MapStyleSheet.RoadHighContrastDark())
     {
         return("RoadHighContrastDark");
     }
     else if (styleSheet == MapStyleSheet.RoadHighContrastLight())
     {
         return("RoadHighContrastLight");
     }
     else
     {
         return("Custom");
     }
 }
Example #6
0
        private async void InitializeMapControl()
        {
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Geopoint UserLocation = new Geopoint(new Windows.Devices.Geolocation.BasicGeoposition());

            if (!localSettings.Values.Keys.Contains("UserLocation"))
            {
                var accessStatus = await Geolocator.RequestAccessAsync();

                switch (accessStatus)
                {
                case GeolocationAccessStatus.Allowed:
                    // Get the current location.
                    Geolocator  geolocator = new Geolocator();
                    Geoposition pos        = await geolocator.GetGeopositionAsync();

                    UserLocation = pos.Coordinate.Point;

                    localSettings.Values["UserLocation"]           = true;
                    localSettings.Values["UserLocation_Latitude"]  = pos.Coordinate.Point.Position.Latitude;
                    localSettings.Values["UserLocation_Longitude"] = pos.Coordinate.Point.Position.Longitude;

                    break;

                case GeolocationAccessStatus.Denied:
                    // Handle the case  if access to location is denied.
                    var messageDialog = new MessageDialog("Location services not enabled!");
                    await messageDialog.ShowAsync();

                    break;

                case GeolocationAccessStatus.Unspecified:
                    // Handle the case if  an unspecified error occurs.
                    break;
                }
            }
            else
            {
                UserLocation = new Geopoint(new Windows.Devices.Geolocation.BasicGeoposition()
                {
                    Latitude = (double)localSettings.Values["UserLocation_Latitude"], Longitude = (double)localSettings.Values["UserLocation_Longitude"]
                });
            }

            CTRL_Map_Main.Center                    = UserLocation;
            CTRL_Map_Main.ZoomLevel                 = 1;
            CTRL_Map_Main.LandmarksVisible          = false;
            CTRL_Map_Main.PedestrianFeaturesVisible = false;
            CTRL_Map_Main.WatermarkMode             = MapWatermarkMode.Automatic;
            CTRL_Map_Main.StyleSheet                = MapStyleSheet.ParseFromJson(resourceLoader.GetString("Map_Style"));
            CTRL_Map_Main.CacheMode                 = new BitmapCache();

            GRD_Map.Visibility = Visibility.Visible;

            MapControlLoaded = true;
        }
        private void SetMapStyleSheet()
        {
            switch (setDefaultStyleCombobox.SelectedIndex)
            {
            case 0:
                myMap.StyleSheet = MapStyleSheet.Aerial();
                break;

            case 1:
                myMap.StyleSheet = MapStyleSheet.AerialWithOverlay();
                break;

            case 2:
                myMap.StyleSheet = MapStyleSheet.RoadDark();
                break;

            case 3:
                myMap.StyleSheet = MapStyleSheet.RoadLight();
                break;

            case 4:
                myMap.StyleSheet = MapStyleSheet.RoadHighContrastDark();
                break;

            case 5:
                myMap.StyleSheet = MapStyleSheet.RoadHighContrastLight();
                break;

            case 6:
                myMap.StyleSheet = MapStyleSheet.ParseFromJson(@"
                        {
                            ""version"": ""1.0"",
                            ""settings"": {
                                ""landColor"": ""#FFFFFF"",
                                ""spaceColor"": ""#000000""
                            },
                            ""elements"": {
                                ""mapElement"": {
                                    ""labelColor"": ""#000000"",
                                    ""labelOutlineColor"": ""#FFFFFF""
                                },
                                ""water"": {
                                    ""fillColor"": ""#DDDDDD""
                                },
                                ""area"": {
                                    ""fillColor"": ""#EEEEEE""
                                },
                                ""political"": {
                                    ""borderStrokeColor"": ""#CCCCCC"",
                                    ""borderOutlineColor"": ""#00000000""
                                }
                            }
                        }
                    ");
                break;
            }
        }
 //Evento llamado cuando la pantalla ha sido cargada. Lo uso para establecer el Index de los los combos de los mapas, ya que al añadir sus items del combo en la función Main, no se puede establecer
 //su index en ella porque su valor aun es null. Por ello, los establezco en esta función, que es llamada posteriormente
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     //Estilo del mapa inicial 2d, correspondiente al index 1 de combo2d
     MapControl.StyleSheet = MapStyleSheet.RoadDark(); //Apariencia del Mapa. Por lo que dice la documentación, se pueden personalizar los colores
                                                       //de cada tipo de apariencia del mapa, para poder cambiarlos y crear nuestras propias apariencias https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/elements-of-map-style-sheet
     combo2d.SelectedIndex = 1;
     combo3d.SelectedIndex = 0;
     Debug.WriteLine(combo2d.Width + " " + combo3d.Width);
 }
        private void SetMapMode(MapStyle mode)
        {
            if (this.mapStyle != mode)
            {
                this.mapStyle = mode;

                var stylesheet = (mode == MapStyle.Road) ?
                                 MapStyleSheet.RoadLight() :
                                 MapStyleSheet.AerialWithOverlay();
                this.map.StyleSheet = stylesheet;
                this.NotifyPropertyChanged(nameof(IsSymbolicMap));
            }
        }
Example #10
0
        private async void InitializeMapStyle()
        {
            drivewMap.MapServiceToken = Constants.BingMapsAPIKey;
            drivewMap.MapProjection   = MapProjection.Globe;
            drivewMap.Style           = MapStyle.Road;

            Uri appUri = new Uri(@"ms-appx:///Styles/MapStyle.json");
            var file   = await StorageFile.GetFileFromApplicationUriAsync(appUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            drivewMap.StyleSheet = MapStyleSheet.ParseFromJson(jsonText);
            Messenger.Default.Register <Geoposition>(this, Constants.BingMapsAPIKey, SetMapView);
        }
Example #11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Specify a known location.
            BasicGeoposition cityPosition = new BasicGeoposition()
            {
                Latitude = 46.283333, Longitude = 86.666667
            };
            Geopoint cityCenter = new Geopoint(cityPosition);

            // Set the map location.
            MapMaker.StyleSheet       = MapStyleSheet.RoadDark();
            MapMaker.Center           = cityCenter;
            MapMaker.ZoomLevel        = 12;
            MapMaker.LandmarksVisible = true;
        }
        //Función que establece el mapa con mapas 2D según el valor de su combo
        private void click_MapaNormal(object sender, RoutedEventArgs e)
        {
            switch (combo2d.SelectedIndex)
            {
            case 0:
                MapControl.StyleSheet = MapStyleSheet.Aerial();
                break;

            case 1:
                MapControl.StyleSheet = MapStyleSheet.RoadDark();
                break;

            case 2:
                MapControl.StyleSheet = MapStyleSheet.RoadLight();
                break;
            }
        }
Example #13
0
        private async void TripMapControl_Loaded(object sender, RoutedEventArgs e)
        {
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            CompletedTripMap.MapServiceToken = Constants.BingMapsAPIKey;
            Uri appUri = new Uri(@"ms-appx:///Styles/MapStyle.json");
            var file   = await StorageFile.GetFileFromApplicationUriAsync(appUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            CompletedTripMap.StyleSheet = MapStyleSheet.ParseFromJson(jsonText);

            await LoadOpenTaskListView();

            if (RideLocations.Count != 0)
            {
                await DrawPath(RideLocations);
            }
        }
Example #14
0
        async void setUpMap()
        {
            _trafficMap.MapServiceToken = Instance.TrafficAPIKey;

            // Set your current location.
            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:

                // Get the current location.
                Geolocator  geolocator = new Geolocator();
                Geoposition pos        = await geolocator.GetGeopositionAsync();

                Geopoint myLocation = pos.Coordinate.Point;

                //K-State Campus Location
                BasicGeoposition bgp = new BasicGeoposition();
                bgp.Latitude  = 39.1930;
                bgp.Longitude = -96.5740;
                Geopoint AndersonHall = new Geopoint(bgp);


                // Set the map location.
                _trafficMap.Center           = AndersonHall;
                _trafficMap.LandmarksVisible = true;
                _trafficMap.Height           = 450;
                _trafficMap.Width            = 350;
                break;

            case GeolocationAccessStatus.Denied:
                // Handle the case  if access to location is denied.
                break;

            case GeolocationAccessStatus.Unspecified:
                // Handle the case if  an unspecified error occurs.
                break;
            }

            _trafficMap.ZoomLevel  = 14;
            _trafficMap.StyleSheet = MapStyleSheet.RoadDark();
        }
        async void setUpMap()
        {
            _trafficMap.MapServiceToken    = Instance.TrafficAPIKey;
            _trafficMapBig.MapServiceToken = Instance.TrafficAPIKey;

            // Set your current location.
            var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:

                // Get the current location.
                Geolocator  geolocator = new Geolocator();
                Geoposition pos        = await geolocator.GetGeopositionAsync();

                Geopoint myLocation = pos.Coordinate.Point;

                // Set the map location.
                _trafficMap.Center              = myLocation;
                _trafficMap.LandmarksVisible    = true;
                _trafficMapBig.Center           = myLocation;
                _trafficMapBig.LandmarksVisible = true;
                break;

            case GeolocationAccessStatus.Denied:
                // Handle the case  if access to location is denied.
                break;

            case GeolocationAccessStatus.Unspecified:
                // Handle the case if  an unspecified error occurs.
                break;
            }

            _trafficMap.ZoomLevel    = 13.55;
            _trafficMapBig.ZoomLevel = 14.65;
            //FIX, System.TypeLoadException: 'Requested Windows Runtime type 'Windows.UI.Xaml.Controls.Maps.MapStyleSheet' is not registered.'
            _trafficMap.StyleSheet    = MapStyleSheet.RoadDark();
            _trafficMapBig.StyleSheet = MapStyleSheet.RoadDark();
        }
Example #16
0
        private async void TripSummary_Loaded(object sender, RoutedEventArgs e)
        {
            sumTripMap.MapServiceToken = Constants.BingMapsAPIKey;
            Uri appUri = new Uri(@"ms-appx:///Styles/MapStyle.json");
            var file   = await StorageFile.GetFileFromApplicationUriAsync(appUri);

            string jsonText = await FileIO.ReadTextAsync(file);

            sumTripMap.StyleSheet = MapStyleSheet.ParseFromJson(jsonText);
            var tripLocations = await localStoreService.LoadLocalData <List <Location> >(Constants.LocationFileIdentifier);

            if (tripLocations != null)
            {
                var positions = (from locations in tripLocations
                                 where locations.TimeStamp >= tripView.CurrentTripDataRepo.StartTime && locations.TimeStamp <= tripView.CurrentTripDataRepo.EndTime
                                 select new BasicGeoposition {
                    Latitude = locations.Latitude, Longitude = locations.Longitude
                }).ToList();

                await DrawPath(positions);
            }
        }
Example #17
0
        private async void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            if (MyMap.Is3DSupported)
            {
                MyMap.Style      = MapStyle.Aerial3DWithRoads;
                MyMap.StyleSheet = MapStyleSheet.RoadDark();


                BasicGeoposition geoPosition = new BasicGeoposition();
                geoPosition.Latitude  = 41.790366;
                geoPosition.Longitude = -6.760116;

                Geopoint myPoint = new Geopoint(geoPosition);
                MyMap.Center    = myPoint;
                MyMap.ZoomLevel = 10;
                MapScene hwScene = MapScene.CreateFromLocationAndRadius(myPoint, 80, 0, 60);
                await MyMap.TrySetSceneAsync(hwScene, MapAnimationKind.Bow);

                MapScene mapScene = MapScene.CreateFromLocationAndRadius(new Geopoint(geoPosition), 500, 150, 70);
                await MyMap.TrySetSceneAsync(mapScene);
            }
        }
        private async void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            myMap.Center    = MainPage.SeattleGeopoint;
            myMap.ZoomLevel = 16;

            // Specify a style sheet.  It is not strictly necessary to Combine since RoadLight is the default.
            var myStyleSheetFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///StyleSheets/MyCustomStates.json"));

            string myStyleSheetJson = await FileIO.ReadTextAsync(myStyleSheetFile);

            myMap.StyleSheet = MapStyleSheet.Combine(new MapStyleSheet[]
            {
                MapStyleSheet.RoadLight(),
                MapStyleSheet.ParseFromJson(myStyleSheetJson)
            });

            // Populate various layers containing points and connect up states to events.
            AddLayer1();
            AddLayer2();

            // Connect the layers to the map.
            myMap.Layers = this.myLayers;
        }
Example #19
0
        public ActivityView()
        {
            InitializeComponent();

            SetupMapStyle();
            EnableAnimations();

            void SetupMapStyle()
            {
                ActivityMap.StyleSheet = MapStyleSheet.ParseFromJson(@"
                {
                    ""version"": ""1.*"",
                    ""settings"": {
                        ""landColor"": ""#FF101416"",
                        ""spaceColor"": ""#FF101416"",
                        ""shadedReliefVisible"": false,
                        ""atmosphereVisible"": false,
                        ""logosVisible"": false
                    },
                    ""elements"": {
                        ""mapElement"": {
                            ""labelVisible"": true,
                            ""labelColor"": ""#FF3E4244"",
                            ""labelOutlineColor"": ""#FF0B0F11"",
                            ""strokeColor"": ""#FF0B0F11"",
                            ""strokeWidthScale"": 1                                             
                        },
                        ""political"": {
                            ""borderStrokeColor"": ""#FF1E3B49"",
                            ""borderOutlineColor"": ""#00000000""
                        },
                        ""point"": {
                            ""iconColor"": ""#00000000"",
                            ""fillColor"": ""#00000000"",
                            ""strokeColor"": ""#00000000""
                        },
                        ""roadShield"": {
                            ""scale"": 0
                        },

                        ""transportation"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },

                        ""road"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""controlledAccessHighway"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""highSpeedRamp"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""highway"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""majorRoad"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF060809""
                        },
                        ""arterialRoad"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""street"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""ramp"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""unpavedStreet"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""tollRoad"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""railway"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""trail"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""waterRoute"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF182127""
                        },
                        ""water"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF182127""
                        },
                        ""river"": {
                            ""strokeColor"": ""#00000000"",
                            ""fillColor"": ""#FF182127""
                        },

                        ""structure"": {
                            ""fillColor"": ""#FF0B0F11""
                        },
                        ""area"": {
                            ""fillColor"": ""#FF0B0F11""
                        }
                    }
                }
            ");
            }

            void EnableAnimations()
            {
                ActionsPanel.EnableFluidVisibilityAnimation(AnimationAxis.Y, -174.0f, -174.0f, showDuration: 400, hideDuration: 400);
                ActivityType.EnableFluidVisibilityAnimation(AnimationAxis.Y, 12.0f, -12.0f, showDuration: 400, hideDuration: 400, showDelay: 800);

                LeftBladeToggle.EnableFluidVisibilityAnimation(centerPoint: new Vector3(20.0f, 20.0f, 0.0f), showFromScale: 0.2f, hideToScale: 0.2f, showDuration: 400, hideDuration: 400);
                RightBladeToggle.EnableFluidVisibilityAnimation(centerPoint: new Vector3(20.0f, 20.0f, 0.0f), showFromScale: 0.2f, hideToScale: 0.2f, showDuration: 400, hideDuration: 400);
                LeftBladeContent.EnableFluidVisibilityAnimation(showFromScale: 0.0f, hideToScale: 0.0f, showDuration: 400, hideDuration: 400);
                RightBladeContent.EnableFluidVisibilityAnimation(showFromScale: 0.0f, hideToScale: 0.0f, showDuration: 400, hideDuration: 400, showDelay: 100);

                RightBladeToggle.EnableImplicitAnimation(VisualPropertyType.Offset, 400, 100);
            }
        }