Bienvenue sur le wiki de Nuit debout, nous sommes le 3020 mars.
Utilisateur:Jmv/common.js : Différence entre versions
De NuitDebout
Ligne 13 : | Ligne 13 : | ||
mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css", 'text/css' ); | mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css", 'text/css' ); | ||
− | + | var global_map_cities = null; | |
− | + | var global_map_cities_data = [ | |
− | var | + | { title: "Marseille", coord: [43.293275, 5.383494], url: "https://wiki.nuitdebout.fr/wiki/Villes/Paris_(R%C3%A9publique)" }, |
+ | { title: "Paris (République)", coord: [48.86714, 2.36465], url: "https://wiki.nuitdebout.fr/wiki/Villes/Marseille" } | ||
+ | ]; | ||
− | + | $( document ).ready(function() { | |
− | + | ||
− | + | ||
− | + | ||
− | L. | + | global_map_cities = L.map('mapid').setView([46.98025, 2.59277], 5); |
− | }); | + | L.tileLayer('http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', { |
+ | maxZoom: 19, | ||
+ | attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>' | ||
+ | }).addTo(global_map_cities); | ||
+ | |||
+ | for(var item of global_map_cities_data) { | ||
+ | console.log(item); | ||
+ | L.marker( | ||
+ | item.coord, | ||
+ | {title: item.title, url: item.url} | ||
+ | ).addTo(global_map_cities).on('click', function(e) { | ||
+ | window.location.href = e.target.options.url ; | ||
+ | }); | ||
+ | } | ||
+ | }); |
Version du 2 juillet 2016 à 11:57
/*
mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.js");
mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe-ui-default.min.js");
document.addEventListener('DOMContentLoaded', function(){
var myPhotoSwipe = Code.PhotoSwipe.attach( window.document.querySelectorAll('.PhotoSwipe a'), { enableMouseWheel: false , enableKeyboard: false } );
}, false);
*/
mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js");
mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css", 'text/css' );
var global_map_cities = null;
var global_map_cities_data = [
{ title: "Marseille", coord: [43.293275, 5.383494], url: "https://wiki.nuitdebout.fr/wiki/Villes/Paris_(R%C3%A9publique)" },
{ title: "Paris (République)", coord: [48.86714, 2.36465], url: "https://wiki.nuitdebout.fr/wiki/Villes/Marseille" }
];
$( document ).ready(function() {
global_map_cities = L.map('mapid').setView([46.98025, 2.59277], 5);
L.tileLayer('http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
}).addTo(global_map_cities);
for(var item of global_map_cities_data) {
console.log(item);
L.marker(
item.coord,
{title: item.title, url: item.url}
).addTo(global_map_cities).on('click', function(e) {
window.location.href = e.target.options.url ;
});
}
});