I want to Implement Draw Features based on value. For this I have taken reference from How Do I Samples. But when I am trying to Implement this on my map, its throw an exception "TargetInvocationException was unhandled" Exception has been thrown by the target of an invocation. I also set the processor affinity. How can I do, please help
I am not quite sure about the requirement; it definitely would be helpful and useful if you could make it clearer.
1)What kind of data are you using against? It is tab file or shape file? 2)Are you using a customized layer? If yes, it is possible to show us the code.
Any more questions please feel free to let me know
I am using the Tab file. I am using the TabFileFeatureLayer to display my Tab file and its working perfactly.
Now I want to display my tab file based on its feature value. I used code like below
Dim customLineStyle As Style = New LineStyle(New GeoPen(GeoColor.SimpleColors.Black, 1)) Dim customAreaStyle As Style = New AreaStyle(New GeoPen(GeoColor.SimpleColors.Black, 1)) Dim customPointStyle As Style = New PointStyle(PointSymbolType.Star, New GeoSolidBrush(GeoColor.SimpleColors.LightGreen), 10)
’ Draw a feature based on a value Dim valueStyle As New ValueStyle() valueStyle.ColumnName = “Vector_Class” valueStyle.ValueItems.Add(New ValueItem(“Primary_roads”, LineStyles.MajorRoad1)) valueStyle.ValueItems.Add(New ValueItem(“Secondary_roads”, LineStyles.SecondaryRoad1)) valueStyle.ValueItems.Add(New ValueItem(“Water”, AreaStyles.Water1))
Can you send your tab file to us so that we can track and debug your problem exactly? If your tab file is too large to attach please send it to support@thinkgeo.com.
I have attached MapSuiteFeatures.rar file with my ticket no 3370.
1. Click on button Load File. It will load the tab file. Now remove remarks on
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle) now it will throw exception.
2. Click on load col button, it will load the column in drop down. 3. Select Vector_Class from Drop down. 4. Click on button Show Feature, it will show the features on map. You can see with zoom. 5. Click on show Data Button, it will throw an exception. The purpose of this button is load Vector_Class data into grid.
I reproduced your problem properly and I'm looking for a solution for you,currently can you use the InMemoryFeatureLayer to instead of the TabFileFeatureLayer temporarily, because about the Tab file support we used the third part maybe there are several issues. Our team is working on the tab file support ourselves and we will not be dependented on the third part. This ability will going to the May public release, please just wait several days and I think we can have a good support for tab file then.
Here is the work around for using InMemoryFeatureLayer to instead of the TabFileFeatureLayer below:
Dim version As String = WinformsMap.GetVersion System.Windows.Forms.Cursor.Current = Cursors.WaitCursor Dim worldLayer As New TabFileFeatureLayer("C:\Users\user\Desktop\ThinkGeo\Ticket3370\MapSuiteFeatures\MapSuiteFeatures\MapSuitFeatures\MapSuitFeatures\vector.TAB", Nothing)
'Dim worldLayer As New CustomFeatureLayer("C:\Users\user\Desktop\ThinkGeo\Ticket3370\MapSuiteFeatures\MapSuiteFeatures\MapSuitFeatures\MapSuitFeatures\vector.TAB")
'worldLayer.Open() ''Dim strings As Collection(Of String) = New Collection(Of String) ''strings.Add("Vector_Class") 'worldLayer.FeatureSource.GetFeaturesInsideBoundingBox(New RectangleShape(71.4341527265625, 34.2687417226563, 86.7337132734375, 23.8877602773438), ReturningColumnsType.AllColumns)
worldLayer.Open() Dim features As Collection(Of Feature) = worldLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns) 'worldLayer.Close()
Dim inMemoryFeatureLayer As InMemoryFeatureLayer = New InMemoryFeatureLayer() inMemoryFeatureLayer.Open() inMemoryFeatureLayer.Columns.Add(New FeatureSourceColumn("Vector_Class"))
For Each Feature In features inMemoryFeatureLayer.InternalFeatures.Add(Feature) Next
inMemoryFeatureLayer.Close()
Dim customLineStyle As Style = New LineStyle(New GeoPen(GeoColor.SimpleColors.Black, 1)) Dim customAreaStyle As Style = New AreaStyle(New GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.SimpleColors.Green))) Dim customPointStyle As Style = New PointStyle(PointSymbolType.Star, New GeoSolidBrush(GeoColor.SimpleColors.LightGreen), 10) Dim customTextStyle As Style = New TextStyle ' Draw a feature based on a value Dim valueStyle As New ValueStyle() valueStyle.ColumnName = "Vector_Class" valueStyle.ValueItems.Add(New ValueItem("primary_roads", LineStyles.MajorRoad1)) valueStyle.ValueItems.Add(New ValueItem("secondary_roads", LineStyles.SecondaryRoad1)) valueStyle.ValueItems.Add(New ValueItem("water", AreaStyles.Water1))
Dim overlay As New LayerOverlay() overlay.Layers.Add(inMemoryFeatureLayer) WinformsMap1.Overlays.Add(overlay)
WinformsMap1.Refresh()
The code above is used to the Load function in your application, also you have to change the code for the other functionalities in your application for InMemoryFeatureLayer.
Actually I developed application based on Tab File Feature Layer, so it will not possible to change code, if large change is required on code level? So, it will be better, I will wait some more days. When new release will come on may, then we can try to implement this. Please inform me after release.
Now the new version is release, can we draw features (line color of map for Primary road, secondary road, railway, water etc) based on column value. If yes, then please guide me, because its an important requirement for my project.
We added new features for TabFileFeatureLayer in the new public release, so you can add, edit and delete features for a TabFileFeatureLayer. For your current requirements, you need to use the ValueStyle to draw the features for different types based on column value, currently, please just use the code what I ever posted to you temporarily, according to my test, there are still any problems when using the ValueStyle for TabFileFeatureLayer. I have posted it to the development team any responses I will let you know,
I checked the attached jpg file and I cannot see the detail exception information from the jpg file, from the attached jpg file I think you used my solution to implement your requirements, can you make a sample with your tab file to us so that we can track where is the exact problem in your application?
In addition, I would like to ask you what’s the version number of Desktop Edition you used? The latest version is 5.0.0.18.
We have fixed the bug for the ValueStyle when using the TabFileFeatureLayer, now you don't need to use the InMemoryFeatureLayer in your application, you can use the ValueStyle to draw the different roads for your tab file directly. Please get the latest version 5.0.18.0 from the DailyBuild of development branch to try again,