Linting fixes

This commit is contained in:
efarooqui
2020-10-06 10:31:17 -07:00
parent 233ddbfc99
commit 9dd5eabd3a
6 changed files with 13 additions and 84 deletions

View File

@@ -172,16 +172,16 @@ export function calcClusterSize (pointCount, numClusters) {
return Math.min(50, 10 + (pointCount / numClusters) * 10)
}
export function isLatitude(lat) {
return !!lat && isFinite(lat) && Math.abs(lat) <= 90;
export function isLatitude (lat) {
return !!lat && isFinite(lat) && Math.abs(lat) <= 90
}
export function isLongitude(lng) {
return !!lng && isFinite(lng) && Math.abs(lng) <= 180;
export function isLongitude (lng) {
return !!lng && isFinite(lng) && Math.abs(lng) <= 180
}
export function mapClustersToLocations(clusters, locations) {
return clusters.map(cl => locations.find(location => location.label === cl.properties.id))
export function mapClustersToLocations (clusters, locations) {
return clusters.map(cl => locations.find(location => location.label === cl.properties.id))
}
export const dateMin = function () {

View File

@@ -259,7 +259,7 @@ class Dashboard extends React.Component {
}
return (
<div>
<div>
<Toolbar
isNarrative={!!app.associations.narrative}
methods={{
@@ -364,7 +364,7 @@ export default connect(
...state,
narrativeIdx: selectors.selectNarrativeIdx(state),
narratives: selectors.selectNarratives(state),
selected: selectors.selectSelected(state),
selected: selectors.selectSelected(state)
}),
mapDispatchToProps
)(Dashboard)

View File

@@ -17,12 +17,11 @@ import SelectedEvents from './presentational/Map/SelectedEvents.jsx'
import Narratives from './presentational/Map/Narratives'
import DefsMarkers from './presentational/Map/DefsMarkers.jsx'
import { mapClustersToLocations } from '../common/utilities'
import { mapClustersToLocations } from '../common/utilities'
// NB: important constants for map, TODO: make statics
const supportedMapboxMap = ['streets', 'satellite']
const defaultToken = 'your_token'
const clusterId = 'clusters'
class Map extends React.Component {
constructor () {
@@ -166,7 +165,7 @@ class Map extends React.Component {
return acc
}, [])
this.index.load(convertedLocations)
this.setState({indexLoaded: true})
this.setState({ indexLoaded: true })
this.update()
}
}

View File

@@ -1,69 +0,0 @@
var map = L.map('map').setView([0, 0], 0);
// Empty Layer Group that will receive the clusters data on the fly.
var markers = L.geoJSON(null, {
pointToLayer: createClusterIcon
}).addTo(map);
// Update the displayed clusters after user pan / zoom.
map.on('moveend', update);
function update() {
// if (!ready) return;
var bounds = map.getBounds();
var bbox = [bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()];
var zoom = map.getZoom();
var clusters = index.getClusters(bbox, zoom);
markers.clearLayers();
markers.addData(clusters);
}
// Zoom to expand the cluster clicked by user.
markers.on('click', function(e) {
var clusterId = e.layer.feature.properties.cluster_id;
var center = e.latlng;
var expansionZoom;
if (clusterId) {
expansionZoom = index.getClusterExpansionZoom(clusterId);
map.flyTo(center, expansionZoom);
}
});
// Retrieve Points data.
var placesUrl = 'https://cdn.rawgit.com/mapbox/supercluster/v4.0.1/test/fixtures/places.json';
var index;
var ready = false;
jQuery.getJSON(placesUrl, function(geojson) {
// Initialize the supercluster index.
index = supercluster({
radius: 60,
extent: 256,
maxZoom: 18
}).load(geojson.features); // Expects an array of Features.
ready = true;
update();
});
function createClusterIcon(feature, latlng) {
if (!feature.properties.cluster) return L.marker(latlng);
var count = feature.properties.point_count;
var size =
count < 100 ? 'small' :
count < 1000 ? 'medium' : 'large';
var icon = L.divIcon({
html: '<div><span>' + feature.properties.point_count_abbreviated + '</span></div>',
className: 'marker-cluster marker-cluster-' + size,
iconSize: L.point(40, 40)
});
return L.marker(latlng, {
icon: icon
});
}
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

View File

@@ -9,7 +9,7 @@ function ClusterEvents ({
onSelect,
svg,
clusters,
numClusters,
numClusters
}) {
function renderClusterBySize (cluster) {
const { point_count: pointCount, cluster_id: clusterId } = cluster.properties
@@ -20,7 +20,7 @@ function ClusterEvents ({
fill: colors.fallbackEventColor,
stroke: colors.darkBackground,
strokeWidth: 0,
fillOpacity: calcOpacity(pointCount),
fillOpacity: calcOpacity(pointCount)
})
return (
@@ -39,7 +39,6 @@ function ClusterEvents ({
)
}
function renderCluster (cluster) {
/**
{

View File

@@ -53,7 +53,7 @@ const initial = {
maxZoom: 20,
bounds: null,
maxBounds: [[180, -180], [-180, 180]],
clusterRadius: 30,
clusterRadius: 30
},
timeline: {
dimensions: {