jms143

Linking Two Map Extents

Discussion created by jms143 on Feb 13, 2014
Latest reply on Feb 14, 2014 by manish_patel
I am trying to link two map extents so that when Map1 extent changes, so does Map2... and vice-versa. I've been using the extent-change event for both Map1 and Map2, but get stuck in an cycle.

When I pan Map1, the Map1 extent-change event is fired. This changes Map2 extent, which fires extentChange2 event, which changes Map1 extent... and the cycle continues. Any ideas? Here is the code for reference:

Map1.on("extent-change", extentChange1);
Map2.on("extent-change", extentChange2);

function extentChange1(evt){
    Map2.setExtent(evt.extent);
}

function extentChange2(evt){
    Map1.setExtent(evt.extent);
}

Outcomes