How do I set an initial map extent? In the getting started sample the CurrentExtent is set to a RectangleShape. Is there a way to determine this from my shape layer?
I am trying to display a single line layer but nothing is being displayed. I have copied code from the getting started app and changed a few lines to suit my line style. I don't know the initial erxtent to set. I'm sure V2 used to automatically work out the best extent to set intially?
What am I doing wrong?
I can send the shape file if required. It worked fine under V2 and loads in map explorer. Here is my code.
winformsMap1.MapUnit = GeographyUnit.Meter;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"D:\KernMobileGisData\MoretonBay V3\Assets\MBRC_Roadcentreline.shp");
I think Val’ suggestion is correct, I doubt there are some problems in your shape file data recording its bounding boxes, while it is wield that in V2 it is correct.
How many layers are you trying to use? Could you debug out all their bounding boxes as well as the currentExtent for the MapControl to double check their ranges?
MapSuiteExplorer works in V3 and V2 (see attachment MapSuiteExplorer)
This is the code I try in V3, maybe I miss something ?
Dim layer As New ShapeFileFeatureLayer("P:\Maps\SECTION.shp") layer.Name = "Sections" layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1 layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Thanks for your reply and clear explanations. I think the problem lies in the CurrentExtent Set to the winformsMap1 is not correct.
Try to set a definite value for the extent, it should works. winformsMap1.CurrentExtent = new RectangleShape(734038.15, 200341.63, 739113.83, 195432.97);
So, one possible reason is that the Function ExtentHelper.GetBoundingBoxOfItems did not return back a correct Rectangle Shape? I tested the following code, and the returning rectangleShape is exactly the same with baseShape.
BaseShape baseShape = new RectangleShape(734038.15, 200341.63, 739113.83, 195432.97); Collection<BaseShape> rectangleShapes = new Collection<BaseShape>(); rectangleShapes.Add(baseShape);
Then, I think the problem is in setting the CurrenExtent for winformsMap. What is the width and height for your MapControl? It is obvious not right there is huge difference between the extent you set with the final result extent of the MapControl.
I dispatched the shapes to test V2 and V3 in different folders (it seems there is index conflict), but this doesn't change the result. I tried with other shapes, same behaviour.
I notice that the ScaleLineAdornmentLayer (MapSuiteExplorer) is wrong ! maybe it is linked with the extent problem ?
I do not think this problem is related with the AdormentLayer. If possible, could you pack up your small sample application and send to recreate it? I do not think the data needed to be packed, as you say this problem will lies whatever the data is.
I think in my enviroment it is correct. When it is first start up, it is blank because you did not add any layers then, after click on the parcelles, the map will show all the maps with full extent. I use the following test data: Dim shapeFile As String = "C:\Program Files\ThinkGeo\Map Suite Desktop Full Edition 3.0\Samples\SampleData\Data\Countries02.shp"
Could you have atry to remove the "SplitContainer1" in your sample and have a try?
Let me interject in this conversation. by looking at the project Zoom To Full Extent of the Code Community, code.thinkgeo.com/projects/show/zoomtofullextent, I used your attached shapefile in a sample app. I have it working just fine with the Dock property set to Fill for the map. The behavior of the map when resizing the form is as expected. See my code below. I hope this is going to help:
//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); }