email bluesky fediverse feed

leaflet Updated my previous Leaflet installation to the new "open-source JavaScript library for mobile-friendly interface map".

Implementation consists of a Leaflet Template and a geo Partial file, you could ude a link in the Article/Post code - such as:

<div class="code">&lt;a href="/leaflet/?@psn,14" title="view location on Leafletjs Map"&gt;&lt;img src="/images/opengeo.png" alt="" /&gt;&lt;/a&gt;</div>

Template - leaflet.html

Remember to delete [remove] from the code - it's there to stop Stacey doing it's stuff even when written as code.

<!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="keywords" content="map, openstreetmap, leaflet, stamen" />
    <meta name="viewport" content="width=device-width" />
    <title>Leaflet Map</title>
    <link rel="alternate" type="application/atom+xml" href="../../atom.xml">
    <link rel="stylesheet" href="/leaflet.css" />
    <script src="/leaflet.js"></script>
    <script type="text/javascript" src=""></script>

<div id="map"></div>

    var landscapeUrl = 'http://{s}{z}/{x}/{y}.png',
        landscapeAttribution = 'Map data &copy; <a href="">CC-BY-SA</a>, <a href="">Gravitystorm</a> Landscape Map.',
        landscapeOptions = {attribution: landscapeAttribution};
    var osmUrl = 'http://{s}{z}/{x}/{y}.png',
        osmAttribution = '&copy; <a href="">OpenStreetMap</a> contributors',
        osmOptions = {attribution: osmAttribution};

    var landscape = new L.TileLayer(landscapeUrl, landscapeOptions);
    var osm = new L.TileLayer(osmUrl, osmOptions);

    if ( {
        var qs =;
        var url = qs.split(',',3);
        var lat = parseFloat(url[0]);
        var lng = parseFloat(url[1]);
        var zmn = parseFloat(url[2]);
    else {
        var lat = 42.94033923363181;
        var lng = -2.8125;
        var zmn = 4;

    var map = new L.Map('map', {
        center: new L.LatLng(lat,lng),
        zoom: zmn,
        layers: [landscape]

    var baseMaps = {
        "Landscape": landscape,
        "Open Street Map": osm,
        "Watercolour": new L.StamenTileLayer("watercolor")

    layersControl = new L.Control.Layers(baseMaps);


    var LeafIcon = L.Icon.extend({
    options: {
            shadowUrl: '/images/pinsh.png',
            iconAnchor: [5, 21],
            shadowAnchor: [1, 22],
            popupAnchor: [0, -25]

    var redIcon = new LeafIcon({iconUrl: '/images/red.png'}),
        greenIcon = new LeafIcon({iconUrl: '/images/green.png'}),
        blueIcon = new LeafIcon({iconUrl: '/images/blue.png'}),
        yellowIcon = new LeafIcon({iconUrl: '/images/yellow.png'});


    unction onMapClick(e) {
        var latlngStr = '(' + + ', ' + e.latlng.lng.toFixed(3) + ')';
        document.getElementById('message').innerHTML = e.latlng;
    map.on('click', onMapClick);


    <a href="/"><img src="/images/logos.png" alt="home" title="home" style="border:0; position: absolute; top: 0; left: 45px;" /></a>
    <div id="message" style="position:absolute; top: 32px; left: 50px;">Click = point</div>


Partial - geoleaf.html

Remove all these * as they are there to stop the code working here, and hence hiding itself!

for*each $root do
    i*f $children do
        for*each $children do
            i*f @psn do
                var marker@id = new L.Marker([@psn], {icon: redIcon}).addTo(map).bindPopup("<h2><a href='../@url'>@title</a><br /><img src='/@th' style='width:95px;height:95px' /></h2><h3><a href='/leaflet/?@psn,15'>zoom</a></h3>");


There is a zoom function in the popup window, but you can pass whatever you like through.