diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-03-04 23:06:02 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-03-04 23:06:02 +0100 |
| commit | 229289d3f95b6990855cee78b289cfb06a54eb69 (patch) | |
| tree | 9cbf95528a7ec6c82cb08ef612a33b02f94ff010 /client/map | |
| parent | b7a3687392835aeba24becf21ceaea00bd77d516 (diff) | |
| parent | 97b71242238321842d77630b6448b6c48eadf932 (diff) | |
putting links on maps, citations
Diffstat (limited to 'client/map')
| -rw-r--r-- | client/map/index.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/client/map/index.js b/client/map/index.js index a9afe211..ec9ebe66 100644 --- a/client/map/index.js +++ b/client/map/index.js @@ -37,11 +37,16 @@ const redDot = L.icon({ popupAnchor: [0, -5] // point from which the popup should open relative to the iconAnchor }) -function addMarker(map, latlng, title, subtext, year) { +function addMarker(map, latlng, title, subtext, year, pdf) { const marker = L.marker(latlng, { icon: redDot }).addTo(map) let message = [ "<b>", title, "</b>", ] + if (pdf && pdf.length) { + message.unshift("<a href='" + pdf[0] + "' target='_blank'>") + message.push("</a>") + } + message = message.concat([ "<br>", subtext, @@ -84,15 +89,19 @@ export default function append(el, payload) { source = [address.lat, address.lng].map(n => parseFloat(n)) } else { console.error("No address found for root paper") - console.log(data) + // console.log(data) } citations.forEach(citation => { - // console.log(citation) + console.log(citation) + if (!citation.addresses) { + console.log(citation) + return + } const citationAddress = citation.addresses[0] const latlng = [citationAddress.lat, citationAddress.lng].map(n => parseFloat(n)) if (Number.isNaN(latlng[0]) || Number.isNaN(latlng[1])) return - addMarker(map, latlng, citation.title, citationAddress.name, citation.year) + addMarker(map, latlng, citation.title, citationAddress.name, citation.year, citation.pdf) addArc(map, source, latlng, arcStyles[citationAddress.type]) }) @@ -107,7 +116,9 @@ export default function append(el, payload) { mapCover.innerHTML = "<div class='cover_message'>Click here to explore the map</div>" mapCover.querySelector('div').addEventListener('click', () => { map.scrollWheelZoom.enable() - el.removeChild(mapCover) + if (mapCover.parentNode === el) { + el.removeChild(mapCover) + } }) function stopPropagation(e) { e.stopPropagation() @@ -118,7 +129,9 @@ export default function append(el, payload) { map.scrollWheelZoom.disable() map.on('focus', () => { map.scrollWheelZoom.enable() - el.removeChild(mapCover) + if (mapCover.parentNode === el) { + el.removeChild(mapCover) + } }) map.on('blur', () => { map.scrollWheelZoom.disable() |
