ThinkGeo.com    |     Documentation    |     Premium Support

Questions re: interactive features and pointshapes

Hello, I am currently evaluating ThinkGeo for a GIS view in one of our products. Playing with the library, I've made some progress, but have the following questions:


1. I need a layer to display images on the map (e.g. aircraft, radar, etc.) I have been able to use the InMemoryFeatureLayer to set up layers for each of my icon types, but was wondering if that is the best way to approach this problem.


2. I need to be able to click on a feature that is a bitmap and have some way of indicating it is the selected item. I can get the click event to show me the selected feature, but I can't find any way to modify the image (e.g. selection handles, different background) to indicate that the feature is selected. How do I do that?


3. Once a feature is added to my InMemoryLayer and it is selected, is there a way to drag it to reposition it on the map? If not, can I set some property values to reposition it?  Every time I try to use the EditTools to update the PointShape position, the icon is never moved and when I click back onto the map control, I get an unhandled exception relating to a bad/missing key in an underlying collection.


From what I've seen, the map suite looks like it can do what I want/need, I'm just not sure how best to implement it. Your API documentation seems to be missing a lot of useful information but your getting started guides are a bit too simplistic. (Just thought I'd provide that unsolicited feedback from a prospective customer). For example, I have no idea what all the differences are between all of the different layer and overlay classes. Thanks in advance for any help or guidance.


Also, I tried to post this on the forums using Google's Chrome browser, but it failed to accept the new post, and never provided any information other than an exclamation icon near the subject name. 



 Everything that you are describing in your post can be accomplished with Map Suite. We have a class EditInteractiveOverlay that has the flexibility to handle the cases you have. This afternoon, our support team will put together a sample app responding to your requirements. In the meantime, I suggest you look at some of the projects of the Code Community. For example, we have the project "Dragged PointStyle" that you might like. While this does not respond exactly to your case, you can have an idea of what can be done with EditInteractiveOverlay in relation to selecting and dragging features.


code.thinkgeo.com/projects/show/draggedpointstyle



First, thank Val for your sharing. 



Robert, 



I agree with Val, everything that you describing can be accomplished with Map Suite. 



The following is my comments for your questions: 

1. That depends on the magnitude of icons, if just few layers need be set up, I think your way of doing it is not bad. But if you need to set up too many layers, I suggest you can try to use ValueStyle to assign different icon to feature by column values, it may more complicate than your way but more effective. If you are not familiar with ValueStyle and don’t know how to use it from the document, you can look at our HowDoI sample DrawAFeatureBasedOnAValue which is under Styles catalog. 



2. First, you will need to find the corresponding layer for a specific feature. You can use the feature’s ID or a column value; each identical ID or value is according to one layer. When mouse click event is raised you can find the feature by calling GetFeaturesNearestTo method in QueryTools and passing in the mouse position in world coordinates. We provide a method which can convert screen coordinates to world coordinates, or you can use our MapClick event which is easier to get the current mouse position using event arguments. Once you get the feature you can get the corresponding layer and then change the style of it. The above way is for working with layers for styles. If you want to use ValueStyle, there is another way which is a little bit different. You will also need to get the feature, and then change the value of column value to make the style change. 



3. You can use EditTools.TranslateByOffset and pass in the offset when mouse moves. The feature id should be the same as the key when you add this feature to InternalFeatures. For example, inMemoryLayer.InternalFeatures.Add(feature.Id, feature); InternalFeatures is a GeoColletion object which contains the key and value pair that works like a Dictionary. 

Another way is adding your feature to winformsMap1.EditOverlay.EditShapesLayer, and then calling the winformsMap1.EditOverlay.CalculateAllControlPoints() method to let the feature be movable. 



Our API is designed to be easy to learn and use. For example the Layers classes. They all have the same basic APIs which inherit from the base class so if you learn how to use first layer and then you can easily use another layers. The difference of each layer is that they use different data sources. They can be different from each other but keep the same API, because they override the virtual method from the base layer to implement the polymorphism.


I am not very familiar with Google's Chrome and I think this browser is public after than we create this discussion forum, so we never test Chrome before, if this is very important issue, we will plan to fix it.


So far, I think you can use IE instead of, Sorry for convenience.




Thanks 

James