0
votes

I've a fusion table layer and I enabled heat map as follows and it is working fine in my map layer.

 layer = new google.maps.FusionTablesLayer({
      query: {
        select: 'Lat', 
        from: FT_TableID
      },
       map: map,
    //  suppressInfoWindows: true
    heatmap: { enabled: true },
      options: {
        styleId: 2,
        templateId: 2
      }
    });

Is it possible to disable the heat map after a particular zoom level, say 13 so that after the zoom level = 13 I can view the actual markers from the fusion table.

1

1 Answers

0
votes

Yes, it is indeed! All you need is to set an event listener to the map objects zoom_changed event and check the maps zoom level. Then use the layers setOptions() method to re-set the layer's heatmap enabled property. So, change your code to the following:

layer = new google.maps.FusionTablesLayer({
    query: {
        select: 'Lat',
        from: FT_TableID
    },
    map: map,
    //  suppressInfoWindows: true
    heatmap: {
        enabled: true
    },
    options: {
        styleId: 2,
        templateId: 2
    }
});
var heatMapIsOn = true;
google.maps.event.addListener(map, 'zoom_changed', function () {
    var zoom = map.getZoom();
    //we could just reset the layers options at every zoom change, but that would be
    //a bit redundant, so we will only reset layers options at zoom level 13
    if (heatMapIsOn && zoom >= 13) {
        layer.setOptions({heatmap: {enabled:false}});
        heatMapIsOn = false;
    } else if (!heatMapIsOn && zoom < 13) {
        layer.setOptions({heatmap: {enabled:true}});
        heatMapIsOn = true;
    }
});