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 ( ) ) ;
2021-01-24 17:00:28 +11:00
var isSmallScreen = window . screen . availWidth < 800 ;
2021-01-20 09:28:43 +11:00
Promise . all ( [ boundaries , branchesCsv , ikcCsv , mechanics , nslaBranches ] )
. then ( data => {
// add tile layer from OSM
const baseMap = L . tileLayer ( 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}' , {
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-01-20 09:28:43 +11:00
id : 'mapbox/dark-v10' ,
tileSize : 512 ,
zoomOffset : - 1 ,
accessToken : mapBoxToken
2021-01-17 19:47:25 +11:00
} ) ;
2021-01-20 09:28:43 +11:00
const baseRules = L . tileLayer ( 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}' , {
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><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' ,
tileSize : 512 ,
zoomOffset : - 1 ,
accessToken : mapBoxToken
} ) ;
2021-01-25 13:43:10 +11:00
const baseIls = L . tileLayer ( 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}' , {
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><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' ,
tileSize : 512 ,
zoomOffset : - 1 ,
accessToken : mapBoxToken
} ) ;
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 ]
} ) ;
// Use TopoJSON
// -----------------------------------------------------------------
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-22 18:29:30 +11:00
// This snippet Copyright (c) 2013 Ryan Clark (MIT License)
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 ,
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'
} ) ;
loanThree . addTo ( map ) ;
const loanFour = new L . StripePattern ( {
color : '#000' ,
weight : 6 ,
spaceWeight : 2 ,
angle : 45
} ) ;
loanFour . addTo ( map ) ;
const loanSix = new L . StripePattern ( {
color : '#000' ,
weight : 2 ,
spaceWeight : 6 ,
angle : 135
} ) ;
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 ,
color : "#fff" ,
dashArray : "4" ,
2021-01-22 18:34:14 +11:00
fillOpacity : 0.2 ,
2021-01-20 09:28:43 +11:00
fillColor : "#bbb" ,
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
} )
}
} ) ;
const branches = L . layerGroup ( [
L . geoCsv ( data [ 1 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circle ( latlng , { color : "#FF3961" , radius : 800 } ) // this is an 800m radius around the library
}
} ) ,
L . geoCsv ( data [ 1 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circleMarker ( latlng , { color : "#FF3961" , radius : 2 , fill : true } )
}
} )
] ) . addTo ( map ) // add this to the initial map on load
// Indigenous Knowledge Centre locations from csv file
const ikcs = L . layerGroup ( [
L . geoCsv ( data [ 2 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
2021-01-19 08:17:22 +11:00
)
} ,
2021-01-20 09:28:43 +11:00
pointToLayer : function ( feature , latlng ) {
return L . circle ( latlng , { color : "#76DBA7" , radius : 800 } )
2021-01-17 19:47:25 +11:00
}
2021-01-20 09:28:43 +11:00
} ) ,
L . geoCsv ( data [ 2 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
2021-01-19 08:17:22 +11:00
)
2021-01-20 09:28:43 +11:00
} ,
pointToLayer : function ( feature , latlng ) {
return L . circleMarker ( latlng , { color : "#76DBA7" , radius : 2 , fill : true } )
}
} )
] ) . addTo ( map ) // add this to the initial map on load
// mechanics institutes (Vic) & schools of arts (NSW) locations from csv file
const mechsAndSoA = L . layerGroup ( [
L . geoCsv ( data [ 3 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circle ( latlng , { color : "rgb(255,165,0)" , radius : 800 } )
}
} ) ,
L . geoCsv ( data [ 3 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circleMarker ( latlng , { color : "rgb(255,165,0)" , radius : 2 , fill : true } )
}
} )
] ) . addTo ( map ) // add this to the initial map on load
// NSLA locations from csv file
const otherLibs = L . layerGroup ( [
L . geoCsv ( data [ 4 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circle ( latlng , { color : "#75f857" , radius : 800 } )
}
} ) ,
L . geoCsv ( data [ 4 ] , {
firstLineTitles : true ,
fieldSeparator : ',' ,
onEachFeature : function ( feature , layer ) {
layer . bindPopup (
` <strong> ${ feature . properties . town } </strong> ` +
` <p> ${ feature . properties . address } <br/> ` +
` phone: ${ feature . properties . phone } </p> `
)
} ,
pointToLayer : function ( feature , latlng ) {
return L . circleMarker ( latlng , { color : "#75f857" , radius : 2 , fill : true } )
}
} )
] ) . addTo ( map ) // add this to the initial map on load
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 ,
color : "white" ,
dashArray : "4" ,
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 = {
"Libraries" : baseMap ,
"Rules" : baseRules ,
2021-01-25 13:43:10 +11:00
"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' ) ;
var overlayMaps = {
"Settler Knowledge Centres" : branches ,
"Indigenous Knowledge Centres" : ikcs ,
"Worker Pacification Centres" : mechsAndSoA ,
"Imperial Knowledge Centres" : otherLibs
2021-01-19 18:21:36 +11:00
}
2021-01-20 09:28:43 +11:00
function setGeneral ( ) {
overlayMaps = {
"Settler Knowledge Centres" : branches ,
2021-01-25 14:32:18 +11:00
"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' ) ;
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 = {
"Public Libraries" : branches ,
2021-01-25 14:32:18 +11:00
"Indigenous Knowledge Centres" : ikcs ,
2021-01-20 09:28:43 +11:00
"Mechanics Institutes" : mechsAndSoA ,
"National & State Libraries" : otherLibs
} ;
2021-01-25 14:32:18 +11:00
modeButton . setAttribute ( 'class' , 'visible' ) ;
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 (
baseMaps ,
overlayMaps ,
2021-01-24 12:40:17 +11: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-01-24 12:40:17 +11:00
mapControl = L . control . layers ( baseMaps , overlayMaps , { "collapsed" : isSmallScreen } ) . addTo ( map ) ;
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-01-24 12:40:17 +11:00
mapControl = L . control . layers ( baseMaps , overlayMaps , { "collapsed" : isSmallScreen } ) . addTo ( map ) ;
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
2021-01-25 13:43:10 +11:00
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' :
2021-01-25 22:06:51 +11:00
f == 'SirsiDynix Horizon' ? '#ffff00' :
f == 'SirsiDynix Symphony' ? '#115583' :
2021-01-25 13:43:10 +11:00
f == 'Softlink Liberty' ? '#00f9ff' :
f == 'SumWare Athenaeum' ? '#ff3232' : '#bbb' ;
}
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' ,
dashArray : "0" ,
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 ( `
< strong > $ { props . name } < / s t r o n g > ` +
` <p>Fines: ` +
(
props . fines === "no" ? "No" :
props . fines == "no_unconfirmed" ? "Probably no" :
props . fines === "yes" ? "Yes" :
props . fines == "adults" ? "No for children" :
props . fines == "by_lga" ? "Varies by LGA" : "Unknown"
) +
` <br/>Loans : ` +
( ! props . standard _loan _weeks || props . standard _loan _weeks == "?" ? ` Unknown ` : ` ${ props . standard _loan _weeks } weeks ` ) +
2021-01-25 13:43:10 +11:00
` <br/>Software : ` +
( ! props . ILS || props . ILS == "?" ? ` Unknown ` : ` ${ props . ILS } ` ) +
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 ) {
this . _div . innerHTML =
` <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 >
2021-01-20 09:28:43 +11:00
< div > < div class = "circle" style = " background :
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> ` +
'<section><p>' +
(
props . fines === "no" ? "Fine free for overdue items" :
props . fines == "no_unconfirmed" ? "Probably no overdue fines" :
props . fines === "yes" ? "Overdue fines for all users" :
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 ` ) +
` <br/>Software: ` +
( ! 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
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-01-25 13:43:10 +11:00
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-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-01-25 13:43:10 +11:00
ils . 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 ( )
} )