add nsla overlay for ILS layer

Changed the "library management software" layer so that there are 2 overlays: Local libraries, and NSLA libraries.
Resolves #119
This commit is contained in:
Hugh Rundle 2021-09-06 19:12:40 +10:00
parent ac608bcc2d
commit 8569270115
2 changed files with 109 additions and 75 deletions

View file

@ -1,10 +1,10 @@
lat,lng,town,address,phone lat,lng,town,address,phone,ils
-37.809815,144.96513,State Library of Victoria,"328 Swanston Street, Melbourne",03 8664 7000 -37.809815,144.96513,State Library of Victoria,"328 Swanston Street, Melbourne",03 8664 7000,Ex Libris Voyager
-35.2964664654173,149.129530279015,National Library of Australia,"Parkes Place, Canberra",02 6262 1111 -35.2964664654173,149.129530279015,National Library of Australia,"Parkes Place, Canberra",02 6262 1111,Ex Libris Voyager
-33.8658844393665,151.213300984753,State Library of New South Wales,"Macquarie Street, Sydney",02 9273 1414 -33.8658844393665,151.213300984753,State Library of New South Wales,"Macquarie Street, Sydney",02 9273 1414,Ex Libris Alma
-27.4709532627151,153.018134355766,State Library of Queensland,"Stanley Place, South Brisbane",07 3840 7666 -27.4709532627151,153.018134355766,State Library of Queensland,"Stanley Place, South Brisbane",07 3840 7666,Ex Libris Alma
-34.9203274502345,138.602616669435,State Library of South Australia,"North Terrace & Kintore Ave, Adelaide",08 8207 7250 -34.9203274502345,138.602616669435,State Library of South Australia,"North Terrace & Kintore Ave, Adelaide",08 8207 7250,Innovative Sierra
-31.9490538016994,115.860634584705,State Library of Western Australia,"25 Francis St, Perth",08 9427 3111 -31.9490538016994,115.860634584705,State Library of Western Australia,"25 Francis St, Perth",08 9427 3111,Innovative Sierra
-42.8815965006531,147.325005456166,Hobart Reading Room (State Reference Library),"91 Murray Street, Hobart",03 6165 5597 -42.8815965006531,147.325005456166,Hobart Reading Room (State Reference Library),"91 Murray Street, Hobart",03 6165 5597,SirsiDynix Symphony
-12.4666020117882,130.842962053658,Northern Territory Library,"4 Bennett St, Parliament House, Darwin",08 8999 7177 -12.4666020117882,130.842962053658,Northern Territory Library,"4 Bennett St, Parliament House, Darwin",08 8999 7177,OCLC WorldShare
-35.3241714564223,149.164639259617,ACT Heritage Library,"255 Canberra Ave, Fyshwick",02 6207 5163 -35.3241714564223,149.164639259617,ACT Heritage Library,"255 Canberra Ave, Fyshwick",02 6207 5163,Civica Spydus

1 lat lng town address phone ils
2 -37.809815 144.96513 State Library of Victoria 328 Swanston Street, Melbourne 03 8664 7000 Ex Libris Voyager
3 -35.2964664654173 149.129530279015 National Library of Australia Parkes Place, Canberra 02 6262 1111 Ex Libris Voyager
4 -33.8658844393665 151.213300984753 State Library of New South Wales Macquarie Street, Sydney 02 9273 1414 Ex Libris Alma
5 -27.4709532627151 153.018134355766 State Library of Queensland Stanley Place, South Brisbane 07 3840 7666 Ex Libris Alma
6 -34.9203274502345 138.602616669435 State Library of South Australia North Terrace & Kintore Ave, Adelaide 08 8207 7250 Innovative Sierra
7 -31.9490538016994 115.860634584705 State Library of Western Australia 25 Francis St, Perth 08 9427 3111 Innovative Sierra
8 -42.8815965006531 147.325005456166 Hobart Reading Room (State Reference Library) 91 Murray Street, Hobart 03 6165 5597 SirsiDynix Symphony
9 -12.4666020117882 130.842962053658 Northern Territory Library 4 Bennett St, Parliament House, Darwin 08 8999 7177 OCLC WorldShare
10 -35.3241714564223 149.164639259617 ACT Heritage Library 255 Canberra Ave, Fyshwick 02 6207 5163 Civica Spydus

View file

@ -27,22 +27,53 @@ function BaseMap(id) {
}) })
} }
function LocationsLayer(data, color) { function getIlsColor(f) {
return f == 'AIT Aurora' ? '#d16a6e' :
f == 'Champ LMSi' ? '#ff00db' :
f == 'Civica Spydus' ? '#800080' :
f == 'DECD Bookmark' ? '#e1153e' :
f == 'Ex Libris Alma' ? '#ff6500' :
f == 'Ex Libris Voyager' ? 'yellow' :
f == 'Follett Destiny' ? '#df4917' :
f == 'Infor V-smart' ? '#e174c1' :
f == 'Innovative Sierra' ? '#ff0000' :
f == 'Koha ILS' ? '#2fbf2f' :
f == 'Libero' ? '#ffa500' :
f == 'Locally developed' ? '#bfdf17' :
f == 'OCLC Amlib' ? '#ddb372' :
f == 'OCLC WorldShare' ? '#2fbf97' :
f == 'SirsiDynix Horizon' ? '#ffff00' :
f == 'SirsiDynix Symphony' ? '#115583' :
f == 'Softlink Liberty' ? '#00f9ff' :
f == 'SumWare Athenaeum' ? '#ff3232' : '#bbb';
}
function LocationsLayer(data, color, outline, type) {
this.data = data; this.data = data;
this.color = color; this.color = color;
this.outline = outline;
this.type = type;
return L.layerGroup([ return L.layerGroup([
L.geoCsv(data, { L.geoCsv(data, {
firstLineTitles: true, firstLineTitles: true,
fieldSeparator: ',', fieldSeparator: ',',
onEachFeature: function (feature, layer) { onEachFeature: function (feature, layer) {
layer.bindPopup( if (type === 'ils') {
`<strong>${feature.properties.town}</strong>` + layer.bindPopup(
`<p>${feature.properties.address}<br/>` + `<strong>${feature.properties.town}</strong>` +
`phone: ${feature.properties.phone}</p>` `<p>${feature.properties.ils}</p>`
) )
} else {
layer.bindPopup(
`<strong>${feature.properties.town}</strong>` +
`<p>${feature.properties.address}<br/>` +
`phone: ${feature.properties.phone}</p>`
)
}
}, },
pointToLayer: function (f, latlng) { pointToLayer: function (f, latlng) {
return L.circle(latlng, {color: color, radius: 800}) // this is an 800m radius around the library let col = type === 'ils' ? getIlsColor(f.properties.ils) : color;
return L.circle(latlng, {color: col, radius: outline}) // this is an 800m radius around the library
} }
}), }),
L.geoCsv(data, { L.geoCsv(data, {
@ -56,7 +87,8 @@ function LocationsLayer(data, color) {
) )
}, },
pointToLayer: function (f, latlng) { pointToLayer: function (f, latlng) {
return L.circleMarker(latlng, {color: color, radius: 2, fill: true}) let col = type === 'ils' ? getIlsColor(f.properties.ils) : color;
return L.circleMarker(latlng, {color: col, radius: 2, fill: true})
} }
}) })
]) ])
@ -78,10 +110,11 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
}); });
// LOCATION LAYERS // LOCATION LAYERS
const branches = new LocationsLayer(data[1], "#FF3961") const branches = new LocationsLayer(data[1], '#FF3961', 800)
const ikcs = new LocationsLayer(data[2], "#76DBA7") const ikcs = new LocationsLayer(data[2], '#76DBA7', 800)
const mechsAndSoA = new LocationsLayer(data[3], "rgb(255,165,0)") const mechsAndSoA = new LocationsLayer(data[3], 'rgb(255,165,0)', 800)
const otherLibs = new LocationsLayer(data[4], "#75f857") const otherLibs = new LocationsLayer(data[4], '#75f857', 800)
const nslaLibs = new LocationsLayer(data[4], '#FF3961', 20000, 'ils')
// add to the initial map on load // add to the initial map on load
branches.addTo(map) branches.addTo(map)
ikcs.addTo(map) ikcs.addTo(map)
@ -111,8 +144,8 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
return { return {
fillColor: getFinesColor(feature.properties.fines), fillColor: getFinesColor(feature.properties.fines),
weight: 3, weight: 3,
color: "white", color: 'white',
dashArray: "4", dashArray: '4',
fillOpacity: 0.2 fillOpacity: 0.2
} }
}, },
@ -177,10 +210,10 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
style: function(feature){ style: function(feature){
return { return {
weight: 3, weight: 3,
color: "#fff", color: '#fff',
dashArray: "4", dashArray: '4',
fillOpacity: 0.2, fillOpacity: 0.2,
fillColor: "#bbb", fillColor: '#bbb',
fillPattern: getLoanFillPattern(feature.properties.standard_loan_weeks) fillPattern: getLoanFillPattern(feature.properties.standard_loan_weeks)
} }
}, },
@ -199,8 +232,8 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
return { return {
fillColor: getIlsColor(feature.properties.ILS), fillColor: getIlsColor(feature.properties.ILS),
weight: 3, weight: 3,
color: "white", color: 'white',
dashArray: "4", dashArray: '4',
fillOpacity: 0.2 fillOpacity: 0.2
} }
}, },
@ -218,9 +251,9 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
// control layers // control layers
// ++++++++++++++ // ++++++++++++++
const baseMaps = { const baseMaps = {
"Libraries" : baseMap, 'Libraries' : baseMap,
"Rules" : baseRules, 'Rules' : baseRules,
"Library Management Software" : baseIls 'Library Management Software' : baseIls
} }
// change the branches overlay names depending on the mode. // change the branches overlay names depending on the mode.
@ -230,24 +263,24 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
function setGeneral() { function setGeneral() {
overlayMaps = { overlayMaps = {
"Settler Knowledge Centres" : branches, 'Settler Knowledge Centres' : branches,
"Indigenous Knowledge Centres" : ikcs, 'Indigenous Knowledge Centres' : ikcs,
"Mechanics Institutes" : mechsAndSoA, 'Mechanics Institutes' : mechsAndSoA,
"Colonial Knowledge Centres" : otherLibs 'Colonial Knowledge Centres' : otherLibs
} }
modeButton.setAttribute('class', 'visible'); modeButton.setAttribute('class', 'visible');
modeButton.innerText = "View in Colonial Mode"; modeButton.innerText = 'View in Colonial Mode';
} }
function setColonial() { function setColonial() {
overlayMaps = { overlayMaps = {
"Public Libraries" : branches, 'Public Libraries' : branches,
"Indigenous Knowledge Centres" : ikcs, 'Indigenous Knowledge Centres' : ikcs,
"Mechanics Institutes" : mechsAndSoA, 'Mechanics Institutes' : mechsAndSoA,
"National & State Libraries" : otherLibs 'National & State Libraries' : otherLibs
}; };
modeButton.setAttribute('class', 'visible'); modeButton.setAttribute('class', 'visible');
modeButton.innerText = "View in Standard Mode"; modeButton.innerText = 'View in Standard Mode';
} }
if (sessionStorage.getItem('mapMode') === 'colonial') { if (sessionStorage.getItem('mapMode') === 'colonial') {
@ -260,7 +293,7 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
var mapControl = L.control.layers( var mapControl = L.control.layers(
baseMaps, baseMaps,
overlayMaps, overlayMaps,
{ "collapsed" : isSmallScreen } { 'collapsed' : isSmallScreen }
).addTo(map); ).addTo(map);
// scale // scale
@ -281,7 +314,7 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
setGeneral() setGeneral()
mapControl.remove(); mapControl.remove();
infoBoxes.branches.remove() infoBoxes.branches.remove()
mapControl = L.control.layers(baseMaps, overlayMaps, {"collapsed": isSmallScreen}).addTo(map); mapControl = L.control.layers(baseMaps, overlayMaps, {'collapsed': isSmallScreen}).addTo(map);
if (!isSmallScreen) { if (!isSmallScreen) {
infoBoxes.branches.addTo(map) infoBoxes.branches.addTo(map)
} }
@ -290,7 +323,7 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
setColonial() setColonial()
mapControl.remove(); mapControl.remove();
infoBoxes.branches.remove() infoBoxes.branches.remove()
mapControl = L.control.layers(baseMaps, overlayMaps, {"collapsed": isSmallScreen}).addTo(map); mapControl = L.control.layers(baseMaps, overlayMaps, {'collapsed': isSmallScreen}).addTo(map);
if (!isSmallScreen) { if (!isSmallScreen) {
infoBoxes.branches.addTo(map) infoBoxes.branches.addTo(map)
} }
@ -307,32 +340,13 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
f == 'no_unconfirmed' ? '#b8e186' : '#bbb'; f == 'no_unconfirmed' ? '#b8e186' : '#bbb';
} }
function getIlsColor(f) {
return f == 'AIT Aurora' ? '#d16a6e' :
f == 'Champ LMSi' ? '#ff00db' :
f == 'Civica Spydus' ? '#800080' :
f == 'DECD Bookmark' ? '#e1153e' :
f == 'Follett Destiny' ? '#df4917' :
f == 'Infor V-smart' ? '#e174c1' :
f == 'Innovative Sierra' ? '#ff0000' :
f == 'Koha ILS' ? '#2fbf2f' :
f == 'Libero' ? '#ffa500' :
f == 'Locally developed' ? '#bfdf17' :
f == 'OCLC Amlib' ? '#ddb372' :
f == 'OCLC WorldShare' ? '#2fbf97' :
f == 'SirsiDynix Horizon' ? '#ffff00' :
f == 'SirsiDynix Symphony' ? '#115583' :
f == 'Softlink Liberty' ? '#00f9ff' :
f == 'SumWare Athenaeum' ? '#ff3232' : '#bbb';
}
// highlight feature on mouse hover // highlight feature on mouse hover
function highlightFeature(e) { function highlightFeature(e) {
const layer = e.target; const layer = e.target;
layer.setStyle({ layer.setStyle({
weight: 6, weight: 6,
color: '#FF3961', color: '#FF3961',
dashArray: "0", dashArray: '0',
fillOpacity: 0 fillOpacity: 0
}); });
@ -351,18 +365,18 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
<strong>${props.name}</strong>` + <strong>${props.name}</strong>` +
`<p>Fines: ` + `<p>Fines: ` +
( (
props.fines === "no" ? "No" : props.fines === 'no' ? 'No' :
props.fines == "no_unconfirmed" ? "Probably no" : props.fines == 'no_unconfirmed' ? 'Probably no' :
props.fines === "yes" ? "Yes" : props.fines === 'yes' ? 'Yes' :
props.fines == "adults" ? "No for children" : props.fines == 'adults' ? 'No for children' :
props.fines == "by_lga" ? "Varies by LGA" : "Unknown" props.fines == 'by_lga' ? 'Varies by LGA' : 'Unknown'
) + ) +
`<br/>Loans : ` + `<br/>Loans : ` +
(!props.standard_loan_weeks || props.standard_loan_weeks == "?" ? `Unknown` : `${props.standard_loan_weeks} weeks`) + (!props.standard_loan_weeks || props.standard_loan_weeks == '?' ? `Unknown` : `${props.standard_loan_weeks} weeks`) +
`<br/>Software : ` + `<br/>Software : ` +
(!props.ILS || props.ILS == "?" ? `Unknown` : `${props.ILS}`) + (!props.ILS || props.ILS == '?' ? `Unknown` : `${props.ILS}`) +
`<br/>Website: ` + `<br/>Website: ` +
(!props.website || props.website == "?" ? `Unknown` : `<a target="_blank" href="`+ `${props.website}` + `" >` + `${props.website}` + `</a>`) + (!props.website || props.website == '?' ? `Unknown` : `<a target="_blank" href="`+ `${props.website}` + `" >` + `${props.website}` + `</a>`) +
`</p>` `</p>`
).openPopup() ).openPopup()
} }
@ -479,6 +493,12 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
// we remove info boxes before adding them again where relevant // we remove info boxes before adding them again where relevant
// this is so we don't accidentally stack up multiple copies dependng on user // this is so we don't accidentally stack up multiple copies dependng on user
// navigation journey // navigation journey
var ilsMaps = {
"NSLA Libraries" : nslaLibs,
"Local Libraries" : ils
}
map.on('baselayerchange', l => { map.on('baselayerchange', l => {
for (let k in infoBoxes) { for (let k in infoBoxes) {
infoBoxes[k].remove() infoBoxes[k].remove()
@ -493,7 +513,11 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
mapControl.removeLayer(overlayMaps[i]) mapControl.removeLayer(overlayMaps[i])
overlayMaps[i].remove() overlayMaps[i].remove()
} }
ils.remove() for (let i in ilsMaps ) {
mapControl.removeLayer(ilsMaps[i])
ilsMaps[i].remove()
}
// ils.remove()
if (!isSmallScreen) { // only add infoboxes to larger screens if (!isSmallScreen) { // only add infoboxes to larger screens
infoBoxes.loanPeriod.addTo(map) infoBoxes.loanPeriod.addTo(map)
infoBoxes.fines.addTo(map) infoBoxes.fines.addTo(map)
@ -510,14 +534,24 @@ Promise.all([boundaries, branchesCsv, ikcCsv, mechanics, nslaBranches])
fines.remove() fines.remove()
loanPeriod.remove() loanPeriod.remove()
// add ILS layer // add ILS layer
// TODO: here we add NSLA libraries
// mapControl.addOverlay(nslaLibs, "National/State libraries")
// mapControl.addOverlay(ils, "Local Libraries")
ils.addTo(map) ils.addTo(map)
nslaLibs.addTo(map)
for (let k in ilsMaps ) {
mapControl.addOverlay(ilsMaps[k], k)
}
} else { } else {
// if 'Libraries' layer... // if 'Libraries' layer...
mapControl.removeLayer(fines) mapControl.removeLayer(fines)
mapControl.removeLayer(loanPeriod) mapControl.removeLayer(loanPeriod)
fines.remove() fines.remove()
loanPeriod.remove() loanPeriod.remove()
ils.remove() for (let i in ilsMaps ) {
mapControl.removeLayer(ilsMaps[i])
ilsMaps[i].remove()
}
branches.addTo(map) branches.addTo(map)
for (let k in overlayMaps ) { for (let k in overlayMaps ) {
mapControl.addOverlay(overlayMaps[k], k) mapControl.addOverlay(overlayMaps[k], k)