jVectorMap custom zoom buttons
Asked Answered
P

3

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.

Pseudoscope answered 11/2, 2013 at 13:57 Comment(3)
Possible duplicate: https://mcmap.net/q/1013046/-jvectormap-zoom-in-by-codeStability
@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.Pseudoscope
Looking to the project at GitHub, seems like you can actually hide the zoom buttons, but I can't find it in the docs...Stability
B
33

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);
Balsaminaceous answered 12/3, 2013 at 12:49 Comment(1)
not working ....Twelvetone
V
23

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

zoomOnScroll: false
Vazquez answered 14/10, 2013 at 9:50 Comment(1)
I don't see this in the API but it works, where is this from?Sirmons
S
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.

Stability answered 11/2, 2013 at 14:5 Comment(5)
I wish I know how to do that... I'll try my best anywayPseudoscope
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...Stability
I've taken the latest version from the website, could you try it with the version you have and see if it works?Pseudoscope
It is not with the latest version, it is already developed but not merged into master, currently in the develop branch.Stability
Could you push it live please?Pseudoscope

© 2022 - 2024 — McMap. All rights reserved.