HI,
I just started evaluate thinkgeo 5.5 as using Visual Studio 2008 to evaluate your tool.
Well i am trying to load an Shape file using the Mapcontrol.I am getting an error “You don’t have the corresponding idx file for your shape file. You can use the static method ShapeFileFeatureSource.BuildIndexFile() or ShapeFileFeatureLayer.BuildIndexFile() to build an idx file for the shape file, or you can set the RequireIndex property to false.” .Below is my code for your reference.
WinformsMap1.MapUnit = GeographyUnit.DecimalDegree
WinformsMap1.BackgroundOverlay.BackgroundBrush = New GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
Dim worldLayer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(“D:\GISPOC\NEWDATA\SHP\filename.shp”)
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
Dim staticOverlay As New LayerOverlay()
staticOverlay.Layers.Add(worldLayer)
'staticOverlay.Layers.Add(“StatesLayer”, statesLayer)
'staticOverlay.Layers.Add(“majorCitiesShapeLayer”, majorCitiesShapeLayer)
WinformsMap1.Overlays.Add(staticOverlay)
WinformsMap1.Refresh()
Can anybody please help me to solve this problem.
Loading Shape File
I manage to solve it by adding this line.But the map is not showing properly.
ShapeFileFeatureLayer.BuildIndexFile(“D:\GISPOC\NEWDATA\SHP\map.shp”)
But the map is not showing .Attached the screen shot and code for your reference.
Dim worldLayer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(“D:\GISPOC\NEWDATA\SHP\map.shp”)
'worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
’ worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.
ShapeFileFeatureLayer.BuildIndexFile(“D:\GISPOC\NEWDATA\SHP\map.shp”)
Dim staticOverlay As New LayerOverlay()
staticOverlay.Layers.Add(worldLayer)
'staticOverlay.Layers.Add(“StatesLayer”, statesLayer)
'staticOverlay.Layers.Add(“majorCitiesShapeLayer”, majorCitiesShapeLayer)
WinformsMap1.Overlays.Add(staticOverlay)
WinformsMap1.Refresh()
please help me to resolve this issue.
Hi Mohammed,
Thanks for your post and Welcome to Map Suite Forums!
I checked your codes and found there is not an extent assigned for the map. please assign the extent for the map before refresh the map, like these codes:
wpfMap1.Overlays.Add(staticOverlay);
worldLayer.Open();
wpfMap1.CurrentExtent = worldLayer.GetBoundingBox();//new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625);
wpfMap1.Refresh();
Any other questions please don’t hesitate to let us know.
Thanks,
Johnny
Still it is not working after i added the codes given by you.Do i need add exact points to show the map?.
Hi,
Try the below codes:
ShapeFileFeatureLayer.BuildIndexFile("D:\GISPOC\NEWDATA\SHP\map.shp")
WinformsMap1.MapUnit = GeographyUnit.DecimalDegree
WinformsMap1.BackgroundOverlay.BackgroundBrush = New GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)
Dim worldLayer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer("D:\GISPOC\NEWDATA\SHP\map.shp")
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1
Dim staticOverlay As New LayerOverlay()
staticOverlay.Layers.Add(worldLayer)
WinformsMap1.Overlays.Add(staticOverlay)
worldLayer.Open()
Map1.CurrentExtent = worldLayer.GetBoundingBox()
WinformsMap1.Refresh()
If it still not work, I have some questions on it:
1. Is the “map.shp” the polygon or multipolygon type?
2. Can it display in the Map Suite Explorer?(we can find the Explorer in installationfolder=> Map Suite Desktop Full Edition 7.0\Map Suite Explorer)
3. How about the StatesLayer or majorCitiesShapeLayer works?
If the issue persists, please attached the “map.shp” here.
Also, I am confused on “Do i need add exact points to show the map?”.
Thanks,
Johnny
Thanks Done…It is working now…
I need your help to solve one more issue.
Based on the above code you have provided i manage to load the shapefile .Loaded shape file is having 3 columns namely id,Name,status.I want do query inside the shp file and add a marker based on my search.How can i achieve that?.
Below is the code i used to add the marker and it is working fine.
Dim markerOverlay As SimpleMarkerOverlay = CType(WinformsMap1.Overlays(“MarkerOverlay”), SimpleMarkerOverlay)
Dim marker As New Marker(e.WorldLocation)
marker.Image = New Bitmap(“Icon url”)
’ marker.Image = My.Resources.AQUA
marker.Width = 20
marker.Height = 34
marker.YOffset = -17
markerOverlay.Markers.Add(marker)
WinformsMap1.Refresh()
I am not sure how to do search inside the shape file?.For example i want to search all items with name is ‘abc’ and add marker on all the results.
Hope to hear from you soon.
Hi,
For your requirements, We have the similar samples on HowDoI samples.
In order to query features by columnnames, please refer to "HowDoI sample => Querying Feature Layers => Find out What column data is in a feature layer". Then change the methods "GetFeaturesContaining" to "GetFeaturesByColumnNames".
In order to insert the queried features as marker, please refer to "HoDOI Sample => Markers=>Add simple markers on the map".
Hope it helps.
Johnny