<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head><meta http-equiv="Content-Type" content="text/html;charset=us-ascii">
<style>BODY{font:10pt Tahoma, Verdana, sans-serif}</style></head><body>
Hi,<br><br>I suspect that when map1 moves, it updates map2, which in turn updates map1, which updates map2...etc..<br><br>Add something like this:<br>var c1, c2, z1, z2;<br>var updatingMap1 = false,updatingMap2 = false;<br>map1.events.register("moveend", map1, function() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(!updatingMap2){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c1 = this.getCenter();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; z1 = this.getZoom();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; updatingMap1 = true;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map2.panTo(c1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map2.zoomTo(z1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; updatingMap1 = false;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>});<br>map2.events.register("moveend", map2, function() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(!updatingMap2){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c2 = this.getCenter();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; z2 = this.getZoom();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; updatingMap2 = true;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map1.panTo(c2);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map1.zoomTo(z2);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; updatingMap2 = false;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>}); <br><br>What I try to do (haven't tested it) is to prevent to update map2 when moving in map2.<br><br>Good luck!<br><br>Met vriendelijke groet,<br><br>Meine Toonen<br>B3Partners BV<br>Tel: 030 214 2083<br><blockquote style="padding-left: 5px; margin-left: 5px; border-left: #0000ff 2px solid; margin-right: 0px"><hr><b>From:</b> canduc17 [mailto:candini@meeo.it]<br><b>To:</b> users@openlayers.org<br><b>Sent:</b> Tue, 20 Dec 2011 15:07:31 +0100<br><b>Subject:</b> [OpenLayers-Users] Re: Synchronize position and zoom of two maps<br><br>I have tryed with the following:<br>
<br>
var c1, c2, z1, z2;<br>
map1.events.register("moveend", map1, function() { <br>
        c1 = this.getCenter();<br>
        z1 = this.getZoom();<br>
        map2.panTo(c1);<br>
        map2.zoomTo(z1);<br>
});<br>
map2.events.register("moveend", map2, function() { <br>
        c2 = this.getCenter();<br>
        z2 = this.getZoom();<br>
        map1.panTo(c2);<br>
        map1.zoomTo(z2);<br>
});<br>
<br>
It seems to work but from time to time maps get frozen and firebug (firefox<br>
plugin) reports me the error "too much recursion".<br>
If I comment out map2 related event I have no problems, but the<br>
synchronization is only if I pan/zoom map1 and I would like to make it<br>
possible also for map2.<br>
<br>
Any ideas on how to solve this?<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/Synchronize-position-and-zoom-of-two-maps-tp7107428p7111860.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/Synchronize-position-and-zoom-of-two-maps-tp7107428p7111860.html</a><br>
Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote><style>
</style>
</body></html>