Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set zoom level in JVectorMap

I'm using the following code to set the initial zoom level for my jvectormap:

$('#world-map').vectorMap('get', 'mapObject').setFocus({
    scale: 3
});

After I initialise this scale property, the zoom level is set, but the zoom in/out buttons are now blocked. Also in the console I get the following error:

Unexpected value scale(2.4000000000000004) translate(undefined, undefined) parsing transform attribute.

How can I correctly set the zoom level, and leave the zoom in/out on?

like image 876
Andrei Avatar asked Nov 19 '22 15:11

Andrei


1 Answers

Just googled a bit and i found an object to be attached in the vectorMap instance:

$("#world-map").vectorMap({
  focusOn: {
    x: 2,
    y: 2,
    scale: 3
  },
  // ...
});

Here the x and y properties are needed to set the position while scale is the scale factor.. very intuitive at all

like image 166
sampixel Avatar answered Nov 22 '22 06:11

sampixel