I am trying to set my own zoom levels, but it isn't working out very well.
When I load my GdiPlusRasterLayer, I call GetBoundingBox() on the layer and then calculate a rect about twice the size of the BoundingBox. I set that new larger rect as the CurrentExtent of the Map. That seems to work as I want.
I then take Map.CurrentScale and set that to be the scale of ZoomLevel01. I then run thru the other 19 ZoomLevels and set each one to be 70% of the value of the previous one. (so ZoomLevel02.Scale = 70% of ZoomLevel01.Scale, ZoomLevel03.Scale = 70% of ZoomLevel02.Scale, etc).
In my case, ZoomLevel01.Scale is 1126.46 and ZoomLevel20.Scale is 1.28
When I display the Map, things look OK, but only the first 5 Zoom Levels seem to work via scroll wheel. (ie ZoomLevel01 to ZoomLevel05) The scale for ZoomLevel05 is 270.46 and the scale for ZoomLevel06 is 189.32 (not that ZoomLevel06 seems to be available).
RasterLayer.Open(); RectangleShape rect = RasterLayer.GetBoundingBox(); RasterLayer.Close();
LayerOverlay ImageOverlay1 = new LayerOverlay(); ImageOverlay1.Layers.Add("RasterLayer", RasterLayer); Map.Overlays.Add(ImageOverlay1); BaseOverlays.Add(ImageOverlay1); //a List<Overlay> I have for housekeeping
//Load world file, run to the last 2 lines, convert them to UTM and write out a temp worldfile StreamReader inFile = new StreamReader(worldFilePath); string tempFile = System.IO.Path.GetTempFileName(); StreamWriter outFile = new StreamWriter(tempFile); double para1 = Convert.ToDouble(inFile.ReadLine()); double para2 = Convert.ToDouble(inFile.ReadLine()); double para3 = Convert.ToDouble(inFile.ReadLine()); double para4 = Convert.ToDouble(inFile.ReadLine()); double lon = Convert.ToDouble(inFile.ReadLine()); double lat = Convert.ToDouble(inFile.ReadLine());
Thank you for sending the code. I see that it is a little more complex than anticipated. If you don’t mind, can you package it into a self contained sample app we can run? Since you know better then us your code, I think that it would take you less time for you to do that than for us, so that we can focus on solving the problem. Thank you.
Not a problem Val. I already had one partly build because of another issue currently with thinkGeo's development team.
When you run this application, click on "Make a Tab" and you will get a tab that has a raster pre-loaded using the code in my post. Using the scroll whell, notice that only ZoomLevel01 thru ZoomLevel09 are available.
I looked at your sample app and it seems to me that the incorrect behavior is that it prevents you from zooming in. I think that by simply setting the property MinimunScale of the Map to 0, it is going to solve your problem. So in your code, simply add the line for the MinimumScale as below and it should work. I hope this solves your problem.
Map = new WinformsMap(); this.Controls.Add(Map); Map.Dock = DockStyle.Fill; Map.MapUnit = GeographyUnit.DecimalDegree; Map.MinimumScale = 0; Map.Disposed += new EventHandler(Map_Disposed);
I am glad this helped you. Also, i want to make you aware of a Code Community sample we have on setting Custom Zoom Levels. You might be interested in checking that out, GetZoomLevel.