bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.39k stars 431 forks source link

Configuration for MultiMap submaps #311

Open cmriddell opened 9 years ago

cmriddell commented 9 years ago

Is it possible to configure the submaps that are loaded using the MultiMap map object? It looks like the maps are added as regular map objects, but it's not clear to me how to pass configuration to those maps. Ideally, I'd like to be able to add markers, legend, etc. to the submaps, same as the main map.

Nilson89 commented 9 years ago

Same here, could not find a way. Would be nice if submaps would a) get configuration of main map or b) have a param that can be set while initiating multiMap which gets passed through to the submaps.

cellulosa commented 9 years ago

For the time being I've created a quick hack by editing multimap.jswhich you can find here that allows parameters to be passed to sub-maps via subMapsOptions:

<script>
    $(function(){
        var map1,
            map2;

        new jvm.MultiMap({
            ...
            subMapsOptions: {
                regionsSelectable: true,
                onRegionClick: function (event, code) {
                    console.log(code);
                },
            },
            main: {
                ...
                regionsSelectable: true,
            }
        });
    });
</script>
Scuzzlebut commented 9 years ago

Hello, thanks for your "hack" it's been very handy! I got one issue with this: after i load a submap i need to zoom to a point right away so this is my code: subMapsOptions: { onRegionClick: function (event, code) { console.log(code); }, zoomOnScroll: false, panOnDrag : false, focusOn: {scale: 4, x: 0.5, y:0.5}, }, It works fine, but when i go back to main map and then again to the same submap he just ignores the focusOn parameter (the others work fine). Is there some bug in the code which prevents me calling this method a second time? Can't figure out the bug. Thanks for the help

vistree commented 7 years ago

Hi @cellulosa , where can we find your hack? The github link you provide does not work any more ... Thanx!!!

cellulosa commented 7 years ago

Hi @vistree,

I removed my repository because I though nobody needed it and it's a long time since I last used jvectormap. Anyway, I found my old edited file, there it is: https://github.com/bjornd/jvectormap/blob/3a3b9506f4c34aa62347e97369b83d6318df40ee/src/multimap.js

vistree commented 7 years ago

@cellulosa : thanx!!!

sipujena commented 6 years ago

Great job.. :+1: