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);
        }
        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);
        }
        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);
        }
        protected virtual TileDataSource CreateTileDataSource()
        {
            TileDataSource vectorTileDataSource = new CartoOnlineTileDataSource("nutiteq.osm");

            // We don't use vectorTileDataSource directly (this would be also option),
            // but via caching to cache data locally persistently/non-persistently
            // Note that persistent cache requires WRITE_EXTERNAL_STORAGE permission
            TileDataSource cacheDataSource = vectorTileDataSource;

            if (persistentTileCache)
            {
                string cacheFile = GetExternalFilesDir(null) + "/mapcache.db";
                cacheDataSource = new PersistentCacheTileDataSource(vectorTileDataSource, cacheFile);
            }
            else
            {
                cacheDataSource = new MemoryCacheTileDataSource(vectorTileDataSource);
            }

            return(cacheDataSource);
        }
Пример #5
0
        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);
        }