Interactive interface for browsing global, full-resolution satellite imagery
add clustering logic
Benjamin King3ce572b82e93
diff --git a/web/js/naturalEvents/cluster.js b/web/js/naturalEvents/cluster.jsindex 560fc4fc0..58bb01f62 100644--- a/web/js/naturalEvents/cluster.js+++ b/web/js/naturalEvents/cluster.js@@ -1,5 +1,11 @@import superCluster from 'supercluster';import lodashRound from 'lodash/round';+import lodashEach from 'lodash/each';++const superClusterObj = superCluster({+ radius: 60,+ maxZoom: 16+});export function naturalEventsPointToGeoJSON(id, coordinates, date) {return {@@ -13,13 +19,18 @@ export function naturalEventsPointToGeoJSON(id, coordinates, date) {coordinates: coordinates}};-}+};+export function naturalEventsGetClusterPoints(pointArray, zoomLevel) {- var index = superCluster({- radius: 80,- maxZoom: 16- });- index.load(pointArray);- console.log(zoomLevel);- return index.getClusters([-180, -85, 180, 85], lodashRound(zoomLevel));-};\ No newline at end of file+ superClusterObj.load(pointArray);+ return superClusterObj.getClusters([-180, -85, 180, 85], lodashRound(zoomLevel));+};++export function naturalEventsCalculateRange(clusterId) {+ var clusterPointArray = superClusterObj.getLeaves(clusterId, Infinity);+ console.log(clusterPointArray);+ // clusterPointArray+ // lodashEach(clusterPointArray, (point) => {++ // });+};diff --git a/web/js/naturalEvents/track.js b/web/js/naturalEvents/track.jsindex 5bbccda3e..92ec7f323 100644--- a/web/js/naturalEvents/track.js+++ b/web/js/naturalEvents/track.js@@ -8,7 +8,10 @@ import OlStyleCircle from 'ol/style/circle';import OlStyleStyle from 'ol/style/style';import OlGeomMultiLineString from 'ol/geom/multilinestring';import lodashEach from 'lodash/each';-import { naturalEventsPointToGeoJSON, naturalEventsGetClusterPoints } from './cluster';+import {+ naturalEventsPointToGeoJSON,+ naturalEventsGetClusterPoints,+ naturalEventsCalculateRange} from './cluster';var naturalEventsTrackLayer = function(featuresArray, styles) {return new OlLayerVector({@@ -138,6 +141,10 @@ function getClusterPointEl(cluster, date, callback) {textEl.className = 'cluster-track-marker-date track-marker-date';circleEl.className = 'track-marker track-marker';circleEl.appendChild(numberEl);+ circleEl.onmouseover = () => {+ naturalEventsCalculateRange(eventID);+ console.log('yolo')+ };overlayEl.appendChild(circleEl);overlayEl.appendChild(textEl);