首页 > 代码库 > Openlayers 3 热力图

Openlayers 3 热力图

<body>
    <div id="map"></div>
    <script>
        var map = new ol.Map({  //初始化map
            target: ‘map‘,
            layers: [
                new ol.layer.Tile({
                    source: new ol.source.OSM()
                })
            ],
            view: new ol.View({
                center: ol.proj.transform([37.41, 8.82], ‘EPSG:4326‘, ‘EPSG:3857‘),
                zoom: 4
            })
        });
        var blur = document.getElementById(‘blur‘);
        var radius = document.getElementById(‘radius‘);
        var heatmap = new ol.layer.Heatmap({
            source: new ol.source.Vector({
                url: ‘data/kml/2012_Earthquakes_Mag5.kml‘,
                projection: ‘EPSG:3857‘,
                format: new ol.format.KML({
                    extractStyles: false
                })
            }),
            blur: 10,
            radius: 10
        });
        map.addLayer(heatmap);
     </script>
</body>

技术分享

Openlayers 3 热力图