ThinkGeo.com    |     Documentation    |     Premium Support

Zooming to Selected Features

I have a question. I have a map where the user can select zip codes and they are hilighted. This data is pulled from an internal database. What I would like to do is zoom into the area where the zip codes have been selected. They are generally in adjacent zip codes.


Does anyone know how to do this?


Thanks.



Jeff,


Here is a sample for you, please have a look.


Ben



261-Post5050.zip (4.81 KB)

Hello again Ben. I hope you had a good holiday. 
  
 Let me start by thanking you for the sample. This looks like it is exactly what I want to do. The only problem I am having is that the example you sent me uses an InMemoryFeatureLayer and the code I am using is using a ShapeFileFeatureLayer. When I try to cast between this type and the InMemoryFeatureLayer I get an invalid cast exception. Does the InternalFeatures collection reside in any other objects? Can I modify my ShapeFileFeatureLayer to be an InMemoryFeatureLayer? 
  
 Thanks again for your help. You have been very helpful with every question I have had.

Jeff, 
  
 ShapeFileFeatureLayer cannot be cast to InMemoryFeatureLayer, as you thought, InternalFeatures property only exists within the InMemoryFeatureLayer. You can call the methods within FeatureLayer.FeatureSource to get all the features, and add them one by one to an InMemoryFeatureLayer, "cast" by yourself :)  I think it is a very good suggestion to make it convertible from a FeatureLayer to an InMemoryFeatureLayer, I will write it down and maybe we will add this feature in the future.  
  
 I’m very glad my work helps. Thank you and hope you had a good holiday too. 
  
 Ben.