Skip to content

Commit

Permalink
Remove use of hardcoded extents for displaying layers (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
crisner authored and jywarren committed Jan 8, 2020
1 parent 5468144 commit d2fe214
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 100 deletions.
104 changes: 8 additions & 96 deletions src/layerData.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
},
"description": "The World Air Quality Index project provides transparent and world-wide air quality information for more than 100 countries, covering more than 12,000 stations in 1000 major cities.",
"layer_desc": "World-wide air quality information",
"icon": "#096",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#096"
},
"eonetFires": {
"url": "https://eonet.sci.gsfc.nasa.gov/",
Expand All @@ -25,15 +17,7 @@
},
"description": "EONET provides a curated source of continuously updated natural event metadata. EONET Events: Wildfires: Wildfires includes all nature of fire, including forest and plains fires, as well as urban and industrial fire events. Fires may be naturally caused or manmade.",
"layer_desc": "All nature of fire events.",
"icon": "#ff421d",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#ff421d"
},
"fractracker": {
"url": "https://www.fractracker.org/",
Expand All @@ -45,10 +29,6 @@
"layer_desc": "Oil and gas development",
"icon": "#e8e800",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 5,
"maxZoom": 15
}
Expand Down Expand Up @@ -81,10 +61,6 @@
"layer_desc": "Indigenous nations - Territories, Languages, Treaties",
"icon": "#532200",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 6,
"maxZoom": 15
}
Expand Down Expand Up @@ -115,15 +91,7 @@
},
"description": "building particulate matter sensors and visualizing the data in an overall picture.",
"layer_desc": "Fine dust measurement",
"icon": "#4edd51",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#4edd51"
},
"mapknitter": {
"url": "https://mapknitter.org/",
Expand All @@ -135,10 +103,6 @@
"layer_desc": "Map data from aerial photos from balloons and kites",
"icon": "#ca283b",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 10,
"maxZoom": 15
}
Expand All @@ -154,10 +118,6 @@
"layer_desc": "Bad odor events",
"icon": "#ff00ff",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 8,
"maxZoom": 15
}
Expand All @@ -170,15 +130,7 @@
},
"description": "OpenAQ is a non-profit organization empowering communities around the globe to clean their air by harmonizing, sharing, and using open air quality data.",
"layer_desc": "Air quality data",
"icon": "#912d25",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#912d25"
},
"openInfraMap": {
"url": "https://openinframap.org/about.html",
Expand All @@ -188,15 +140,7 @@
},
"description": "Open Infrastructure Map is a view of the world's hidden infrastructure mapped in the OpenStreetMap database.",
"layer_desc": "World's hidden infrastructure",
"icon": "#b59f10",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#b59f10"
},
"opensense": {
"url": "https://opensensemap.org/",
Expand All @@ -207,15 +151,7 @@
},
"description": "openSenseMap is a platform for open sensor data at which everyone can participate in.",
"layer_desc": "Sensor data from senseboxes",
"icon": "",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": ""
},
"openWeatherMap": {
"url": "https://openweathermap.org/guide",
Expand All @@ -225,15 +161,7 @@
},
"description": "OpenWeatherMap provides many kinds of weather maps including Precipitation, Clouds, Pressure, Temperature, Wind.",
"layer_desc": "Weather information",
"icon": "#00a3fe",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#00a3fe"
},
"osmlandfills,quarries": {
"url": "https://www.openstreetmap.org/about",
Expand All @@ -245,10 +173,6 @@
"layer_desc": "Land used for landfill and mine quarry",
"icon": "#008000",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 11,
"maxZoom": 15
}
Expand Down Expand Up @@ -281,15 +205,7 @@
},
"description": "An air quality monitoring network built on a new generation of \"Internet of Things\" sensors",
"layer_desc": "Air quality data from PurpleAir sensors",
"icon": "#7c22b5",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 3,
"maxZoom": 15
}
"icon": "#7c22b5"
},
"skytruth": {
"url": "https://alerts.skytruth.org/",
Expand All @@ -301,10 +217,6 @@
"layer_desc": "Environmentally significant incidents",
"icon": "#f00",
"extents": {
"bounds": [
[-44.087585028245165, -148.88671875000003],
[76.63922560965888, 140.62500000000003]
],
"minZoom": 10,
"maxZoom": 15
}
Expand Down
10 changes: 6 additions & 4 deletions src/util/layersBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,17 @@ L.Control.LayersBrowser = L.Control.Layers.extend({
var currentBounds = map.getBounds();
var currentZoom = map.getZoom();
var bounds;
var zoom;
if(data) {
bounds = L.latLngBounds(data.extents.bounds);
bounds = data.extents && data.extents.bounds && L.latLngBounds(data.extents.bounds);
zoom = data.extents && data.extents.minZoom && data.extents.minZoom;
for(var i in elements) {
if((!bounds.intersects(currentBounds) && map.hasLayer(layerName) && removeFrmMap) ||
(currentZoom < data.extents.minZoom && map.hasLayer(layerName) && removeFrmMap)) {
if((bounds && !bounds.intersects(currentBounds) && map.hasLayer(layerName) && removeFrmMap) ||
( zoom && (currentZoom < zoom) && map.hasLayer(layerName) && removeFrmMap)) {
elements[i].style.display = 'none';
// Remove layer from map if active
map.removeLayer(layerName);
} else if(!bounds.intersects(currentBounds) || currentZoom < data.extents.minZoom) {
} else if((bounds && !bounds.intersects(currentBounds)) || (zoom && (currentZoom < zoom))) {
elements[i].style.display = 'none';
} else {
elements[i].style.display = 'block';
Expand Down

0 comments on commit d2fe214

Please sign in to comment.