clean up variable declarations and indentation

This commit is contained in:
Hugh Rundle 2021-01-19 18:21:36 +11:00
parent 632534789d
commit f9c6b9274d

View file

@ -1,5 +1,5 @@
// add tile layer from OSM
var baseMap = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
const baseMap = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/dark-v10',
@ -8,7 +8,7 @@ var baseMap = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/
accessToken: 'pk.eyJ1IjoiaHVnaHIiLCJhIjoiY2lxenRqMGQyMDJvdWZwbWd0d2JxeGswNiJ9.vfUQRJDzbJhaG_865TSkPA'
});
var baseRules = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
const baseRules = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a><br>Incorporates Administrative Boundaries ©PSMA Australia Limited licensed by the Commonwealth of Australia under Creative Commons Attribution 4.0 International licence (CC BY 4.0).',
maxZoom: 18,
id: 'mapbox/light-v10',
@ -18,7 +18,7 @@ var baseRules = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}
});
// attach map to #mapid div above and centre
var map = L.map('mapid', {
const map = L.map('mapid', {
center: [-27.00, 133.000],
zoom: 5,
layers: [baseMap]
@ -43,7 +43,7 @@ L.TopoJSON = L.GeoJSON.extend({
// -----------------------------------------------------------------
// library services fines overlay
var fines = new L.TopoJSON(libraryServices, {
const fines = new L.TopoJSON(libraryServices, {
style: function(feature){
return {
fillColor: getFinesColor(feature.properties.fines),
@ -64,7 +64,7 @@ onEachFeature: function onEachFeature(feature, layer) {
// fill patterns for loan period overlay
var circles = new L.PatternCircle({
const circles = new L.PatternCircle({
color: '#000',
weight: 1,
radius: 2,
@ -74,7 +74,7 @@ var circles = new L.PatternCircle({
fillOpacity: 1
});
var loanTwo = new L.Pattern({
const loanTwo = new L.Pattern({
width: 8,
height: 8
})
@ -82,12 +82,12 @@ var loanTwo = new L.Pattern({
loanTwo.addShape(circles);
loanTwo.addTo(map);
var loanThree = new L.StripePattern({
const loanThree = new L.StripePattern({
color: '#000'
});
loanThree.addTo(map);
var loanFour = new L.StripePattern({
const loanFour = new L.StripePattern({
color: '#000',
weight: 6,
spaceWeight: 2,
@ -95,7 +95,7 @@ angle: 45
});
loanFour.addTo(map);
var loanSix = new L.StripePattern({
const loanSix = new L.StripePattern({
color: '#000',
weight: 2,
spaceWeight: 6,
@ -104,15 +104,15 @@ var loanSix = new L.StripePattern({
loanSix.addTo(map);
function getLoanFillPattern(w) {
return w == '2' ? loanTwo :
return w == '2' ? loanTwo :
w == '3' ? loanThree :
w == '4' ? loanFour :
w == '6' ? loanSix : null
}
// loan period overlay
var loanPeriod = new L.TopoJSON(libraryServices, {
style: function(feature){
const loanPeriod = new L.TopoJSON(libraryServices, {
style: function(feature){
return {
weight: 3,
color: "#fff",
@ -122,8 +122,7 @@ style: function(feature){
fillPattern: getLoanFillPattern(feature.properties.standard_loan_weeks)
}
},
onEachFeature: function onEachFeature(feature, layer) {
onEachFeature: function onEachFeature(feature, layer) {
layer.on({
mouseover: e => highlightFeature(e),
mouseout: e => resetHighlight(e, loanPeriod),
@ -262,16 +261,16 @@ const otherLibs = L.layerGroup([
// ++++++++++++++
// control layers
// ++++++++++++++
var baseMaps = {
const baseMaps = {
"Libraries" : baseMap,
// "Languages" : baseLang,
"Rules" : baseRules,
}
// change the overlay name depending on the mode.
var modeButton = document.getElementById('mode-button');
const modeButton = document.getElementById('mode-button');
var overlayMaps = {
const overlayMaps = {
"Settler Knowledge Centres" : branches,
"Indigenous Knowledge Centres": ikcs,
"Worker Pacification Centres" : mechsAndSoA,
@ -326,7 +325,7 @@ function switchMode() {
modeButton.addEventListener('click', switchMode, false);
// add control layers
var mapControl = L.control.layers(
const mapControl = L.control.layers(
baseMaps,
overlayMaps,
{ "collapsed" : false }
@ -336,7 +335,7 @@ var mapControl = L.control.layers(
L.control.scale().addTo(map);
// info boxes
var infoBoxes = {
const infoBoxes = {
branches: L.control(),
fines: L.control(),
loanPeriod: L.control(),
@ -344,7 +343,7 @@ var infoBoxes = {
}
function getFinesColor(f) {
return f == 'no' ? '#4dac26' :
return f == 'no' ? '#4dac26' :
f == 'yes' ? '#d01c8b' :
f == 'adults' ? '#f1b6da' :
f == 'by_lga' ? '#abd9e9' :
@ -353,7 +352,7 @@ return f == 'no' ? '#4dac26' :
// highlight feature on mouse hover
function highlightFeature(e) {
var layer = e.target;
const layer = e.target;
layer.setStyle({
weight: 6,
color: '#FF3961',
@ -383,7 +382,7 @@ function addLegend() {
this._div = L.DomUtil.create('div', 'info')
this.update();
return this._div;
}
}
// FINES LEGEND
infoBoxes.fines.onAdd = addLegend;