diff --git a/public/css/extra.css b/public/css/extra.css index 3954c046..1622fbb6 100644 --- a/public/css/extra.css +++ b/public/css/extra.css @@ -79,6 +79,10 @@ width: 100%; height: 100%; } +.geo-map { + width: 100%; + height: 250px; +} .MJX_Assistive_MathML { display: none; diff --git a/public/css/markdown.css b/public/css/markdown.css index 5cb32d14..8f97491e 100644 --- a/public/css/markdown.css +++ b/public/css/markdown.css @@ -127,6 +127,7 @@ .markdown-body pre.graphviz, .markdown-body pre.mermaid, .markdown-body pre.abc, +.markdown-body pre.geo, .markdown-body pre.vega { text-align: center; background-color: inherit; diff --git a/public/css/slide.css b/public/css/slide.css index f00a9db4..72275c6a 100644 --- a/public/css/slide.css +++ b/public/css/slide.css @@ -224,6 +224,7 @@ pre.sequence-diagram, pre.graphviz, pre.mermaid, pre.abc, +pre.geo, pre.vega { text-align: center; background-color: white; diff --git a/public/js/extra.js b/public/js/extra.js index f32e13c8..74581463 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1,5 +1,5 @@ /* eslint-env browser, jquery */ -/* global moment, serverurl, plantumlServer */ +/* global moment, serverurl, plantumlServer, L */ import Prism from 'prismjs' import hljs from 'highlight.js' @@ -453,6 +453,31 @@ export function finishView (view) { console.warn(err) } }) + view.find('div.geo.raw').removeClass('raw').each(function (key, value) { + const $elem = $(value).parent().parent() + const $value = $(value) + const content = $value.text() + try { + if (content.match(/[\d\.\,]+/)) { + const [lng, lat, zoom] = content.split(',').map(parseFloat) + const position = [lat, lng] + $elem.html(`
`) + const map = L.map($elem.find('.geo-map')[0]).setView(position, zoom || 16) + + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: 'OSM', + maxZoom: 18, + }).addTo(map) + L.marker(position).addTo(map) + $elem.addClass('geo') + } + } catch (err) { + $elem.append(`