0

I use d3.js and dc.leaflet.js to draw cluster map and markers map. ".cluster(true)" or ".cluster(false)" can change the map style.

var MKmarker = dc_leaflet.markerChart("#map")
    function drawmap(MapTypeBoolean) {
      MKmarker
        .dimension(geoDim)
        .group(geoGroup)
        .center([23.5, 121])
        .zoom(7)
        .cluster(MapTypeBoolean)//MapTypeBoolean true = cluster map / false = marker map
        .renderPopup(false)
        .filterByArea(true);
    };
drawmap(true); // The default is cluster map

I set two buttons to switch the map by calling drawmap function again with different Boolean, but they don't work.

$('.marker').click(function() {
    $('.cluster').addClass('btn-default');
    $('.cluster').removeClass('btn-info');
    $(this).removeClass('btn-default');
    $(this).addClass('btn-info');
    drawmap(false); // When the 'marker'button is clicked, it should call drawmap function again with 'false'. ->But it doesn't work.
});

Here is my codepen. https://codepen.io/skysky888/pen/bqmpEe

Thank you~

RPichioli
  • 3,245
  • 2
  • 25
  • 29
Elsie
  • 1
  • 1

0 Answers0