ThinkGeo.com    |     Documentation    |     Premium Support

World layer not showed completly


When using map control in meters, the country layer dont show completly when zooming out, with white backgorund

have fun to find the correct region :)


The country contours are visible when zoom in (blue).


I have made some screenshot where the google layer is enabled,


 



Lars,


This is a known issue for Projection; One way to go around this is pre-project the data instead of projecting it on the fly.
 
Following code shows the way, hope it helps:

     Proj4Projection proj4 = new Proj4Projection();
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
            proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

            string shapeFile = @"..\..\Countries02.shp";
            string googleShapeFile = @"..\..\googleCountries02.shp";
            ShapeFileFeatureSource.SaveToProjection(shapeFile, googleShapeFile, proj4, OverwriteMode.Overwrite);

            winformsMap1.MapUnit = GeographyUnit.Meter;

            ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(googleShapeFile);
            shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            GoogleMapsLayer layer = new GoogleMapsLayer(@"ABQIAAAAX_L0oJKT0IU2n0u0qxcr3BR3rCYD_eVzP3e6DX1YTr2ah9RbohStaDJYLxi99hL16CJfmL4rjnw9wA", "C:\\ImageCache");

            LayerOverlay backgroundOverlay = new LayerOverlay();
            backgroundOverlay.Layers.Add("layer", layer);
            backgroundOverlay.Layers.Add("WorldLayer", shapeFileLayer);

            winformsMap1.Overlays.Add("BackgroundOverlay", backgroundOverlay);


            winformsMap1.CurrentExtent  = new RectangleShape(-20000000, 20000000, 20000000, -20000000);


            winformsMap1.Refresh();

 

Any more questions please feel free to let me know.
Thanks.
 
Yale


Hi 
  
 Now its an known issue :), its work great now thanks

Lars, 
  
 We want to use the index file we created for the shape file for speed.  The issue is that the index uses bounding boxe rectangle and when you project them they tend to twist and mangle. If you just get the bounding box of the mangles box then it is not correct and at higher extents it is very obvious.  It is a difficult problem with no known solution as of yet except to re-project the data or to use the data without an index which is slow.  It all really depends on the projects etc, for UTM and State plane which are used very often at lower extents it is not a big deal because the twisting is  very minor bad but in other projections it gets radical.  It is something we are still putting some brainpower on but have yet to come up with something turnkey for the users. 
  
 David

Thanks for the explanation. 
 /Lars

Lars, 
  
   No problem.  I felt compelled as this issue really ticks me off! 
  
 David

When adding InMemoryLayers at runtime, and then changeing extent or pan, sometimes the InMemolayers are not drawed. 
 Setting the layer IsVisible to false and the true again draws the layer, but this gives the map 3 refresh… performence :( 
  
 All my layer are projectet to meters, so that i can use the google overlay, i don’t want all my layer to be stored as files. 
  
 Any idea ?

Lars,


I am curious why the map need 3 refresh when changing the layer IsVisible status.
 
Attachment contains a demo for this to turn on and off the InMemoryFeatureLayer over the Google Layer.
 
Please feel free let me know if any more questions!
 
Thanks.
 
Yale

1148-Post6239.zip (11 KB)

Hi 
 The problem is not to set invisible, but that the InMemory layers not always are drawed correct (missing bitmap etc.) 
 The 3 refresh, first when the layer is populated, second to turn layer off, third layer on 
  
 If you zoom the the map draws the layers correct "must" of the times. 


Lars, 
  
 Thanks for your explanation! 
  
 Could you provide us some sample codes to recreate your problem? Basically, is it possible by changing some codes (for example, change the InmemoryLayer) in the attachment sample above to show your problem? 
  
 Please feel free let me know if any more questions! 
  
 Thanks. 
  
 Yale 


Hi 



Have made some screenshoots, the problem is in the bitmap layer. 



To recreate problem, zoom intoworld map, insert some bitmaps and then zoom up/down. ( I insert about 400 points around world, most europe) 

Some time the map only displays some, all and none.


Only zoom up/down add removes icons, panning at same zoom, dosen't make any difference.



OnLoad 

winMap.Overlays.Add("WindFarmLayer", AddBitmapLayer("WindFarmLayer", VSU.Common.Ressources.Images.MapWindFarm, googleProjection)); 

MapWindFarm is an 16x16 png image. 





private static LayerOverlay AddBitmapLayer(string name, VSU.Common.Ressources.Images image, Projection googleProjection) 



var overlay = new LayerOverlay(); 

var layer = new InMemoryFeatureLayer(); 

layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap; 

layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = new GeoImage (VSU.Common.Ressources.ImageMgr.Instance.GetImageAsStream(image)); 

layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 

layer.FeatureSource.Projection = googleProjection; 



overlay.Layers.Add(name, layer); 

return overlay; 





the layer is populated in an aysnc. callback. 



private void m_vdcService_GetWindFarmItemsCompleted(object sender, VDCWindFarmItemEventArgs e) 



if (InvokeRequired) 



BeginInvoke(new EventHandler<vdcwindfarmitemeventargs></vdcwindfarmitemeventargs>(m_vdcService_GetWindFarmItemsCompleted), new object[] { sender, e }); 



else 



btnShowWindFarms.Enabled = true; 

progressControl.Visible = false; 

progressControl.Stop(); 



if (e.Items.Count > 0) 



winMap.Overlays["WindFarmLayer"].Lock.EnterWriteLock(); 

try 



InMemoryFeatureLayer pointLayer = (InMemoryFeatureLayer)winMap.FindFeatureLayer("WindFarmLayer"); 





foreach (WindFarmItem item in e.Items) 



Feature feature = new Feature(item.Longitude, item.Latitude, item.GetHashCode().ToString()); 

pointLayer.InternalFeatures.Add(item.GetHashCode().ToString(), feature); 





finally 



winMap.Overlays["WindFarmLayer"].Lock.ExitWriteLock(); 





winMap.Refresh(); 

m_windFarmsLoaded = true; 



else 



btnShowWindFarms.CheckState = CheckState.Unchecked; 









 


Pictures are at different zoom levels.


europe empty :(



 


Total blackout




Testet with version 3.0.411 same problem 
 /Lars

Lars, 
  
 One dumb question is in the OnLoad for the form do you set the Map.MapUnit = Meters?  The default for the map is decimal degrees and there are a number of math function where it counts.  This might cause the scale calculation to be incorrect.  Can you try this and let me know the results. 
  
 The other thing I would try is to not pass in the google projection to the layer and when you add the windmills in your method create a google maps projection class and project the points themselves and add them into the in memory layer already projected.  I bet that does the trick. 
  
 David

Hi 
  
 My map is in meters :) 
 I have tried to insted of setting the googleProjection on the feature layer, to convert my points to meters when adding, this make a 
 huge difference, now i works. 
  
 When setting the projection on an layer, i will still aspect it to do the conversion for me, please correct me if i’m wrong. 
  
 But problem solved for now ;)

Lars,   
  
 I am glad to see that working for you.  I intended it only to get you up and running.  It is actually more effecient this way as you don’t need to re-project the points over and over as you draw.  I bet the issues has to do with the extent being re-projected on the fly to figure out of the in memory feature set is in the right area.  Could you do me a favor and send in some of the points you are using and I will try and re-create the issues here.  This could really help us find out what the real problem is.  I already know the projection etc so I just need your points.  You can send them to support@thinkgeo.com and hhave them send it to David and Yale please. 
  
 David