Skip to content

Instantly share code, notes, and snippets.

@tablacus
Last active August 5, 2018 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tablacus/f4aee1181d70301865aa64ee1278dd0e to your computer and use it in GitHub Desktop.
Save tablacus/f4aee1181d70301865aa64ee1278dd0e to your computer and use it in GitHub Desktop.
Use Leaflet (OpenStreetMap) via All-in-One Event Calendar (WordPress Plugin)
<link rel='stylesheet' id='leaflet_stylesheet-css' href='https://unpkg.com/leaflet@1.3.3/dist/leaflet.css' type='text/css' media='' />
<script async type='text/javascript' src='https://unpkg.com/leaflet@1.3.3/dist/leaflet.js'></script>
<style type="text/css">
.leaflet-zoom-box { z-index: 280; }
.leaflet-pane { z-index: 240; }
.leaflet-overlay-pane { z-index: 240; }
.leaflet-shadow-pane { z-index: 250; }
.leaflet-marker-pane { z-index: 260; }
.leaflet-tooltip-pane { z-index: 265; }
.leaflet-popup-pane { z-index: 270; }
.leaflet-control { z-index: 280; }
.leaflet-top,
.leaflet-bottom { z-index: 299; }
.ai1ec-gmap-link { z-index: 299; }
</style>
<script type="text/javascript">
var oc = document.getElementById("ai1ec-gmap-canvas");
if (oc) {
oc.style.visibility = "hidden";
}
window.addEventListener("load", function ()
{
setTimeout(function ()
{
var o = document.getElementById("ai1ec-gmap-address");
if (o) {
var oc = document.getElementById("ai1ec-gmap-canvas");
if (oc) {
oc.innerHTML = "";
oc.style.visibility = "visible";
}
var
lat_lng = o.value.split(','),
lat = parseFloat(lat_lng[0]),
lng = parseFloat(lat_lng[1]),
map = L.map('ai1ec-gmap-canvas', {
scrollWheelZoom: false,
tap: false,
dragging: window.ontouchstart !== null
}).setView(
[lat, lng],
17
);
L.tileLayer(
'//{s}.tile.osm.org/{z}/{x}/{y}.png',
{ attribution: 'Map data © <a href="https://osm.org/copyright">OpenStreetMap</a>' }
).addTo(map);
L.marker(
[lat, lng]
).addTo(map);
}
}, 500);
}, false);
</script>
@tablacus
Copy link
Author

tablacus commented Aug 4, 2018

Use WordPress plug-in "Insert Headers and Footers" to add scripts in Footer.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment