I need a HTML page to compare two maps from Carto using Leaflet with same events, i.e. a Pan (or Zoom In/Out) event in Map1 aplicate the same in Map2.

I saw this example (Two cartodb visualization on the same html page) that show how can I use two maps at the same pages. But I need aplicate same events in both maps.


You can create and instantiate two maps (map1 and map2), then you can assign a custom function to both maps after a certain event:

map1.on('event', function(e) {
  customFunction(map1, map2);

map2.on('event', function(e) {
  customFunction(map2, map1);

Here you have a working example.

| improve this answer | |
  • Doesn't Carto use Leaflet? – Bill Chappell Jun 30 '17 at 19:47
  • Yes, it does. But also works with OL and GM. – ramiroaznar Jul 6 '17 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.