MediaWiki:Gadget-CoordinateDiffMap.js

( function ( mw, $ ) {

if (!$( 'body' ).hasClass( 'wb-diffpage' ) || !$("table.wb-globe-details").length) return;

mw.loader.using( [ 'mapbox' ], function {       $("table.wb-globe-details").each(function (i) { var globe = $(this).find("td.wb-globe-globe a").attr("href"); if (globe != "http://gratisdata.miraheze.org/entity/Q476") return;

$(this).css("width", "100%"); $(this).css("padding-right", "23px");

$(this).find("tbody").append("   "); var lat = $(this).find("td.wb-globe-latitude").text; var lon = $(this).find("td.wb-globe-longitude").text; var precision = $(this).find("td.wb-globe-precision").text; precision = 360 / parseFloat(precision, 10) / 120; var zoom = Math.floor( Math.log(precision) / Math.log(2) ); zoom = zoom > 18 ? 18 : zoom; var map = L.map('mapmapmap'+i).setView([lat, lon], zoom);

L.tileLayer('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', {               attribution: 'Map data &copy; OSM contributors',                maxZoom: 18            }).addTo(map); L.marker([lat, lon]).addTo(map); });   });

}( mediaWiki, jQuery ) );