public override void ViewDidLoad() { base.ViewDidLoad(); // Add default base layer AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStyleVoyager); // Load ground overlay bitmap //Bitmap androidMarkerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.jefferson); //com.carto.graphics.Bitmap overlayBitmap = BitmapUtils.createBitmapFromAndroidBitmap(androidMarkerBitmap); Bitmap overlayBitmap = BitmapUtils.LoadBitmapFromFile("jefferson-building-ground-floor.jpg"); // Create two vectors containing geographical positions and corresponding raster image pixel coordinates. // 2, 3 or 4 points may be specified. Usually 2 points are enough (for conformal mapping). MapPos pos = BaseProjection.FromWgs84(new MapPos(-77.004590, 38.888702)); double sizeNS = 110; double sizeWE = 100; MapPosVector mapPoses = new MapPosVector(); mapPoses.Add(new MapPos(pos.X - sizeWE, pos.Y + sizeNS)); mapPoses.Add(new MapPos(pos.X + sizeWE, pos.Y + sizeNS)); mapPoses.Add(new MapPos(pos.X + sizeWE, pos.Y - sizeNS)); mapPoses.Add(new MapPos(pos.X - sizeWE, pos.Y - sizeNS)); ScreenPosVector bitmapPoses = new ScreenPosVector(); bitmapPoses.Add(new ScreenPos(0, 0)); bitmapPoses.Add(new ScreenPos(0, overlayBitmap.Height)); bitmapPoses.Add(new ScreenPos(overlayBitmap.Width, overlayBitmap.Height)); bitmapPoses.Add(new ScreenPos(overlayBitmap.Width, 0)); // Create bitmap overlay raster tile data source BitmapOverlayRasterTileDataSource rasterDataSource = new BitmapOverlayRasterTileDataSource( 0, 20, overlayBitmap, BaseProjection, mapPoses, bitmapPoses ); RasterTileLayer rasterLayer = new RasterTileLayer(rasterDataSource); MapView.Layers.Add(rasterLayer); // Apply zoom level bias to the raster layer. // By default, bitmaps are upsampled on high-DPI screens. // We will correct this by applying appropriate bias float zoomLevelBias = (float)(Math.Log(MapView.Options.DPI / 160.0f) / Math.Log(2)); rasterLayer.ZoomLevelBias = zoomLevelBias * 0.75f; rasterLayer.TileSubstitutionPolicy = TileSubstitutionPolicy.TileSubstitutionPolicyVisible; MapView.SetFocusPos(pos, 0); MapView.SetZoom(15.5f, 0); }
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); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // USGS Base map: http://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer string url = "http://basemap.nationalmap.gov/arcgis/services/USGSTopo/MapServer/WmsServer?"; string layers = "0"; HttpWmsTileDataSource wms = new HttpWmsTileDataSource(0, 14, BaseProjection, false, url, "", layers, "image/png8"); RasterTileLayer wmsLayer = new RasterTileLayer(wms); // Calculate zoom bias, basically this is needed to 'undo' automatic DPI scaling, // we will display original raster with close to 1:1 pixel density double zoomLevelBias = Math.Log(MapView.Options.DPI / 160) / Math.Log(2); wmsLayer.ZoomLevelBias = (float)zoomLevelBias; MapView.Layers.Add(wmsLayer); // Animate map to map coverage MapView.SetFocusPos(BaseProjection.FromWgs84(new MapPos(-100, 40)), 1); MapView.SetZoom(5, 1); }