MediaWiki:Kartographer.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „→Jedes JavaScript an dieser Stelle wird für alle Benutzer auf Seiten geladen, die Karten enthalten: /********************************************************************** * The JavaScript in this file is a CUSTOMIZATION of the Kartographer * extension for Wikivoyage. * * For any information about Kartographer, visit the page: * https://www.mediawiki.org/wiki/Extension:Kartographer * * WHAT IS IT DOING ? * * This code listens to a Kartog…“ |
Keine Bearbeitungszusammenfassung |
||
| (10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 48: | Zeile 48: | ||
"options": { | "options": { | ||
"wvIsExternal": true, | "wvIsExternal": true, | ||
"wvName": " | "wvName": "Standard", | ||
"subdomains": [ | "subdomains": [ | ||
"a", | "a", | ||
| Zeile 65: | Zeile 65: | ||
"landscape": { | "landscape": { | ||
/* [[User:DTankersley (WMF)]] is the contact person for this API key */ | /* [[User:DTankersley (WMF)]] is the contact person for this API key */ | ||
"tilesUrl": "http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey= | "tilesUrl": "http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=dffb0dc7ee234e4b903fd6735aac05d2", | ||
"options": { | "options": { | ||
"wvIsExternal": true, | "wvIsExternal": true, | ||
"wvName": " | "wvName": "Alternative", | ||
"attribs": [ | "attribs": [ | ||
{ | { | ||
| Zeile 81: | Zeile 81: | ||
} | } | ||
] | ] | ||
} | } | ||
}, | }, | ||
| Zeile 114: | Zeile 97: | ||
"wvIsOverlay": true, | "wvIsOverlay": true, | ||
"wvIsExternal": true, | "wvIsExternal": true, | ||
"wvName": " | "wvName": "Radfahren", | ||
"attribs": [ | "attribs": [ | ||
{ | { | ||
| Zeile 129: | Zeile 112: | ||
"wvIsOverlay": true, | "wvIsOverlay": true, | ||
"wvIsExternal": true, | "wvIsExternal": true, | ||
"wvName": " | "wvName": "Wandern", | ||
"attribs": [ | "attribs": [ | ||
{ | { | ||
| Zeile 139: | Zeile 122: | ||
} | } | ||
}, | }, | ||
}; | }; | ||
/* jscs:enable validateQuoteMarks, disallowQuotedKeysInObjects */ | /* jscs:enable validateQuoteMarks, disallowQuotedKeysInObjects */ | ||
| Zeile 181: | Zeile 149: | ||
.basemap( 'mapnik' ) | .basemap( 'mapnik' ) | ||
.basemap( 'landscape' ) | .basemap( 'landscape' ) | ||
.overlay( 'cycling' ) | .overlay( 'cycling' ) | ||
.overlay( 'hiking' ) | .overlay( 'hiking' ) | ||
.datalayer( map.dataLayers ) | .datalayer( map.dataLayers ) | ||
.update(); | .update(); | ||
} ); | } ); | ||
Aktuelle Version vom 30. Januar 2022, 12:39 Uhr
/* Jedes JavaScript an dieser Stelle wird für alle Benutzer auf Seiten geladen, die Karten enthalten */
/**********************************************************************
* The JavaScript in this file is a CUSTOMIZATION of the Kartographer
* extension for Wikivoyage.
*
* For any information about Kartographer, visit the page:
* https://www.mediawiki.org/wiki/Extension:Kartographer
*
* WHAT IS IT DOING ?
*
* This code listens to a Kartographer extension hook `wikipage.maps`
* and adds a few features onto the map:
*
* - Adds a control (top right) to select a different tile layer and toggle
* overlays:
* - Adds tile layers (mapnik, mapquestopen, mapquest, landscape)
* - Adds overlays (traffic, maplabels, boundaries, hill, cycling, hiking)
* - Adds a control (top left) to show the Nearby Articles from enwikivoyage.
*
* HOW CAN YOU HELP ?
*
* We need to collect feedback, about the experimentation itself, about the
* features, the design, the user experience, the code... We also need to
* start tracking bugs and fixing them. Please help.
*
* To report a bug or an issue:
* https://phabricator.wikimedia.org/maniphest/task/create/?projects=maps
* https://phabricator.wikimedia.org/tag/maps
*
* To contribute to the code:
* https://phabricator.wikimedia.org/r/p/mediawiki/extensions/Kartographer;browse/master/
* https://github.com/wikimedia/mediawiki-extensions-Kartographer
*
**********************************************************************/
( function ( mw ) {
var wv,
ready,
nearbyArticlesCfg = {
url: 'https://tools.wmflabs.org/wikivoyage/w/data/en-articles.js',
thumbPath: '//upload.wikimedia.org/wikipedia/commons/thumb/'
},
/* jscs:disable validateQuoteMarks, disallowQuotedKeysInObjects */
maptiles = {
"mapnik": {
"tilesUrl": "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
"options": {
"wvIsExternal": true,
"wvName": "Standard",
"subdomains": [
"a",
"b",
"c"
],
"attribs": [
{
"url": "http://www.openstreetmap.org/copyright",
"name": "OpenStreetMap",
"label": "Map data"
}
]
}
},
"landscape": {
/* [[User:DTankersley (WMF)]] is the contact person for this API key */
"tilesUrl": "http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=dffb0dc7ee234e4b903fd6735aac05d2",
"options": {
"wvIsExternal": true,
"wvName": "Alternative",
"attribs": [
{
"url": "http://www.openstreetmap.org/copyright",
"name": "OpenStreetMap",
"label": "Map data"
},
{
"url": "http://www.opencyclemap.org/",
"name": "Andy Allan",
"label": "Tiles"
}
]
}
},
"boundaries": {
"tilesUrl": "http://korona.geog.uni-heidelberg.de/tiles/adminb/x={x}&y={y}&z={z}",
"options": {
"wvIsOverlay": true,
"wvIsExternal": true,
"wvName": "Boundaries",
"attribs": []
}
},
"cycling": {
"tilesUrl": "http://tile.waymarkedtrails.org/cycling/{z}/{x}/{y}.png",
"options": {
"wvIsOverlay": true,
"wvIsExternal": true,
"wvName": "Radfahren",
"attribs": [
{
"url": "http://cycling.waymarkedtrails.org",
"name": "Waymarked Trails",
"label": "Cycling routes"
}
]
}
},
"hiking": {
"tilesUrl": "http://tile.waymarkedtrails.org/hiking/{z}/{x}/{y}.png",
"options": {
"wvIsOverlay": true,
"wvIsExternal": true,
"wvName": "Wandern",
"attribs": [
{
"url": "http://hiking.waymarkedtrails.org",
"name": "Waymarked Trails",
"label": "Hiking trails"
}
]
}
},
};
/* jscs:enable validateQuoteMarks, disallowQuotedKeysInObjects */
mw.hook( 'wikipage.maps' ).add( function ( maps ) {
ready = ready || mw.loader.using( [ 'oojs-ui', 'ext.kartographer.wv' ] ).done( function () {
wv = mw.loader.require( 'ext.kartographer.wv' );
wv.NearbyArticles.setConfig( nearbyArticlesCfg );
$.each( maptiles, function ( i, tile ) {
wv.wikivoyage.addTileLayer( i, tile.tilesUrl, tile.options );
} );
} );
// `maps` can be an array
maps = $.isArray( maps ) ? maps : [ maps ];
ready.done( function () {
// customize each map
$.each( maps, function ( i, map ) {
var wvmap = new wv.WVMap( map );
wvmap.controlLayers()
.basemap( 'mapnik' )
.basemap( 'landscape' )
.overlay( 'cycling' )
.overlay( 'hiking' )
.datalayer( map.dataLayers )
.update();
} );
} );
} );
} )( mediaWiki );