2021-01-20 09:28:43 +11:00
const boundaries = fetch ( 'data/boundaries.topo.json' )
. then ( response => response . json ( ) )
2021-01-22 18:29:30 +11:00
const branchesCsv = fetch ( 'data/public_library_locations.csv' )
2021-01-20 09:28:43 +11:00
. then ( response => response . text ( ) ) ;
2021-01-22 18:29:30 +11:00
const ikcCsv = fetch ( 'data/indigenous_knowledge_centre_locations.csv' )
2021-01-20 09:28:43 +11:00
. then ( response => response . text ( ) ) ;
2021-01-22 18:29:30 +11:00
const mechanics = fetch ( 'data/mechanics_institute_locations.csv' )
2021-01-20 09:28:43 +11:00
. then ( response => response . text ( ) ) ;
2021-01-22 18:29:30 +11:00
const nslaBranches = fetch ( 'data/nsla_library_locations.csv' )
2021-01-20 09:28:43 +11:00
. then ( response => response . text ( ) ) ;
2022-10-29 16:11:21 +11:00
const caul = fetch ( 'data/academic_library_locations.csv' )
. then ( response => response . text ( ) ) ;
2021-01-24 17:00:28 +11:00
var isSmallScreen = window . screen . availWidth < 800 ;
2021-03-08 16:18:45 +11:00
function BaseMap ( id ) {
this . id = id ;
return L . tileLayer ( 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}' , {
2021-01-20 09:28:43 +11:00
attribution : 'Map data © <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>' ,
2021-01-17 19:47:25 +11:00
maxZoom : 18 ,
2021-03-08 16:18:45 +11:00
id : id ,
2021-01-20 09:28:43 +11:00
tileSize : 512 ,
zoomOffset : - 1 ,
accessToken : mapBoxToken
2021-03-08 16:18:45 +11:00
} )
}
2021-01-17 19:47:25 +11:00
2021-09-06 19:12:40 +10:00
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' :
2024-02-11 14:20:30 +11:00
f == 'FOLIO' ? '#0dc5ff' :
2021-09-06 19:12:40 +10:00
f == 'Follett Destiny' ? '#df4917' :
f == 'Infor V-smart' ? '#e174c1' :
2022-09-03 17:07:53 +10:00
f == 'Innovative Polaris' ? '#8e7cc3' :
2021-09-06 19:12:40 +10:00
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 ) {
2021-03-08 16:18:45 +11:00
this . data = data ;
this . color = color ;
2021-09-06 19:12:40 +10:00
this . outline = outline ;
this . type = type ;
2021-03-08 16:18:45 +11:00
return L . layerGroup ( [
L . geoCsv ( data , {
2022-09-03 17:07:53 +10:00
firstLineTitles : true ,
2021-03-08 16:18:45 +11:00
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
2021-09-06 19:12:40 +10:00
if ( type === 'ils' ) {
layer . bindPopup (
2022-09-03 17:07:53 +10:00
` <strong> ${ feature . properties . town } </strong> ` +
2022-10-29 16:11:21 +11:00
` <p> ${ feature . properties . ils } </p> ` +
` <p> ${ feature . properties . discovery } </p> `
2021-09-06 19:12:40 +10:00
)
} else {
layer . bindPopup (
2022-09-03 17:07:53 +10:00
` <strong> ${ feature . properties . town } </strong> ` +
2021-09-06 19:12:40 +10:00
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
}
2021-03-08 16:18:45 +11:00
} ,
pointToLayer : function ( f , latlng ) {
2021-09-06 19:12:40 +10:00
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
2021-03-08 16:18:45 +11:00
}
} ) ,
L . geoCsv ( data , {
2022-09-03 17:07:53 +10:00
firstLineTitles : true ,
2021-03-08 16:18:45 +11:00
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
2022-09-03 17:07:53 +10:00
` <strong> ${ feature . properties . town } </strong> ` +
2021-03-08 16:18:45 +11:00
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( f , latlng ) {
2021-09-06 19:12:40 +10:00
let col = type === 'ils' ? getIlsColor ( f . properties . ils ) : color ;
return L . circleMarker ( latlng , { color : col , radius : 2 , fill : true } )
2021-03-08 16:18:45 +11:00
}
} )
] )
}
2021-01-20 09:28:43 +11:00
2021-03-08 16:18:45 +11:00
2022-10-29 16:11:21 +11:00
Promise . all ( [ boundaries , branchesCsv , ikcCsv , mechanics , nslaBranches , caul ] )
2021-03-08 16:18:45 +11:00
. then ( data => {
// add tile layers for each base map
const baseMap = new BaseMap ( 'mapbox/dark-v10' )
const baseRules = new BaseMap ( 'mapbox/light-v10' )
const baseIls = new BaseMap ( 'mapbox/light-v10' )
2021-01-25 13:43:10 +11:00
2021-01-20 09:28:43 +11:00
// attach map to #mapid div above and centre
const map = L . map ( 'mapid' , {
center : [ - 27.00 , 133.000 ] ,
2021-01-24 17:00:28 +11:00
zoom : isSmallScreen ? 4 : 5 ,
2021-01-20 09:28:43 +11:00
layers : [ baseMap ]
} ) ;
2021-03-08 16:18:45 +11:00
// LOCATION LAYERS
2021-09-06 19:12:40 +10:00
const branches = new LocationsLayer ( data [ 1 ] , '#FF3961' , 800 )
const ikcs = new LocationsLayer ( data [ 2 ] , '#76DBA7' , 800 )
const mechsAndSoA = new LocationsLayer ( data [ 3 ] , 'rgb(255,165,0)' , 800 )
const otherLibs = new LocationsLayer ( data [ 4 ] , '#75f857' , 800 )
const nslaLibs = new LocationsLayer ( data [ 4 ] , '#FF3961' , 20000 , 'ils' )
2022-10-29 16:11:21 +11:00
const academicLibs = new LocationsLayer ( data [ 5 ] , '#0073A1' , 1000 , 'ils' )
2021-03-08 16:18:45 +11:00
// add to the initial map on load
branches . addTo ( map )
ikcs . addTo ( map )
mechsAndSoA . addTo ( map )
otherLibs . addTo ( map )
2021-01-20 09:28:43 +11:00
// Use TopoJSON
// -----------------------------------------------------------------
2021-03-08 16:18:45 +11:00
// This snippet Copyright (c) 2013 Ryan Clark (MIT License)
2021-01-20 09:28:43 +11:00
L . TopoJSON = L . GeoJSON . extend ( {
addData : function ( jsonData ) {
if ( jsonData . type === 'Topology' ) {
for ( let key in jsonData . objects ) {
geojson = topojson . feature ( jsonData , jsonData . objects [ key ] ) ;
L . GeoJSON . prototype . addData . call ( this , geojson ) ;
}
} else {
L . GeoJSON . prototype . addData . call ( this , jsonData ) ;
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
} ,
} ) ;
// -----------------------------------------------------------------
2021-01-17 19:47:25 +11:00
2021-01-20 09:28:43 +11:00
// library services fines overlay
const fines = new L . TopoJSON ( data [ 0 ] , {
2021-01-19 18:21:36 +11:00
style : function ( feature ) {
2021-01-20 09:28:43 +11:00
return {
fillColor : getFinesColor ( feature . properties . fines ) ,
weight : 3 ,
2021-09-06 19:12:40 +10:00
color : 'white' ,
dashArray : '4' ,
2021-01-22 18:34:14 +11:00
fillOpacity : 0.2
2021-01-20 09:28:43 +11:00
}
} ,
2021-01-19 18:21:36 +11:00
onEachFeature : function onEachFeature ( feature , layer ) {
layer . on ( {
mouseover : e => highlightFeature ( e ) ,
2021-01-20 09:28:43 +11:00
mouseout : e => resetHighlight ( e , fines ) ,
2021-01-24 12:40:17 +11:00
click : e => zoomToFeature ( e , feature . properties ) ,
2021-01-20 09:28:43 +11:00
} )
}
} ) ;
// fill patterns for loan period overlay
const circles = new L . PatternCircle ( {
color : '#000' ,
weight : 1 ,
radius : 2 ,
x : 4 ,
y : 4 ,
fill : true ,
fillOpacity : 1
} ) ;
const loanTwo = new L . Pattern ( {
width : 8 ,
height : 8
} )
loanTwo . addShape ( circles ) ;
loanTwo . addTo ( map ) ;
const loanThree = new L . StripePattern ( {
color : '#000'
2022-09-03 17:07:53 +10:00
} ) ;
2021-01-20 09:28:43 +11:00
loanThree . addTo ( map ) ;
const loanFour = new L . StripePattern ( {
color : '#000' ,
weight : 6 ,
spaceWeight : 2 ,
angle : 45
2022-09-03 17:07:53 +10:00
} ) ;
2021-01-20 09:28:43 +11:00
loanFour . addTo ( map ) ;
const loanSix = new L . StripePattern ( {
color : '#000' ,
weight : 2 ,
spaceWeight : 6 ,
angle : 135
2022-09-03 17:07:53 +10:00
} ) ;
2021-01-20 09:28:43 +11:00
loanSix . addTo ( map ) ;
function getLoanFillPattern ( w ) {
return w == '2' ? loanTwo :
w == '3' ? loanThree :
w == '4' ? loanFour :
w == '6' ? loanSix : null
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
// loan period overlay
const loanPeriod = new L . TopoJSON ( data [ 0 ] , {
style : function ( feature ) {
return {
weight : 3 ,
2021-09-06 19:12:40 +10:00
color : '#fff' ,
dashArray : '4' ,
2021-01-22 18:34:14 +11:00
fillOpacity : 0.2 ,
2021-09-06 19:12:40 +10:00
fillColor : '#bbb' ,
2021-01-20 09:28:43 +11:00
fillPattern : getLoanFillPattern ( feature . properties . standard _loan _weeks )
}
} ,
onEachFeature : function onEachFeature ( feature , layer ) {
layer . on ( {
mouseover : e => highlightFeature ( e ) ,
mouseout : e => resetHighlight ( e , loanPeriod ) ,
click : zoomToFeature
} )
}
} ) ;
2021-01-25 13:43:10 +11:00
// integrated library management software
const ils = new L . TopoJSON ( data [ 0 ] , {
style : function ( feature ) {
return {
fillColor : getIlsColor ( feature . properties . ILS ) ,
weight : 3 ,
2021-09-06 19:12:40 +10:00
color : 'white' ,
dashArray : '4' ,
2021-01-25 13:43:10 +11:00
fillOpacity : 0.2
}
} ,
onEachFeature : function onEachFeature ( feature , layer ) {
layer . on ( {
mouseover : e => highlightFeature ( e ) ,
mouseout : e => resetHighlight ( e , ils ) ,
click : e => zoomToFeature ( e , feature . properties ) ,
} )
}
} ) ;
2021-01-20 09:28:43 +11:00
// ++++++++++++++
// control layers
// ++++++++++++++
const baseMaps = {
2021-09-06 19:12:40 +10:00
'Libraries' : baseMap ,
'Rules' : baseRules ,
'Library Management Software' : baseIls
2021-01-20 09:28:43 +11:00
}
2021-01-25 13:43:10 +11:00
// change the branches overlay names depending on the mode.
2021-01-20 09:28:43 +11:00
const modeButton = document . getElementById ( 'mode-button' ) ;
2021-03-08 16:18:45 +11:00
var overlayMaps = { }
2021-01-20 09:28:43 +11:00
function setGeneral ( ) {
overlayMaps = {
2021-09-06 19:12:40 +10:00
'Settler Knowledge Centres' : branches ,
'Indigenous Knowledge Centres' : ikcs ,
'Mechanics Institutes' : mechsAndSoA ,
'Colonial Knowledge Centres' : otherLibs
2021-01-17 19:47:25 +11:00
}
2021-01-25 14:32:18 +11:00
modeButton . setAttribute ( 'class' , 'visible' ) ;
2021-09-06 19:12:40 +10:00
modeButton . innerText = 'View in Colonial Mode' ;
2021-01-17 19:47:25 +11:00
}
2021-01-25 14:32:18 +11:00
function setColonial ( ) {
2021-01-20 09:28:43 +11:00
overlayMaps = {
2021-09-06 19:12:40 +10:00
'Public Libraries' : branches ,
'Indigenous Knowledge Centres' : ikcs ,
'Mechanics Institutes' : mechsAndSoA ,
'National & State Libraries' : otherLibs
2021-01-20 09:28:43 +11:00
} ;
2021-01-25 14:32:18 +11:00
modeButton . setAttribute ( 'class' , 'visible' ) ;
2021-09-06 19:12:40 +10:00
modeButton . innerText = 'View in Standard Mode' ;
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
2021-01-25 14:32:18 +11:00
if ( sessionStorage . getItem ( 'mapMode' ) === 'colonial' ) {
setColonial ( )
2021-01-20 09:28:43 +11:00
} else {
setGeneral ( )
}
2021-01-23 18:11:42 +11:00
// add control layers
var mapControl = L . control . layers (
2022-09-03 17:07:53 +10:00
baseMaps ,
overlayMaps ,
2021-09-06 19:12:40 +10:00
{ 'collapsed' : isSmallScreen }
2021-01-23 18:11:42 +11:00
) . addTo ( map ) ;
// scale
L . control . scale ( ) . addTo ( map ) ;
// info boxes
const infoBoxes = {
branches : L . control ( ) ,
fines : L . control ( ) ,
loanPeriod : L . control ( ) ,
serviceInfo : L . control ( { position : 'topleft' } )
}
2021-01-25 14:32:18 +11:00
// switching mode between standard and colonial
2021-01-20 09:28:43 +11:00
function switchMode ( ) {
2021-01-25 14:32:18 +11:00
if ( sessionStorage . getItem ( 'mapMode' ) === 'colonial' ) {
2021-01-20 09:28:43 +11:00
sessionStorage . setItem ( 'mapMode' , 'general' ) ;
setGeneral ( )
mapControl . remove ( ) ;
infoBoxes . branches . remove ( )
2021-09-06 19:12:40 +10:00
mapControl = L . control . layers ( baseMaps , overlayMaps , { 'collapsed' : isSmallScreen } ) . addTo ( map ) ;
2021-01-24 12:40:17 +11:00
if ( ! isSmallScreen ) {
infoBoxes . branches . addTo ( map )
}
2021-01-20 09:28:43 +11:00
} else {
2021-01-25 14:32:18 +11:00
sessionStorage . setItem ( 'mapMode' , 'colonial' ) ;
setColonial ( )
2021-01-20 09:28:43 +11:00
mapControl . remove ( ) ;
infoBoxes . branches . remove ( )
2021-09-06 19:12:40 +10:00
mapControl = L . control . layers ( baseMaps , overlayMaps , { 'collapsed' : isSmallScreen } ) . addTo ( map ) ;
2021-01-24 12:40:17 +11:00
if ( ! isSmallScreen ) {
infoBoxes . branches . addTo ( map )
}
2021-01-20 09:28:43 +11:00
}
}
modeButton . addEventListener ( 'click' , switchMode , false ) ;
function getFinesColor ( f ) {
return f == 'no' ? '#4dac26' :
f == 'yes' ? '#d01c8b' :
f == 'adults' ? '#f1b6da' :
f == 'by_lga' ? '#abd9e9' :
f == 'no_unconfirmed' ? '#b8e186' : '#bbb' ;
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
// highlight feature on mouse hover
function highlightFeature ( e ) {
const layer = e . target ;
layer . setStyle ( {
weight : 6 ,
color : '#FF3961' ,
2021-09-06 19:12:40 +10:00
dashArray : '0' ,
2021-01-20 09:28:43 +11:00
fillOpacity : 0
} ) ;
if ( ! L . Browser . ie && ! L . Browser . opera && ! L . Browser . edge ) {
layer . bringToFront ( ) ;
}
2021-01-24 12:40:17 +11:00
if ( ! isSmallScreen ) {
infoBoxes . serviceInfo . addTo ( map )
infoBoxes . serviceInfo . update ( layer . feature . properties )
}
2021-01-20 09:28:43 +11:00
}
2021-01-24 12:40:17 +11:00
function zoomToFeature ( e , props ) {
2021-01-20 09:28:43 +11:00
map . fitBounds ( e . target . getBounds ( ) ) ;
2021-01-24 12:40:17 +11:00
e . target . bindPopup ( `
2022-09-03 17:07:53 +10:00
< strong > $ { props . name } < / s t r o n g > ` +
` <p>Fines: ` +
2021-01-24 12:40:17 +11:00
(
2022-09-03 17:07:53 +10:00
props . fines === 'no' ? 'No' :
props . fines == 'no_unconfirmed' ? 'Probably no' :
props . fines === 'yes' ? 'Yes' :
2021-09-06 19:12:40 +10:00
props . fines == 'adults' ? 'No for children' :
props . fines == 'by_lga' ? 'Varies by LGA' : 'Unknown'
2022-09-03 17:07:53 +10:00
) +
` <br/>Loans : ` +
( ! props . standard _loan _weeks || props . standard _loan _weeks == '?' ? ` Unknown ` : ` ${ props . standard _loan _weeks } weeks ` ) +
` <br/>Software : ` +
( ! props . ILS || props . ILS == '?' ? ` Unknown ` : ` ${ props . ILS } ` ) +
` <br/>Website: ` +
2021-09-06 19:12:40 +10:00
( ! props . website || props . website == '?' ? ` Unknown ` : ` <a target="_blank" href=" ` + ` ${ props . website } ` + ` " > ` + ` ${ props . website } ` + ` </a> ` ) +
2021-01-24 12:40:17 +11:00
` </p> `
) . openPopup ( )
2021-01-20 09:28:43 +11:00
}
2021-01-24 12:40:17 +11:00
// clear on mouseout
2021-01-20 09:28:43 +11:00
function resetHighlight ( e , layer ) {
layer . resetStyle ( e . target ) ;
infoBoxes . serviceInfo . remove ( )
}
// this is used to add general info when each layer is added
function addLegend ( ) {
this . _div = L . DomUtil . create ( 'div' , 'info' )
this . update ( ) ;
return this . _div ;
}
// FINES LEGEND
infoBoxes . fines . onAdd = addLegend ;
infoBoxes . fines . update = function ( props ) {
2022-09-03 17:07:53 +10:00
this . _div . innerHTML =
2021-01-20 09:28:43 +11:00
` <p>Hover over an area for more information</p>
< section >
< div > < div class = "circle" style = "background-color: #4dac26" > < / d i v > F i n e f r e e < / d i v >
< div > < div class = "circle" style = "background-color: #b8e186" > < / d i v > F i n e f r e e ( u n c o n f i r m e d ) < / d i v >
< div > < div class = "circle" style = "background-color: #f1b6da" > < / d i v > F i n e f r e e f o r c h i l d r e n < / d i v >
< div > < div class = "circle" style = "background-color: #abd9e9" > < / d i v > F i n e p o l i c y v a r i e s < / d i v >
< div > < div class = "circle" style = "background-color: #d01c8b" > < / d i v > F i n e s f o r a l l u s e r s < / d i v >
< div > < div class = "circle" style = "background-color: #bbb" > < / d i v > U n k n o w n ( h e l p m e f i n d o u t ! ) < / d i v >
< / s e c t i o n >
`
} ;
// BRANCH LOCATIONS LEGEND
infoBoxes . branches . onAdd = addLegend ;
infoBoxes . branches . update = function ( props ) {
this . _div . innerHTML = `
< h4 > Library Branches < / h 4 >
< p > Circles represent an 800 metre radius from the library location . This is the distance generally used by urban planners to represent "conceptually within walking distance" for most people . < / p >
` };
2021-01-24 12:40:17 +11:00
if ( ! isSmallScreen ) {
infoBoxes . branches . addTo ( map ) // add by default it larger screen
}
2021-01-20 09:28:43 +11:00
// STANDARD LOAN PERIOD LEGEND
infoBoxes . loanPeriod . onAdd = addLegend ;
infoBoxes . loanPeriod . update = function ( props ) {
this . _div . innerHTML = `
2021-01-17 19:47:25 +11:00
< section >
2022-09-03 17:07:53 +10:00
< div > < div class = "circle" style = " background :
2021-01-20 09:28:43 +11:00
radial - gradient ( 4 px 4 px at 6 px 6 px , # 3 a3a3a 50 % , transparent 75 % ) ,
radial - gradient ( 4 px 4 px at 16 px 6 px , # 3 a3a3a 50 % , transparent 75 % ) ,
radial - gradient ( 4 px 4 px at 2 px 12 px , # 3 a3a3a 50 % , transparent 75 % ) ,
radial - gradient ( 4 px 4 px at 12 px 12 px , # 3 a3a3a 50 % , transparent 75 % ) ,
radial - gradient ( 4 px 4 px at 20 px 12 px , # 3 a3a3a 50 % , transparent 75 % ) ,
radial - gradient ( 4 px 4 px at 8 px 18 px , # 3 a3a3a 50 % , transparent 75 % ) ;
background - repeat : no - repeat ;
border : 1 px solid black ;
" > < / d i v > 2 w e e k s < / d i v >
< div > < div class = "circle" style = " background : repeating - linear - gradient (
0 deg ,
# 3 a3a3a ,
# 3 a3a3a 2 px ,
# fff 2 px ,
# 3 a3a3a 4 px
) " > < / d i v > 3 w e e k s < / d i v >
< div > < div class = "circle" style = " background : repeating - linear - gradient (
45 deg ,
# 3 a3a3a ,
# 3 a3a3a 3 px ,
# fff 1 px ,
# 3 a3a3a 4 px
) " > < / d i v > 4 w e e k s < / d i v >
< div > < div class = "circle" style = " background : repeating - linear - gradient (
135 deg ,
# fff ,
# fff 8 px ,
# 3 a3a3a 2 px ,
# fff 10 px
) " > < / d i v > 6 w e e k s < / d i v >
2021-01-17 19:47:25 +11:00
< div > < div class = "circle" style = "background-color: #bbb" > < / d i v > U n k n o w n ( h e l p m e f i n d o u t ! ) < / d i v >
< / s e c t i o n >
`
2021-01-20 09:28:43 +11:00
} ;
2021-01-25 13:43:10 +11:00
// FOCUSSED AREA INFOBOX (pops up on top left)
2021-01-20 09:28:43 +11:00
infoBoxes . serviceInfo . onAdd = addLegend ;
infoBoxes . serviceInfo . update = function ( props ) {
if ( props ) {
this . _div . innerHTML = ` <h4> ${ props . name } </h4> ` +
2022-09-03 17:07:53 +10:00
'<section><p>' +
2021-01-20 09:28:43 +11:00
(
2022-09-03 17:07:53 +10:00
props . fines === "no" ? "Fine free for overdue items" :
props . fines == "no_unconfirmed" ? "Probably no overdue fines" :
props . fines === "yes" ? "Overdue fines for all users" :
2021-01-20 09:28:43 +11:00
props . fines == "adults" ? "No overdue fines for children" :
props . fines == "by_lga" ? "Fine policy varies" : "No fines data"
2021-01-25 13:43:10 +11:00
) + '<br/>' +
( ! props . standard _loan _weeks || props . standard _loan _weeks == "?" ? ` No loan period data ` : ` ${ props . standard _loan _weeks } week loans ` ) +
2022-09-03 17:07:53 +10:00
` <br/>Software: ` +
2021-01-25 13:43:10 +11:00
( ! props . ILS || props . ILS == "?" ? ` Unknown ` : ` ${ props . ILS } ` ) +
2021-01-20 09:28:43 +11:00
'</p></section>'
2021-01-25 13:43:10 +11:00
}
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
2021-01-24 12:53:55 +11:00
// loan period layer is always at bottom
2021-01-20 09:28:43 +11:00
map . on ( 'overlayadd' , l => {
if ( l . name == "Loan Period" ) {
loanPeriod . bringToBack ( )
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
} )
// change overlays depending on base layer
// we remove info boxes before adding them again where relevant
// this is so we don't accidentally stack up multiple copies dependng on user
// navigation journey
2021-09-06 19:12:40 +10:00
var ilsMaps = {
2022-10-29 16:11:21 +11:00
"Academic Libraries" : academicLibs ,
2021-09-06 19:12:40 +10:00
"NSLA Libraries" : nslaLibs ,
"Local Libraries" : ils
}
2021-01-20 09:28:43 +11:00
map . on ( 'baselayerchange' , l => {
for ( let k in infoBoxes ) {
infoBoxes [ k ] . remove ( )
}
if ( l . name == "Rules" ) {
2021-01-25 13:43:10 +11:00
modeButton . setAttribute ( 'class' , 'hidden' ) ; // hide the mode button when it's not relevant
2021-01-20 09:28:43 +11:00
mapControl . addOverlay ( fines , "Fines" )
mapControl . addOverlay ( loanPeriod , "Loan Period" )
loanPeriod . addTo ( map )
fines . addTo ( map )
for ( let i in overlayMaps ) {
mapControl . removeLayer ( overlayMaps [ i ] )
overlayMaps [ i ] . remove ( )
}
2021-09-06 19:12:40 +10:00
for ( let i in ilsMaps ) {
mapControl . removeLayer ( ilsMaps [ i ] )
ilsMaps [ i ] . remove ( )
}
// ils.remove()
2021-01-24 12:53:55 +11:00
if ( ! isSmallScreen ) { // only add infoboxes to larger screens
infoBoxes . loanPeriod . addTo ( map )
infoBoxes . fines . addTo ( map )
}
2021-01-25 13:43:10 +11:00
} else if ( l . name == "Library Management Software" ) {
2021-01-20 09:28:43 +11:00
modeButton . setAttribute ( 'class' , 'hidden' ) ; // hide the mode button when it's not relevant
2021-01-25 13:43:10 +11:00
// remove any other layers
for ( let i in overlayMaps ) {
mapControl . removeLayer ( overlayMaps [ i ] )
overlayMaps [ i ] . remove ( )
}
mapControl . removeLayer ( fines )
mapControl . removeLayer ( loanPeriod )
fines . remove ( )
loanPeriod . remove ( )
// add ILS layer
ils . addTo ( map )
2021-09-06 19:12:40 +10:00
nslaLibs . addTo ( map )
2022-10-29 16:11:21 +11:00
academicLibs . addTo ( map )
2021-09-06 19:12:40 +10:00
for ( let k in ilsMaps ) {
mapControl . addOverlay ( ilsMaps [ k ] , k )
}
2021-01-20 09:28:43 +11:00
} else {
2021-01-25 13:43:10 +11:00
// if 'Libraries' layer...
2021-01-20 09:28:43 +11:00
mapControl . removeLayer ( fines )
mapControl . removeLayer ( loanPeriod )
fines . remove ( )
loanPeriod . remove ( )
2021-09-06 19:12:40 +10:00
for ( let i in ilsMaps ) {
mapControl . removeLayer ( ilsMaps [ i ] )
ilsMaps [ i ] . remove ( )
}
2021-01-20 09:28:43 +11:00
branches . addTo ( map )
for ( let k in overlayMaps ) {
mapControl . addOverlay ( overlayMaps [ k ] , k )
}
2021-01-24 12:40:17 +11:00
if ( ! isSmallScreen ) {
infoBoxes . branches . addTo ( map )
}
2021-01-20 09:28:43 +11:00
modeButton . setAttribute ( 'class' , 'visible' ) ;
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
} )
// remove the loading message once everything is loaded
const loadingDiv = document . getElementById ( "loading" ) ;
loadingDiv . remove ( )
2022-10-29 16:11:21 +11:00
} )