ThinkGeo.com    |     Documentation    |     Premium Support

Issue with loading layers on two different map controls on form load

Please see the attached project. To sum up, I am using two map controls currently and instantiating a ShapeFileFeatureLayer for the first map control and then using .CloneDeep to create a copy of it to add to the second map control.


I would like to add a feature to the second map control that shows me the viewable extents of my first map control.


I receive a Parameter is not valid error on map2.refresh. I am trying to utilize the map1.CurrentExtentChanged to create and re-create the viewable extent feature representation.


I am using build 341



912-TestCloneDeep.zip (117 KB)

Nelson,


Thanks for your post and demo to show your problem!
 
I think the reason is you do not set the right current extent for Map2. Try the attached update sample.
 
Let me know if more questions.
 
Thanks
 
Yale

913-TestCloneDeep_Update.zip (11.9 KB)

Yale, in the updated demo, it is a nice effect you provide for the map and we may opt to use it however as it stands we want the extens of map2 to stay the same. That is, when we zoom in and out, we want the blue box of map2 to shrink and grow as necessary. I set map2.currentextent on load, why is this incorrect?

Nelson,


If you want to set a fixed extent, that is OK, just using following statement in the mapViewer_CurrentExtentChangedEvent.
 

map2.CurrentExtent = New RectangleShape(-180, 90, 180, -90)

 

The reason for its error happened you just set the extent at the Form_Load is before setting the extent( in fact, it will be called in the Me.map1.CurrentScale = 1126.46444320679 statement in its initialization), the mapViewer_CurrentExtentChangedEvent will be raised and at that time the Map2 extent was not in correct value, and this will cause the exception.
 
Of course, if you want, you can skip the first 2 times of event happened, that of course can solve this problem.
 
Let me know if you have any questions.
 
Thanks.
 
Yale