I want to view all the layers i loaded into WPFMap control in a full extent. What i mean is, In MapSuiteExplorer (Available with installer) when we add a layer it automatically loads the layer covering the whole WPFMap control.
*rectangleShapes contains all the layers co-ordinates. (rectangleShapes.Add(Layer1.GetBoundingBox()); rectangleShapes.Add(Layer2.GetBoundingBox()); rectangleShapes.Add(Layer3.GetBoundingBox());)
The above particular code is not strecthing the layers to the wpfMapControl size.
Thanks for your quick reply Ben. I am using WPFmapControl in my application to load layers. The one in the website is not helping me as they are using PictureBox control and map engine.
you can read the each layer extent by GetBoundingBox() command and then add them to collection of BaseShape, then you can use the ExtentHelper.GetDrawingExtent to obtain the full extent:
From the code of the Code Community Services edtion project, to have it working with WPF, you can use the code below. You can see that there is not a big difference:
//Function for getting the extent based on a collection of layers. //It gets the overall extent of all the layers. private RectangleShape GetFullExtent(GeoCollection<Layer> Layers) { Collection<BaseShape> rectangleShapes = new Collection<BaseShape>();
foreach (Layer layer in Layers) { layer.Open(); if (layer.HasBoundingBox == true) rectangleShapes.Add(layer.GetBoundingBox()); } return ExtentHelper.GetBoundingBoxOfItems(rectangleShapes); }
Thanks everyone for the replies. My requirement is that when u load a layer it has to strecth to the full extent of the map control as shown in the below image. Please verify the Map Suite Explorer which comes along with the installer. Regards
Hi Val, I had set my WPFControl’s height and width as 600 and 1000 respectively. Loaded 8 different shape files on the control and set the current extent as suggested in your previous post. when i debug i got current extent as {-4077.26966075121,3354.28020964718,3745.40009563083,-1339.32164418204}. Still the features in the shape files are not stretching to the my WPFControl’s height and width.
It seems like that your shapefiles have different projections.
Here is what I’m think about; you have two layers in the map, one has a bounding box of [-180 90 180 -90] while the other one has a bounding box of [-4000 3000 3000,-1000]. The first layer is using decimal degree as its map unit and the second one is using feet. You get an envelop of the two layers When using ExtentHelper.GetBoundingBoxOfItems. If this extent is set to WpfMap.CurrentExtent, the first layer will be almost invisible.
Please consult your data vendor to confirm that all your data have the same projection or you can send support@thinkgeo.com your data if it is fine.
And by the way, please make sure to call WpfMap.Refresh every time the WpfMap.CurrentExtent is changed.