首页 > 解决方案 > Openlayers 4.6.5 热图并不总是在 Mac Chrome 版本 94.0.4606.71 上呈现

问题描述

好的,所以我在下面定义了这个变量。

var heatmapLayer = new ol.layer.Heatmap({
                        source: new ol.source.Vector({
                         format: new ol.format.GeoJSON()
                           }),
                        opacity: .65
                           });

我想通过执行下面的代码在网站上绘制热图。

$.getJSON(url, con).done(function(json) {
        var max = json.reduce(function(a, b) { return com.toInt(a) > com.toInt(b.val) ? com.toInt(a) : com.toInt(b.val); },0);
        var fs = [];
        
        json.forEach(function(e) {
            var f = new ol.Feature({
                geometry: map.geoWKT.readGeometry(e.geom),
                weight: (com.toInt(e.val) / max),
                id: e.recordid,
                val: com.toInt(e.val)
            });
            fs.push(f);
        });
        
        heatmapLayer.getSource().clear();
        heatmapLayer.getSource().addFeatures(fs);
        heatmapLayer.setVisible(true);
    });

在 Windows Chrome 上,上述方法可以正常工作,但在 Mac Chrome 上,它们似乎并不总是有效。特别是当 fs 被传递给 addFeatures 方法时,在 Windows Chrome 上它一直有效,但在 Mac Chrome 上却不行。是什么导致了这个问题?Openlayers 4.6.5 Heatmap 与 Mac Chrome 不兼容吗?我必须修复我的代码以适应 Mac Chrome 吗?需要帮助

标签: openlayersheatmap

解决方案


推荐阅读