UNPKG

react-map-gl-supercluster

Version:

23 lines (22 loc) 839 B
import { dequal } from 'dequal/lite'; export function isEqual(a, b) { return dequal(a, b); } export function isClustersShallowEqual(clusters1, clusters2) { return (clusters1.length === clusters2.length && clusters1.every((feature1, index) => { const feature2 = clusters2[index]; return (feature1 === feature2 || (feature1.type === feature2.type && feature1.id === feature2.id && isPointGeometryEqual(feature1.geometry, feature2.geometry))); })); } function isPointGeometryEqual(a, b) { return a === b || (a.type === b.type && isEqual(a.coordinates, b.coordinates)); } export function getMapState(map) { const bounds = map.getBounds().toArray().flat(); const zoom = Math.round(map.getZoom()); return { bounds, zoom }; }