neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

Zooming trigger issue on 2.0 #249

Closed dnsBlah closed 7 years ago

dnsBlah commented 8 years ago

Hi all,

I used to use this function to scale my plots on the map.


$(".maparea").on("zoom", function() {
    var zoomLevel = $(".maparea").data("zoomLevel");
    $(".maparea").trigger("update", [{
        map: {
            defaultPlot: {
                size: 10 / (1 + 0.25 * zoomLevel)
            },
            defaultLink: {
                attrs: {
                    "stroke-width": 1 / (1 + 0.25 * zoomLevel)
                }
            }
        }
    }]);
});

But nowdays with 2.0 the zoomLevel is not being picked up anymore, and the trigger is not being called always ...

Is there a new solution for this, maybe someone also have a better idea for the scaling, because on an iPhone for example, it's too big.

The size has something to do in relation with the width of the screen.

neveldo commented 8 years ago

Hi @dnsBlah ,

The zoom event haven't been updated between 1.1.0 and 2.0.0 versions, it should still be triggered when a user zoom the map. Could you provide a JSFiddle example that highlight the issue ?

All the data of a map are now (from mapael 2.0.0) stored within a mapael instance that can be accessed from here : $(".mapcontainer").data('mapael'). To get the zoomLevel : $(".mapcontainer").data('mapael').zoomData.zoomLevel. I will improve the documentation on that point.