Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jVectorMap custom zoom buttons

With jVectorMap is it possible to hide zoom buttons and call Zoom In/Out using their API? I've checked the API documentation and couldn't find any methods, causing the map re-zoom.

like image 294
user1514042 Avatar asked Feb 11 '13 13:02

user1514042


3 Answers

On a side note, you can also disable/enable zooming on scroll using

zoomOnScroll: false
like image 138
Mason Avatar answered Oct 20 '22 22:10

Mason


Sure.

Hide the buttons:

$('#map').vectorMap({
    map: 'world_mill_en',
    zoomButtons : false
});

Get reference to the map:

map = $("#world-map-gdp").vectorMap('get', 'mapObject');

Set the zoom level:

map.setScale(4);
like image 39
Blas Ruiz Avatar answered Oct 21 '22 00:10

Blas Ruiz


There's no such feature a this moment. But...

  1. It seems like someone else asked for an option to hide the zoom buttons, and it is already done but seems not documented, see feature request status: https://github.com/bjornd/jvectormap/pull/136.
  2. To allow zoom in/out by code you could and should create a feature request via GitHub: https://github.com/bjornd/jvectormap/issues/new

I strongly encourage you to create the feature request so the devs behind the project can actually know what are the real needs.

Edit

Looking trough the mentioned feature request, I can see there is a parameter to hide zoom buttons. So you will need to build your maps passing a zoomButtons attribute to false:

$('#map').vectorMap({
  map: 'world_mill_en',
  zoomButtons : false
});

The other thing you are looking for (zoom in/out via API), I think if you are really sure there's no way to do it, you should create an issue masked as a feature request.

Edit 2

Months after my answer was posted, the feature got released see that answer.

like image 5
Rubens Mariuzzo Avatar answered Oct 21 '22 00:10

Rubens Mariuzzo