private void AddRasterLayers(IEnumerable <string> fileNames) { foreach (string fileName in fileNames) { try { string layerName = new FileInfo(fileName).Name; if (!((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(layerName)) { RasterLayer rasterLayer = null; switch (Path.GetExtension(fileName).ToUpperInvariant()) { case ".SID": rasterLayer = new MrSidRasterLayer(fileName); break; case ".ECW": rasterLayer = new EcwRasterLayer(fileName); break; case ".JP2": rasterLayer = new Jpeg2000RasterLayer(fileName); break; case ".BMP": case ".JPG": case ".JPEG": case ".GIF": case ".TIFF": case ".TIF": rasterLayer = new GdiPlusRasterLayer(fileName); break; default: break; } if (rasterLayer != null && ExplorerHelper.ValidateRasterLayer(rasterLayer)) { rasterLayer.Name = layerName; winformsMap1.Overlays[0].Lock.EnterWriteLock(); try { ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Add(layerName, rasterLayer); } finally { winformsMap1.Overlays[0].Lock.ExitWriteLock(); } SetupThemeItem(rasterLayer); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0); } } }
private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-122, 74, 106, -62); GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(@"world.tif"); ((GdiPlusRasterSource)(worldImageLayer.ImageSource)).StreamLoading += new EventHandler <StreamLoadingEventArgs>(MainForm_StreamLoading); worldImageLayer.UpperThreshold = double.MaxValue; worldImageLayer.LowerThreshold = 0; worldImageLayer.IsGrayscale = false; LayerOverlay testOverlay = new LayerOverlay(); testOverlay.Layers.Add("worldImageLayer", worldImageLayer); winformsMap1.Overlays.Add("testOverlay", testOverlay); winformsMap1.Refresh(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.DisplayASimpleMap); GdiPlusRasterLayer radarImageLayer = new GdiPlusRasterLayer(SampleHelper.GetDataPath(@"Gif/EWX_N0R_0.gif")); radarImageLayer.UpperThreshold = double.MaxValue; radarImageLayer.LowerThreshold = 0; radarImageLayer.Open(); LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add(radarImageLayer); layerOverlay.TileType = TileType.MultiTile; androidMap = FindViewById <MapView>(Resource.Id.androidmap); androidMap.Overlays.Add(layerOverlay); androidMap.MapUnit = GeographyUnit.DecimalDegree; androidMap.CurrentExtent = radarImageLayer.GetBoundingBox(); SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType()); }