I am developing an application. It contains a module where I have to use DataTable to store some database. How can I highlight / display the features(data) in the DataTable on the map?
Or else even if we click on a sigle row(selected row) of DataTable , how to display corresponding feature on map ?
I am sorry to say that I might misunderstand you by not getting results back from the API. If you want to highlight some specified features, please take a reference on the following HowDoI sample, I think it is doing what we want to achieve: HowDoI\ Dynamic Shapes\ Highlight A Feature On The Map
Any more questions please feel free to let me know.
LayerOverlay highlightOverlay = new LayerOverlay(); highlightOverlay.Layers.Add("HighlightLayer", highlightLayer); winformsMap1.Overlays.Add("HighlightOverlay", highlightOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-165.7421875, 80.23046875, -35.6640625, 13.08203125); winformsMap1.Refresh();
worldLayer.Open(); DataTable dataTable = worldLayer.QueryTools.ExecuteQuery("Select * from USStates Where PERIMETER > 30 Order by PERIMETER"); worldLayer.Close();
I think Scott has hooked up an event for the DataGridView in the following way, so in the dgridResult_SelectionChanged event, we can convert the sender into DataGridView as he has suggested.
dgridResult.SelectionChanged += new EventHandler(dgridResult_SelectionChanged);
I am not quite understood what do you mean by generalized the column? We can change it to a specified reasonable column value if we want. Any more questions please feel free to let me know.
In the above code, we are using "RECID" field. So the code will work only for the files whose database contains the field "RECID". But there are some files which does not contain "RECID" field. They might contain "PROPERTYNO" or anything different.
How to make the above code flexible so that it can support any files ???
I just give you the sample snippet, you can change the sample code according to your mind, for example, if the columns contains the "PROPERTYNO" or anything else, you just need to change this code to:
I guess you misunderstood the question. Sorry for that.
In the above statement, you have entered "PROPERTYNO" in the column field. So this is something we had hardcoded it . Is there any other way wherein the application should take on the primary key(column) itself accordingly . We need not pass it.
I do not quite understand exactly what do you mean by “Primary key”, as all the columns are the same status which is different with the SQL Server table. While, we definitely can make it automatically find the target column, following code snippet shows you how to find the middle column in sequence.
InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer(); highlightLayer.Open();
int midCount = highlightLayer.GetColumns().Count /2; string name = highlightLayer.GetColumns()[midCount].ColumnName;
Any more questions please feel free to let me know.
One more doubt !!! In the code, you have mentioned "RECID" which is unique for each record (row) for that particular file(USStates.shp). i.e. No two rows have same "RECID".
So how to code to find such fields having unique values for every rows.
Or should I generate a column named suppose "UID" at the time of creation of the DataTable and assign it values serially so each row will have a separate n unique key of itself.
I have another question !!! In the above code, we can select only one row at a time and highlight the corresponding feature. How can we select multiple rows at a time using "Ctrl+MouseClick" and highlight correspondingly ??
I have attached a snapshot. In this, when we click on a row the corresponding feature gets highlighted. This code is mentioned by you above. Now I need some modifications. Here we were selecting a single row. But now I need to select multiple rows. How can I do this ??
I am curious what control are you using to hold the data in the “Attributes of States”? Could you provide us a sample to show how you implement the single row highlighted? If you want, you can attach the sample to the discussion form or send it to our support (support@thinkgeo.com) and ask to forward to Scott and Yale for this post.
Any more questions please feel free to let me know.