mapv
Version:
a library of geography visualization
92 lines (85 loc) • 2.19 kB
HTML
<html>
<head>
<title>ol-point-honeycomb</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/openlayers/dist/ol.css">
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://cdn.jsdelivr.net/npm/openlayers/dist/ol.js"></script>
<script src="../../build/mapv.js"></script>
<script>
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
layerName: 'baseLayer',
preload: 4,
source: new ol.source.OSM({
url: 'http://{a-e}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png'
})
})
],
loadTilesWhileAnimating: true,
pixelRatio: 1,
view: new ol.View({
projection: 'EPSG:4326',
center: [-102.17609405517578, 34.41583177128595],
zoom: 5
})
});
var randomCount = 100;
var data = [];
while (randomCount--) {
data.push({
geometry: {
type: 'Point',
coordinates: [-125.8 + Math.random() * 50, 30.3 + Math.random() * 20]
},
count: 30 * Math.random()
});
}
var dataSet = new mapv.DataSet(data);
var options = {
fillStyle: 'rgba(55, 50, 250, 0.8)',
shadowColor: 'rgba(255, 250, 50, 1)',
shadowBlur: 20,
max: 100,
size: 50,
label: {
show: true,
fillStyle: 'white',
// shadowColor: 'yellow',
// font: '20px Arial',
// shadowBlur: 10,
},
globalAlpha: 0.5,
gradient: { 0.25: "rgb(0,0,255)", 0.55: "rgb(0,255,0)", 0.85: "yellow", 1.0: "rgb(255,0,0)" },
draw: 'honeycomb',
projection: 'EPSG:4326',
methods: {
click: function (event) {
console.log(event)
},
mousemove: function (event) {
if (event) {
mapvLayer.setDefaultCursor('pointer', event)
} else {
mapvLayer.setDefaultCursor('default', event)
}
}
}
};
var mapvLayer = new mapv.OpenlayersLayer(map, dataSet, options);
</script>
</body>
</html>