I am looking for some code Explamle to show all images in a Folder on the local machine. I need to turn them on at zoomlevel 12 to 20. And turn them off 1 thru 11.
This code only shows all images all the time.
' TileCaching Code
Dim bitmapTileCache As FileBitmapTileCache = New FileBitmapTileCache
Dim NewFylovers As String = MapSetupOptionBo.MapSetFlyOverDir.Trim
When I use this Code all I get is a Black screen where the images are to Be. What am I doing wrong.
Dim bitmapTileCache As FileBitmapTileCache = New FileBitmapTileCache Dim NewFylovers As String = MapSetupOptionBo.MapSetFlyOverDir.Trim With bitmapTileCache .CacheDirectory = NewFylovers .CacheId = "Flyovers" .ImageFormat = TileImageFormat.Jpeg OverlayImage.TileCache = bitmapTileCache End With
I couldn’t figure out the problem from your code, I have a question about OverlayImage, what type of it, and how you initialize it, could you provide a sample project which I can run it to test the problem?
If I use the image list this it works fine. But if I have to many image it runs out of memory.
Dim di As New DirectoryInfo(MapSetupOptionBo.MapSetFlyOverDir.Trim) Dim aryFi As FileInfo() = di.GetFiles("*.jpg") Dim fi As FileInfo For Each fi In aryFi Dim ImageLayer As New GdiPlusRasterLayer With ImageLayer .LowerThreshold = 0 .UpperThreshold = Double.MaxValue .PathFilename = fi.FullName .IsVisible = True .Transparency = 250 .Name = “Image” ’ Add 5/25/2011 'Dim myFeatureLayer As GdiPlusRasterLayer = CType(LexusMap.FindRasterLayer(fi.FullName), GdiPlusRasterLayer) OverlayImage.Layers.Add(fi.FullName, ImageLayer) 'CreateItemInLayerOutControl(fi.FullName) End With Next
So I get load the sample code from vs2008 program. And it will not work. I do not understand how. This example does nothing. I just change your code around.
Private Sub DisplayMap_Load(ByVal sender As Object, ByVal e As EventArgs)
winformsMap1.MapUnit = GeographyUnit.DecimalDegree winformsMap1.BackgroundOverlay.BackgroundBrush = New GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
Dim worldLayer As New ShapeFileFeatureLayer("C:\EZ911NET\ez911CadMap\shape\BrantleyGACounty Road.shp") worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1 worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Dim staticOverlay As New LayerOverlay() staticOverlay.Layers.Add("WorldLayer", worldLayer) winformsMap1.Overlays.Add(staticOverlay)
Dim bitmapTileCache As FileBitmapTileCache = New FileBitmapTileCache() bitmapTileCache.CacheDirectory = "D:\EZ911Map\BrantleyGA\FlyOvers" bitmapTileCache.CacheId = "World02CachedTiles" bitmapTileCache.ReadOnly = True bitmapTileCache.ImageFormat = TileImageFormat.Png
staticOverlay.TileCache = bitmapTileCache
winformsMap1.CurrentExtent = New RectangleShape(-82.51, 31.5, 30.7, -81.13)
Thanks for your sample code, I simply change the OverlayImage.IsVisible = False to OverlayImage.IsVisible = True and it works properly. About shape files sample, from the shp name, I think it’s a LineShapes data, so you need to set LineStyle for it, such as worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway1
I have 2000 Images in a folder and when I run this code it runs out of memory. How can I load a lot of images. I did the same thing with mapobjects it did not have that limitation. How can load that many images without running out of memory ?
Dim di As New DirectoryInfo(MapSetupOptionBo.MapSetFlyOverDir.Trim)
Dim aryFi As FileInfo() = di.GetFiles("*.jpg")
Dim fi As FileInfo For Each fi In aryFi Dim ImageLayer As New GdiPlusRasterLayer With ImageLayer .LowerThreshold = 0 .UpperThreshold = Double.MaxValue .PathFilename = fi.FullName .IsVisible = True .Transparency = 250 .Name = "Image" OverlayImage.Layers.Add(fi.FullName, ImageLayer) End With Next
If you want to load them all at once, I don’t have good solution to avoid out of memory error, if not, you can do following two ways: 1, set smaller extent that only show part of them. 2, add them to different overlay and set overlay.IsVisable to control them.
Additional information, you can try to set TileCache for overlay to that it will load image file at first time, then it will load cached image which may use less memory.
For example, the entire bounding box of your images is (-100,100,100,-100), you can try to set the current extent of map to (-50,50,50,-50), just show ¼ part of the entire images.