2

So I have a simple map divided into different states and everytime I click one state I want it to zoom in into that region, so it fills the screen.

I'm using Mapael with the zoom enabled, but when I specify a region, see the code below, it does zoom in but then it zooms back when i try to pan around or zoom closer. What can I do to make it smoother? Like if it was a "natural" zoom in? Thank you!

$(document).ready(function() {
    $('path').click(function() {
        $('svg').each(function() {
            $(this)[0].setAttribute('viewBox', '256 68 600 300');
        });
    });
});
John Slegers
  • 45,213
  • 22
  • 199
  • 169
user1765661
  • 585
  • 1
  • 7
  • 21

2 Answers2

2

May I suggest you take a look at jquery Transit, a library built for smooth animations by targeting DOM elements in the standard jquery method? I am currently using it an am very satisfied with the results.

You can find it at http://ricostacruz.com/jquery.transit/

tllewellyn
  • 903
  • 2
  • 7
  • 28
0

There is a trigger function for the zoom:

$(".mapcontainer").trigger('zoom', {level : 10, x : 100, y : 200});
user1765661
  • 585
  • 1
  • 7
  • 21