11

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.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
user1514042
  • 1,899
  • 7
  • 31
  • 57
  • Possible duplicate: http://stackoverflow.com/questions/9913035/jvectormap-zoom-in-by-code – Rubens Mariuzzo Feb 11 '13 at 14:01
  • @Rubens Mariuzzo - I don't need centering or 'bring to view' functionality, I just need to hide zoom buttons and assign zoom in/out calls to my own UI element. – user1514042 Feb 11 '13 at 14:04
  • Looking to the project at GitHub, seems like you can actually hide the zoom buttons, but I can't find it in the docs... – Rubens Mariuzzo Feb 11 '13 at 14:08

3 Answers3

32

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);
Leonid Shvechikov
  • 3,927
  • 2
  • 17
  • 14
Blas Ruiz
  • 466
  • 3
  • 5
22

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

zoomOnScroll: false
Mason
  • 243
  • 2
  • 4
5

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.

Community
  • 1
  • 1
Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
  • I wish I know how to do that... I'll try my best anyway – user1514042 Feb 11 '13 at 14:10
  • Which version are you using? This option is from the latest commits, not sure they are in the latest release yet (but better check). But, if it is urgent, you can grab the latest development commits and test... – Rubens Mariuzzo Feb 18 '13 at 02:18
  • I've taken the latest version from the website, could you try it with the version you have and see if it works? – user1514042 Feb 18 '13 at 09:48
  • It is not with the latest version, it is already [developed](https://github.com/bjornd/jvectormap/blob/develop/lib/world-map.js#L930) but not merged into master, currently in the [develop branch](https://github.com/bjornd/jvectormap/tree/develop). – Rubens Mariuzzo Mar 08 '13 at 13:10
  • Could you push it live please? – user1514042 Mar 08 '13 at 16:01