diff options
| author | adamhrv <adam@ahprojects.com> | 2019-03-04 17:07:32 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-03-04 17:07:32 +0100 |
| commit | 83f920dc8c47e212431f1c86d56304afd70d3c54 (patch) | |
| tree | 4aec389c76458c3a84e4a1c00094b25b4ad5e02b /client/map/index.js | |
| parent | 7bc747994eb0b6c502e1e2b6ee37492e6feac06b (diff) | |
| parent | 9a23f6779df8cc397b903c3c56881710bd2f98fc (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'client/map/index.js')
| -rw-r--r-- | client/map/index.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/client/map/index.js b/client/map/index.js index 4b922ec5..a9afe211 100644 --- a/client/map/index.js +++ b/client/map/index.js @@ -37,13 +37,19 @@ const redDot = L.icon({ popupAnchor: [0, -5] // point from which the popup should open relative to the iconAnchor }) -function addMarker(map, latlng, title, subtext) { +function addMarker(map, latlng, title, subtext, year) { const marker = L.marker(latlng, { icon: redDot }).addTo(map) - marker.bindPopup([ + let message = [ "<b>", title, "</b>", + ] + message = message.concat([ "<br>", subtext, - ].join('')) + ]) + if (year) { + message.push(" (" + year + ")") + } + marker.bindPopup(message.join('')) return marker } @@ -86,13 +92,13 @@ export default function append(el, payload) { 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) + addMarker(map, latlng, citation.title, citationAddress.name, citation.year) addArc(map, source, latlng, arcStyles[citationAddress.type]) }) console.log(paper) - const rootMarker = addMarker(map, source, paper.title, paper.address) + const rootMarker = addMarker(map, source, paper.title, address.name, paper.year) rootMarker.openPopup() // a transparent div to cover the map, so normal scroll events will not be eaten by leaflet |
