public override void ViewDidLoad() { base.ViewDidLoad(); AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleGray); string encoded = JsonUtils.GetTorqueQuery(); string url = "http://viz2.cartodb.com/api/v2/sql?q=" + encoded + "&cache_policy=persist"; // Define datasource with the query HTTPTileDataSource source = new HTTPTileDataSource(0, 14, url); // Create persistent cache to make it faster string cacheFile = Utils.GetDocumentDirectory() + "/torque_tile_cache.db"; TileDataSource cacheSource = new PersistentCacheTileDataSource(source, cacheFile); // Create CartoCSS style from Torque points CartoCSSStyleSet styleSheet = new CartoCSSStyleSet(JsonUtils.TorqueCartoCSS); // Create tile decoder and Torque layer decoder = new TorqueTileDecoder(styleSheet); tileLayer = new TorqueTileLayer(cacheSource, decoder); MapView.Layers.Add(tileLayer); MapView.SetZoom(1, 0); }
public MergedRasterTileDataSource(HTTPTileDataSource source1, HTTPTileDataSource source2) : base(source1.MinZoom, source1.MaxZoom) { this.source1 = source1; this.source2 = source2; paint = new Paint(); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleGray); string encoded = JsonUtils.GetTorqueQuery(); // Define datasource with the query string url = "http://viz2.cartodb.com/api/v2/sql?q=" + encoded + "&cache_policy=persist"; HTTPTileDataSource source = new HTTPTileDataSource(0, 14, url); // Create persistent cache to make it faster string cacheFile = GetExternalFilesDir(null) + "torque_tile_cache.db"; TileDataSource cacheSource = new PersistentCacheTileDataSource(source, cacheFile); // Create CartoCSS style from Torque points CartoCSSStyleSet styleSheet = new CartoCSSStyleSet(JsonUtils.TorqueCartoCSS); // Create tile decoder and Torque layer decoder = new TorqueTileDecoder(styleSheet); tileLayer = new TorqueTileLayer(cacheSource, decoder); MapView.Layers.Add(tileLayer); MapView.SetZoom(1, 0); }
Carto.Graphics.Bitmap CreateBitmap(HTTPTileDataSource source, MapTile tile) { var data = source.LoadTile(tile); if (data == null) { return(null); } return(Carto.Graphics.Bitmap.CreateFromCompressed(data.Data)); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Initialize hillshading raster data source, better visible in mountain ranges HTTPTileDataSource source1 = new HTTPTileDataSource(0, 24, TiledRasterUrl); HTTPTileDataSource source2 = new HTTPTileDataSource(0, 24, HillsideRasterUrl); MergedRasterTileDataSource mergedSource = new MergedRasterTileDataSource(source1, source2); var layer = new RasterTileLayer(mergedSource); MapView.Layers.Add(layer); // Animate map to a nice place MapView.SetFocusPos(BaseProjection.FromWgs84(new MapPos(-122.4323, 37.7582)), 1); MapView.SetZoom(13, 1); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Initialize hillshading raster data source, better visible in mountain ranges HTTPTileDataSource source1 = new HTTPTileDataSource(0, 24, TiledRasterUrl); HTTPTileDataSource source2 = new HTTPTileDataSource(0, 24, HillsideRasterUrl); MergedRasterTileDataSource mergedSource = new MergedRasterTileDataSource(source1, source2); var layer = new RasterTileLayer(mergedSource); MapView.Layers.Add(layer); // Animate map to a nice place MapView.SetFocusPos(BaseProjection.FromWgs84(new MapPos(-122.4323, 37.7582)), 1); MapView.SetZoom(13, 1); }
protected override void UpdateBaseLayer() { MapView.Layers.Clear(); if (vectorStyleTileType == "raster") { Menu.Disable("OSM"); string url = (vectorStyleName == "positron") ? Urls.Positron : Urls.DarkMatter; TileDataSource source = new HTTPTileDataSource(1, 19, url); var layer = new RasterTileLayer(source); MapView.Layers.Add(layer); } else { Menu.Enable("OSM"); string selection = Menu.GetSelectedValueOf("OSM"); CartoOnlineVectorTileLayer layer = null; if (selection == "nutiteq.osm") { if (vectorStyleName.Split(':')[1] == "default") { layer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); } else { layer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDark); } } else { var styleAsset = AssetUtils.LoadAsset(vectorStyleName + ".zip"); layer = new CartoOnlineVectorTileLayer(vectorStyleOSM, new ZippedAssetPackage(styleAsset)); } MapView.Layers.Add(layer); } }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Initialize hillshading raster data source, better visible in mountain ranges HTTPTileDataSource hillsRasterTileDataSource = new HTTPTileDataSource(0, 24, HillsideRasterUrl); // Add persistent caching datasource, tiles will be stored locally on persistent storage PersistentCacheTileDataSource cachedDataSource = new PersistentCacheTileDataSource(hillsRasterTileDataSource, GetExternalFilesDir(null) + "/mapcache_hills.db"); // Initialize a raster layer with the previous data source RasterTileLayer hillshadeLayer = new RasterTileLayer(cachedDataSource); // Add the previous raster layer to the map MapView.Layers.Add(hillshadeLayer); // Animate map to a nice place MapView.SetFocusPos(BaseProjection.FromWgs84(new MapPos(-122.4323, 37.7582)), 1); MapView.SetZoom(13, 1); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Initialize hillshading raster data source, better visible in mountain ranges HTTPTileDataSource tileSource = new HTTPTileDataSource(0, 24, HillsideRasterUrl); // Add persistent caching datasource, tiles will be stored locally on persistent storage PersistentCacheTileDataSource cachedSource = new PersistentCacheTileDataSource(tileSource, Utils.GetDocumentDirectory() + "mapcache_hills.db"); // Initialize a raster layer with the previous data source RasterTileLayer hillshadeLayer = new RasterTileLayer(cachedSource); // Add the previous raster layer to the map MapView.Layers.Add(hillshadeLayer); // Animate map to a nice place MapView.SetFocusPos(BaseProjection.FromWgs84(new MapPos(-122.4323, 37.7582)), 1); MapView.SetZoom(13, 1); }
Carto.Graphics.Bitmap CreateBitmap(HTTPTileDataSource source, MapTile tile) { return(Carto.Graphics.Bitmap.CreateFromCompressed(source.LoadTile(tile).Data)); }
void UpdateBaseLayer(Section section, string selection) { if (section.Type != SectionType.Language) { currentOSM = section.OSM.Value; currentSelection = selection; } if (section.Type == SectionType.Vector) { if (currentOSM == "nutiteq.osm") { // Nutiteq styles are bundled with the SDK, we can initialize them via constuctor if (currentSelection == "default") { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); } else if (currentSelection == "gray") { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleGray); } else { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDark); } } else if (currentOSM == "mapzen.osm") { // Mapzen styles are all bundled in one .zip file. // Selection contains both the style name and file name (cf. Sections.cs in Shared) string fileName = currentSelection.Split(':')[0]; string styleName = currentSelection.Split(':')[1]; // Create a style set from the file and style BinaryData styleAsset = AssetUtils.LoadAsset(fileName + ".zip"); var package = new ZippedAssetPackage(styleAsset); CompiledStyleSet styleSet = new CompiledStyleSet(package, styleName); // Create datasource and style decoder var source = new CartoOnlineTileDataSource(currentOSM); var decoder = new MBVectorTileDecoder(styleSet); currentLayer = new VectorTileLayer(source, decoder); } ContentView.Menu.LanguageChoiceEnabled = true; ResetLanguage(); } else if (section.Type == SectionType.Raster) { // We know that the value of raster will be Positron or Darkmatter, // as Nutiteq and Mapzen use vector tiles // Additionally, raster tiles do not support language choice string url = (currentSelection == "positron") ? Urls.Positron : Urls.DarkMatter; TileDataSource source = new HTTPTileDataSource(1, 19, url); currentLayer = new RasterTileLayer(source); // Language choice not enabled in raster tiles ContentView.Menu.LanguageChoiceEnabled = false; } else if (section.Type == SectionType.Language) { if (currentLayer is RasterTileLayer) { // Raster tile language chance is not supported return; } UpdateLanguage(selection); } MapView.Layers.Clear(); MapView.Layers.Add(currentLayer); ContentView.Menu.Hide(); currentListener = null; currentListener = MapView.InitializeVectorTileListener(VectorLayer); }
void UpdateBaseLayer(Section section, string selection) { if (section.Type != SectionType.Language) { currentOSM = section.OSM.Value; currentSelection = selection; } if (section.Type == SectionType.Vector) { if (currentOSM == "nutiteq.osm") { // Nutiteq styles are bundled with the SDK, we can initialize them via constuctor if (currentSelection == "default") { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); } else if (currentSelection == "gray") { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleGray); } else { currentLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CartoBasemapStyleDark); } } else if (currentOSM == "mapzen.osm") { // Mapzen styles are all bundled in one .zip file. // Selection contains both the style name and file name (cf. Sections.cs in Shared) string fileName = currentSelection.Split(':')[0]; string styleName = currentSelection.Split(':')[1]; // Create a style set from the file and style BinaryData styleAsset = AssetUtils.LoadAsset("styles/" + fileName + ".zip"); var package = new ZippedAssetPackage(styleAsset); CompiledStyleSet styleSet = new CompiledStyleSet(package, styleName); // Create datasource and style decoder var source = new CartoOnlineTileDataSource(currentOSM); var decoder = new MBVectorTileDecoder(styleSet); currentLayer = new VectorTileLayer(source, decoder); } Menu.LanguageChoiceEnabled = true; ResetLanguage(); } else if (section.Type == SectionType.Raster) { // We know that the value of raster will be Positron or Darkmatter, // as Nutiteq and Mapzen use vector tiles // Additionally, raster tiles do not support language choice string url = (currentSelection == "positron") ? Urls.Positron : Urls.DarkMatter; TileDataSource source = new HTTPTileDataSource(1, 19, url); currentLayer = new RasterTileLayer(source); // Language choice not enabled in raster tiles Menu.LanguageChoiceEnabled = false; } else if (section.Type == SectionType.Language) { if (currentLayer is RasterTileLayer) { // Raster tile language chance is not supported return; } UpdateLanguage(selection); } MapView.Layers.Clear(); MapView.Layers.Add(currentLayer); Menu.Hide(); currentListener = null; currentListener = MapView.InitializeVectorTileListener(VectorLayer); }