Example #1
0
        private void SetupMap()
        {
            if (SettingsService.Instance.IsNianticMapEnabled)
            {
                var googleTileSource =
                    new HttpMapTileDataSource(
                        "http://mts0.google.com/vt/lyrs=m@289000001&hl=en&src=app&x={x}&y={y}&z={zoomlevel}&s=Gal&apistyle=" + (RequestedTheme == ElementTheme.Light ? MapStyleHelpers.LightMapStyleString : MapStyleHelpers.DarkMapStyleString));

                GameMapControl.Style = MapStyle.None;
                GameMapControl.TileSources.Clear();
                GameMapControl.TileSources.Add(new MapTileSource(googleTileSource)
                {
                    AllowOverstretch = true,
                    IsFadingEnabled  = false,
                    Layer            = MapTileLayer.BackgroundReplacement
                });

                GoogleAttributionBorder.Visibility = Visibility.Visible;
            }
            else
            {
                // Fallback to Bing Maps
                // TODO: map color scheme is set but the visual style doesn't update!
                GameMapControl.ColorScheme = ViewModel.CurrentTheme == ElementTheme.Dark
                    ? MapColorScheme.Dark
                    : MapColorScheme.Light;
                GameMapControl.TileSources.Clear();
                GameMapControl.Style = MapStyle.Road;

                GoogleAttributionBorder.Visibility = Visibility.Collapsed;
            }
        }
Example #2
0
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            args.Request.Uri = new Uri($"https://api.mapbox.com/styles/v1/{ApplicationKeys.MapBoxStyle}/tiles/256/{args.ZoomLevel}/{args.X}/{args.Y}?access_token={ApplicationKeys.MapBoxToken}");
            deferral.Complete();
        }
 protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
 {
     var deferral = args.Request.GetDeferral();
       // TilePathPrefixes - load balancing + caching
       args.Request.Uri = new Uri($"http://{TilePathPrefixes[args.Y % 3]}.tile.openstreetmap.org/{args.ZoomLevel}/{args.X}/{args.Y}.png");
       deferral.Complete();
 }
        protected BaseHttpTileSource()
        {
            var t = new HttpMapTileDataSource();

            t.UriRequested += MapUriRequested;
            TileSource      = t;
        }
 private void SatelliteMapView_Checked(object sender, RoutedEventArgs e)
 {
     if (ShowTraffic.IsOn)
     {
         Map.TileSources.Clear();
         var mapuri     = "http://mt1.google.com/vt/lyrs=s@221097413,traffic&hl=" + AppCore.OnMapLanguage + "&z={zoomlevel}&x={x}&y={y}";
         var dataSource = new HttpMapTileDataSource(mapuri)
         {
             AllowCaching = true
         };
         Map.TileSources.Add(new MapTileSource(dataSource)
         {
             AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled
         });
     }
     else
     {
         Map.TileSources.Clear();
         var mapuri     = "http://mt1.google.com/vt/lyrs=s&hl=" + AppCore.OnMapLanguage + "&z={zoomlevel}&x={x}&y={y}";
         var dataSource = new HttpMapTileDataSource(mapuri)
         {
             AllowCaching = true
         };
         Map.TileSources.Add(new MapTileSource(dataSource)
         {
             AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled
         });
     }
 }
Example #6
0
        private void MapDataSource()
        {
            HttpMapTileDataSource dataSource  = new HttpMapTileDataSource("http://map.baidu.com/z={4}&x={0}&y={0}");
            MapTileSource         titleSource = new MapTileSource(dataSource);

            MapControl.TileSources.Add(titleSource);
        }
Example #7
0
 private void DefaultMapView_Checked(object sender, RoutedEventArgs e)
 {
     if (ShowTraffic.IsOn)
     {
         Map.TileSources.Clear();
         var dataSource = new HttpMapTileDataSource("http://mt1.google.com/vt/lyrs=r@221097413,traffic&hl=x-local&z={zoomlevel}&x={x}&y={y}")
         {
             AllowCaching = true
         };
         Map.TileSources.Add(new MapTileSource(dataSource)
         {
             AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled
         });
     }
     else
     {
         Map.TileSources.Clear();
         var dataSource = new HttpMapTileDataSource("http://mt1.google.com/vt/lyrs=r&hl=x-local&z={zoomlevel}&x={x}&y={y}")
         {
             AllowCaching = true
         };
         Map.TileSources.Add(new MapTileSource(dataSource)
         {
             AllowOverstretch = AllowOverstretch, IsFadingEnabled = FadeAnimationEnabled
         });
     }
 }
Example #8
0
        public GameMapPage()
        {
            InitializeComponent();
            NavigationCacheMode = NavigationCacheMode.Enabled;            

            // Setup nearby translation
            Loaded += (s, e) =>
            {
                var randomTileSourceIndex = new Random().Next(0, ApplicationKeys.MapBoxTokens.Length);
                Logger.Write($"Using MapBox's keyset {randomTileSourceIndex}");
                var mapBoxTileSource =
                    new HttpMapTileDataSource(
                        "https://api.mapbox.com/styles/v1/" + (RequestedTheme == ElementTheme.Light ? ApplicationKeys.MapBoxStylesLight[randomTileSourceIndex] : ApplicationKeys.MapBoxStylesDark[randomTileSourceIndex]) +
                        "/tiles/256/{zoomlevel}/{x}/{y}?access_token=" + ApplicationKeys.MapBoxTokens[randomTileSourceIndex])
                    {
                        AllowCaching = true
                    };

                GameMapControl.TileSources.Clear();
                GameMapControl.TileSources.Add(new MapTileSource(mapBoxTileSource) {AllowOverstretch = true, IsFadingEnabled = false});                

                ShowNearbyModalAnimation.From =
                    HideNearbyModalAnimation.To = NearbyPokemonModal.ActualHeight;
                HideNearbyModalAnimation.Completed += (ss, ee) =>
                {
                    NearbyPokemonModal.IsModal = false;
                };
            };
        }
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;


            _map = new MapControl();
            _map.MapServiceToken = "yourtoken";
            BasicGeoposition center = new BasicGeoposition();

            center.Latitude  = 50.07574;
            center.Longitude = 14.416;
            _map.Center      = new Geopoint(center);
            _map.ZoomLevel   = 17;

            HttpMapTileDataSource dataSource = new HttpMapTileDataSource();

            dataSource.UriRequested += new TypedEventHandler <HttpMapTileDataSource, MapTileUriRequestedEventArgs>(
                (source, args) => {
                Rect mercBounds  = GlobalMercator.TileBounds(new Tile(args.X, args.Y), args.ZoomLevel);
                args.Request.Uri = new Uri(string.Format(_wmsUrl, mercBounds.Left, Math.Abs(mercBounds.Bottom), mercBounds.Right, Math.Abs(mercBounds.Top)));;
            });

            _map.TileSources.Add(new MapTileSource(dataSource));
            this.Content = _map;
        }
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            args.Request.Uri = new Uri($"http://mt{(args.X % 2) + (2 * (args.Y % 2))}.google.com/vt/lyrs={mapPrefix}&z={args.ZoomLevel}&x={args.X}&y={args.Y}");
            deferral.Complete();
        }
Example #11
0
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            // TilePathPrefixes - load balancing + caching
            args.Request.Uri = new Uri($"http://{TilePathPrefixes[args.Y % 3]}.tile.openstreetmap.fr/hot/{args.ZoomLevel}/{args.X}/{args.Y}.png");
            deferral.Complete();
        }
Example #12
0
        protected BaseHttpTileSource()
        {
            var t = new HttpMapTileDataSource {
                AllowCaching = true
            };

            t.UriRequested += MapUriRequested;
            TileSource      = t;
        }
 /**
  * change the tilesource of the mapControl to use openstreetmap
  */
 public static void SetOsmTileSource(this MapControl mapControl) {
     var httpsource = new HttpMapTileDataSource("http://a.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");
     httpsource.AllowCaching = true;
     var ts = new MapTileSource(httpsource) {
         Layer = MapTileLayer.BackgroundReplacement
     };
     mapControl.Style = MapStyle.None;
     mapControl.TileSources.Add(ts);
 }
 public static MapTileDataSource GetForBuildings( MapProperties props )
 {
     var source = new HttpMapTileDataSource();
     source.UriRequested += ( _, e ) =>
     {
         e.Request.Uri = EpflBuildingsSource.GetUri( e.X, e.Y, e.ZoomLevel, props.Floor );
     };
     return source;
 }
Example #15
0
        private void AddMap()
        {
            var httpTileDataSource = new HttpMapTileDataSource();

            // Attach a handler for the UriRequested event.
            httpTileDataSource.UriRequested += HandleUriRequestAsync;
            MapTileSource httpTileSource = new MapTileSource(httpTileDataSource);

            MyMapControl.TileSources.Add(httpTileSource);
        }
Example #16
0
        private async void HandleUriRequestAsync(HttpMapTileDataSource sender,
                                                 MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();
            var tile     = manager.convert_bingTile_to_baidu(args.X, args.Y, args.ZoomLevel);
            var uri      = await GetCustomUriAsync(tile.x, tile.y, tile.z);

            args.Request.Uri = uri;
            deferral.Complete();
        }
Example #17
0
        private void TileSource_Checked(object sender, RoutedEventArgs e)
        {
            var httpsource = new HttpMapTileDataSource("http://a.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");
            var ts         = new MapTileSource(httpsource)
            {
                Layer = MapTileLayer.BackgroundReplacement
            };

            map1.Style = MapStyle.None;
            map1.TileSources.Add(ts);
        }
        /// <summary>
        /// This function converts the basic url template value (x, y, z) into real values.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void DataSource_UriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var    deferral    = args.Request.GetDeferral();
            string urlTemplate = customMap.MapTileTemplate;

            //Here we write the code for creating the url.
            var url = urlTemplate.Replace("{z}", args.ZoomLevel.ToString()).Replace("{x}", args.X.ToString()).Replace("{y}", args.Y.ToString());

            args.Request.Uri = new Uri(url);

            deferral.Complete();
        }
Example #19
0
        private void SetTileSource()
        {
            HttpMapTileDataSource osmSource = new HttpMapTileDataSource("http://a.basemaps.cartocdn.com/light_all/{zoomlevel}/{x}/{y}.png");
            osmSource.AllowCaching = true;
            MapTileSource osmLayer = new MapTileSource(osmSource);
            osmLayer.Layer = MapTileLayer.BackgroundReplacement;
            osmLayer.AllowOverstretch = true;
            osmLayer.IsTransparencyEnabled = false;
            osmLayer.IsFadingEnabled = false;

            mapControl.Style = MapStyle.None;
            mapControl.TileSources.Add(osmLayer);
        }
Example #20
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            HttpMapTileDataSource dataSource = new HttpMapTileDataSource("http://tile2.maps.2gis.ru/tiles?x={x}&y={y}&z={zoomlevel}&v=1");
            MapTileSource         tileSource = new MapTileSource(dataSource)
            {
                Layer           = MapTileLayer.BackgroundReplacement,
                IsFadingEnabled = false,
            };

            Map.Style = MapStyle.None;
            Map.TileSources.Add(tileSource);
        }
Example #21
0
        private void SetTileSource()
        {
            HttpMapTileDataSource osmSource = new HttpMapTileDataSource("http://a.basemaps.cartocdn.com/light_all/{zoomlevel}/{x}/{y}.png");

            osmSource.AllowCaching = true;
            MapTileSource osmLayer = new MapTileSource(osmSource);

            osmLayer.Layer                 = MapTileLayer.BackgroundReplacement;
            osmLayer.AllowOverstretch      = true;
            osmLayer.IsTransparencyEnabled = false;
            osmLayer.IsFadingEnabled       = false;

            mapControl.Style = MapStyle.None;
            mapControl.TileSources.Add(osmLayer);
        }
        private void AddAnimatedTilesClick(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (httpTileSource == null)
            {
                var httpMapTileDataSource = new HttpMapTileDataSource();
                httpMapTileDataSource.UriRequested += HttpMapTileDataSourceUriRequested;
                httpTileSource = new MapTileSource()
                {
                    DataSource    = httpMapTileDataSource,
                    FrameCount    = timestamps.Length,
                    FrameDuration = TimeSpan.FromMilliseconds(500),
                };

                myMap.TileSources.Add(httpTileSource);
            }
        }
        /// <summary>
        /// This function update the tiles of the Map for this plateform.
        /// </summary>
        private void UpdateTiles()
        {
            if (nativeMap != null)
            {
                if (this.customMap.MapTileTemplate != null)
                {
                    if (nativeMap.TileSources.Count > 0)
                    {
                        nativeMap.TileSources.Clear();
                        this.nativeMap.Style = MapStyle.Road;
                    }

                    this.nativeMap.Style = MapStyle.None;
                    HttpMapTileDataSource dataSource = new HttpMapTileDataSource();
                    dataSource.UriRequested += DataSource_UriRequested;
                    nativeMap.TileSources.Add(new MapTileSource(dataSource));
                }
            }
        }
        private void SetTileSourceToOSM()
        {
            var next       = "a";
            var httpsource = new HttpMapTileDataSource("http://a.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");

            httpsource.UriRequested += (src, args) => {
                next             = GetNextDomain(next);
                args.Request.Uri = new Uri("http://" + next + ".tile.openstreetmap.org/" +
                                           args.ZoomLevel + "/" + args.X + "/" + args.Y + ".png");
            };

            var tilesource = new MapTileSource(httpsource)
            {
                Layer = MapTileLayer.BackgroundOverlay
            };

            MyMap.Style = MapStyle.None;
            MyMap.TileSources.Add(tilesource);
        }
        private void SetTileSourceToOSM()
        {
            var next = "a";
            var httpsource = new HttpMapTileDataSource("http://a.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");

            httpsource.UriRequested += (src, args) => {
                next = GetNextDomain(next);
                args.Request.Uri = new Uri("http://" + next + ".tile.openstreetmap.org/" +
                    args.ZoomLevel + "/" + args.X + "/" + args.Y + ".png");

            };

            var tilesource = new MapTileSource(httpsource)
            {
                Layer = MapTileLayer.BackgroundOverlay
            };

           MyMap.Style = MapStyle.None;
           MyMap.TileSources.Add(tilesource);
        }
Example #26
0
        private void SetupMap()
        {
            if (ApplicationKeys.MapBoxTokens.Length > 0 && SettingsService.Instance.IsNianticMapEnabled)
            {
                if (_mapBoxIndex == -1)
                {
                    _mapBoxIndex = new Random().Next(0, ApplicationKeys.MapBoxTokens.Length);
                }
                Logger.Write($"Using MapBox's keyset {_mapBoxIndex}");
                var mapBoxTileSource =
                    new HttpMapTileDataSource(
                        "https://api.mapbox.com/styles/v1/" +
                        (RequestedTheme == ElementTheme.Light
                            ? ApplicationKeys.MapBoxStylesLight[_mapBoxIndex]
                            : ApplicationKeys.MapBoxStylesDark[_mapBoxIndex]) +
                        "/tiles/256/{zoomlevel}/{x}/{y}?access_token=" +
                        ApplicationKeys.MapBoxTokens[_mapBoxIndex])
                {
                    AllowCaching = true
                };

                GameMapControl.Style = MapStyle.None;
                GameMapControl.TileSources.Clear();
                GameMapControl.TileSources.Add(new MapTileSource(mapBoxTileSource)
                {
                    AllowOverstretch = true,
                    IsFadingEnabled  = false,
                    Layer            = MapTileLayer.BackgroundReplacement
                });
            }
            else
            {
                // Fallback to Bing Maps
                // TODO: map color scheme is set but the visual style doesn't update!
                GameMapControl.ColorScheme = ViewModel.CurrentTheme == ElementTheme.Dark
                    ? MapColorScheme.Dark
                    : MapColorScheme.Light;
                GameMapControl.TileSources.Clear();
                GameMapControl.Style = MapStyle.Terrain;
            }
        }
Example #27
0
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            if (!(args.ZoomLevel < 4 && Epsg == 4326))
            {
                var extent      = GetTileExtent(args.X, args.Y, args.ZoomLevel);
                var urlTemplate = string.Concat(ServiceUrl,
                                                ServiceUrl.EndsWith("?")
            ? string.Empty
            : ServiceUrl.EndsWith("&") ? string.Empty : (ServiceUrl.Contains("?") ? "&" : "?"), WmsPostFix);
                var url = string.Format(CultureInfo.InvariantCulture,
                                        urlTemplate, extent.XLow, extent.YLow, extent.XHigh, extent.YHigh, TileSize, Epsg,
                                        string.Join(",", Layers),
                                        Version, ReferenceSystemName, ImageType);

#if DEBUG
                Debug.WriteLine("Tile x={0}, y={1}, zoom={2}", args.X, args.Y, args.ZoomLevel);
                Debug.WriteLine("adding uri {0}", url);
#endif
                args.Request.Uri = new Uri(url);
            }
            deferral.Complete();
        }
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

              if (!(args.ZoomLevel < 4 && Epsg == 4326))
              {
            var extent = GetTileExtent(args.X, args.Y, args.ZoomLevel);
            var urlTemplate = string.Concat(ServiceUrl,
              ServiceUrl.EndsWith("?")
            ? string.Empty
            : ServiceUrl.EndsWith("&") ? string.Empty : (ServiceUrl.Contains("?") ? "&" : "?"), WmsPostFix);
            var url = string.Format(CultureInfo.InvariantCulture,
              urlTemplate, extent.XLow, extent.YLow, extent.XHigh, extent.YHigh, TileSize, Epsg,
              string.Join(",", Layers),
              Version, ReferenceSystemName, ImageType);

            #if DEBUG
            Debug.WriteLine("Tile x={0}, y={1}, zoom={2}", args.X, args.Y, args.ZoomLevel);
            Debug.WriteLine("adding uri {0}", url);
            #endif
            args.Request.Uri = new Uri(url);
              }
              deferral.Complete();
        }
Example #29
0
 protected BaseHttpTileSource()
 {
     var t = new HttpMapTileDataSource {AllowCaching = true};
     t.UriRequested += MapUriRequested;
     TileSource = t;
 }
Example #30
0
        private void Hm_UriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var res = TileCoordinate.ReverseGeoPoint(args.X, args.Y, args.ZoomLevel);

            args.Request.Uri = new Uri($"https://maps.googleapis.com/maps/api/staticmap?center={res.Latitude},{res.Longitude}&zoom={args.ZoomLevel}&maptype=traffic&size=256x256&key={AppCore.GoogleMapAPIKey}", UriKind.RelativeOrAbsolute);
        }
 private void HttpMapTileDataSourceUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
 {
     args.Request.Uri = new Uri(urlTemplate.Replace("{timestamp}", timestamps[args.FrameIndex]));
 }
 public HttpMapTileDataSourceEvents(HttpMapTileDataSource This)
 {
     this.This = This;
 }
 protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
 {
     var deferral = args.Request.GetDeferral();
       args.Request.Uri = new Uri($"http://mt{(args.X % 2) + (2 * (args.Y % 2))}.google.com/vt/lyrs={mapPrefix}&z={args.ZoomLevel}&x={args.X}&y={args.Y}");
       deferral.Complete();
 }
Example #34
0
 protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
 {
     var deferral = args.Request.GetDeferral();
     args.Request.Uri = new Uri($"https://api.mapbox.com/styles/v1/{ApplicationKeys.MapBoxStyle}/tiles/256/{args.ZoomLevel}/{args.X}/{args.Y}?access_token={ApplicationKeys.MapBoxToken}");
     deferral.Complete();
 }
 protected abstract void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args);
Example #36
0
        public void UpdateTileOverlay(MainViewModel viewModel, bool programatic = false)
        {
            if (!programatic)
            {
                if (viewModel.SelectedTile == null)
                {
                    viewModel.SelectedTile = StaticResources.TilesList.First;
                }
                viewModel.SelectedTile = viewModel.SelectedTile.Next ?? StaticResources.TilesList.First;
            }
            MainPage.Map.TileSources.Clear();
            // if native map, just remove the previous overlay
            if (viewModel.SelectedTile.Value.NativeMapLayer)
            {
                if (viewModel.SelectedTile.Value.Name == StaticResources.TilesHybridName)
                {
                    MainPage.Map.Style = MapStyle.AerialWithRoads;
                }
                else
                {
                    MainPage.Map.Style = MapStyle.Road;
                }
            }
            else
            {
                MainPage.Map.Style = MapStyle.None;
                var maxZoom = viewModel.SelectedTile.Value.MaxZoom;
                if (maxZoom == 0)
                {
                    maxZoom = (int)MainPage.Map.MaxZoomLevel;
                }

                if (MainPage.Map.ZoomLevel > maxZoom)
                {
                    MainPage.Map.ZoomLevel = maxZoom;
                }
                if (viewModel.SelectedTile.Value.Name == StaticResources.TilesOpenStreetMapName)
                {
                    var httpsource = new HttpMapTileDataSource(StaticResources.TilesMapnik);
                    var tilesource = new MapTileSource(httpsource)
                    {
                        Layer = MapTileLayer.BackgroundReplacement
                    };

                    MainPage.Map.TileSources.Add(tilesource);
                }
                else if (viewModel.SelectedTile.Value.Name == StaticResources.TilesOpenCycleMapName)
                {
                    var httpsource = new HttpMapTileDataSource(StaticResources.TilesMaquest);
                    var tilesource = new MapTileSource(httpsource)
                    {
                        Layer = MapTileLayer.BackgroundReplacement
                    };
                    MainPage.Map.TileSources.Add(tilesource);
                }
            }
            if (!programatic)
            {
                viewModel.TileName    = viewModel.SelectedTile.Value.Name;
                viewModel.VisualState = "normalTileName";
                viewModel.VisualState = "showTileName";
            }
            _settingsService.MapTile = viewModel.SelectedTile.Value.Name;
        }
Example #37
0
 private void TileSource_Checked(object sender, RoutedEventArgs e)
 {
     var httpsource = new HttpMapTileDataSource("http://a.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");
     var ts = new MapTileSource(httpsource)
     {
         Layer = MapTileLayer.BackgroundReplacement
     };
     map1.Style = MapStyle.None;
     map1.TileSources.Add(ts);
 }
Example #38
0
        public void UpdateTileOverlay(MainViewModel viewModel, bool programatic = false)
        {
            if (!programatic)
            {
                if (viewModel.SelectedTile == null)
                {
                    viewModel.SelectedTile = StaticResources.TilesList.First;
                }
                viewModel.SelectedTile = viewModel.SelectedTile.Next ?? StaticResources.TilesList.First;
            }
            MainPage.Map.TileSources.Clear();
            // if native map, just remove the previous overlay 
            if (viewModel.SelectedTile.Value.NativeMapLayer)
            {
                if (viewModel.SelectedTile.Value.Name == StaticResources.TilesHybridName)
                {
                    MainPage.Map.Style = MapStyle.AerialWithRoads;
                }
                else
                {
                    MainPage.Map.Style = MapStyle.Road;
                }
            }
            else
            {
                MainPage.Map.Style = MapStyle.None;
                var maxZoom = viewModel.SelectedTile.Value.MaxZoom;
                if (maxZoom == 0)
                {
                    maxZoom = (int)MainPage.Map.MaxZoomLevel;
                }
                
                if (MainPage.Map.ZoomLevel > maxZoom)
                {
                    MainPage.Map.ZoomLevel = maxZoom;
                }
                if (viewModel.SelectedTile.Value.Name == StaticResources.TilesOpenStreetMapName)
                {
                    var httpsource = new HttpMapTileDataSource(StaticResources.TilesMapnik);
                    var tilesource = new MapTileSource(httpsource)
                    {
                        Layer = MapTileLayer.BackgroundReplacement
                    };

                    MainPage.Map.TileSources.Add(tilesource);
                }
                else if (viewModel.SelectedTile.Value.Name == StaticResources.TilesOpenCycleMapName)
                {
                    var httpsource = new HttpMapTileDataSource(StaticResources.TilesMaquest);
                    var tilesource = new MapTileSource(httpsource)
                    {
                        Layer = MapTileLayer.BackgroundReplacement
                    };
                    MainPage.Map.TileSources.Add(tilesource);
                }
            }
            if (!programatic)
            {
                viewModel.TileName = viewModel.SelectedTile.Value.Name;
                viewModel.VisualState = "normalTileName";
                viewModel.VisualState = "showTileName";
            }
            _settingsService.MapTile = viewModel.SelectedTile.Value.Name;
        }
Example #39
0
 protected abstract void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args);
 protected BaseHttpTileSource()
 {
     var t = new HttpMapTileDataSource();
       t.UriRequested += MapUriRequested;
       TileSource = t;
 }