Select to view content in your preferred language

Layer synchronisation after extent change

542
3
08-08-2011 03:53 AM
SarahBurgin
Emerging Contributor
I'm attempting to enhance an application that's built using ArcGIS API for Flex and has an ArcGISTiledMapServiceLayer together with a number of feature layers which are declared in MXML.

All is well when the layers are populated and map functions such as pan and zoom work just fine.

However, we needed to add a function to change the extent of the map directly using ActionScript is response to a user action. This has been achieved using map.extent.update() and then refreshing the map layer however after doing so the feature layers of our application appear to lose synchronisation with the map layer - we see symbols jump from one position to another when pan is used, zoom acts very strangely and sometimes the feature layer symbols don't appear at all.

Making the layers invisible whilst the extent changes or refreshing them afterwards doesn't seem to work around the problem. Can anyone suggest a possible solution please? TIA
Tags (2)
0 Kudos
3 Replies
SarahBurgin
Emerging Contributor
I've made some progress with this problem - think it only happens if the new extent causes the map scale to change without specifically assigning a new scale value to the map after the extent has changed.

The appropriate new value to use for scale, however, depends upon the new extent; I now need to determine this value somehow to completely solve the problem.
0 Kudos
SarahBurgin
Emerging Contributor
I found a successful workaround for the problem, which was to set the map at its fully zoomed-in scale after changing the extent based upon a focal point, then progressively zooming the map back out again and checking its resulting extent, unless an appropriate scale is found for the features that we need to be within the viewed area.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sarah,

   The easy way to do this is to check if the map.extent contains the current extent that you are setting:

                                map.extent = yourextent;
                                // make sure the whole extent is visible
                                if (!map.extent.contains(extent))
                                {
                                    map.level--;
                                }


Don't forget to click the top arrow (promote) as shown below:
0 Kudos