【问题标题】:Fusion table map layer heat map融合表地图图层热图
【发布时间】:2013-04-17 15:25:50
【问题描述】:

我有一个融合表层,并按如下方式启用了热图,它在我的地图层中运行良好。

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

是否可以在特定缩放级别(例如 13 级)之后禁用热图,以便在缩放级别 = 13 之后我可以查看融合表中的实际标记。

【问题讨论】:

    标签: google-maps google-maps-api-3 google-fusion-tables zooming heatmap


    【解决方案1】:

    是的,确实如此!您只需为地图对象 zoom_changed 事件设置一个事件侦听器并检查地图缩放级别。然后使用图层的 setOptions() 方法重新设置图层的热图启用属性。因此,将您的代码更改为以下内容:

    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;
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多