「MediaWiki:Kartographer.js」の版間の差分
表示
削除された内容 追加された内容
per talk page |
|||
16行目: | 16行目: | ||
* - Adds tile layers (mapnik, mapquestopen, mapquest, landscape) |
* - Adds tile layers (mapnik, mapquestopen, mapquest, landscape) |
||
* - Adds overlays (traffic, maplabels, boundaries, hill, cycling, hiking) |
* - Adds overlays (traffic, maplabels, boundaries, hill, cycling, hiking) |
||
* - Adds a control (top left) to show the Nearby Articles from enwikivoyage. |
|||
* |
* |
||
* HOW CAN YOU HELP ? |
* HOW CAN YOU HELP ? |
||
38行目: | 37行目: | ||
var wv, |
var wv, |
||
ready, |
ready, |
||
⚫ | |||
nearbyArticlesCfg = { |
|||
url: 'https://tools.wmflabs.org/wikivoyage/w/data/ja-articles.js', |
|||
thumbPath: '//upload.wikimedia.org/wikipedia/commons/thumb/' |
|||
}, |
|||
⚫ | |||
maptiles = { |
maptiles = { |
||
"OSM": { |
"OSM": { |
||
175行目: | 170行目: | ||
ready = ready || mw.loader.using( [ 'oojs-ui', 'ext.kartographer.wv' ] ).done( function () { |
ready = ready || mw.loader.using( [ 'oojs-ui', 'ext.kartographer.wv' ] ).done( function () { |
||
wv = mw.loader.require( 'ext.kartographer.wv' ); |
wv = mw.loader.require( 'ext.kartographer.wv' ); |
||
wv.NearbyArticles.setConfig( nearbyArticlesCfg ); |
|||
$.each( maptiles, function ( i, tile ) { |
$.each( maptiles, function ( i, tile ) { |
||
203行目: | 196行目: | ||
.datalayer( map.dataLayers ) |
.datalayer( map.dataLayers ) |
||
.update(); |
.update(); |
||
// https://wikivoyage.toolforge.org/w/data/ja-articles.jsに情報がないため |
|||
// wvmap.nearby(); |
|||
} ); |
} ); |
||
} ); |
} ); |
2023年10月20日 (金) 12:08時点における最新版
/* ここに記述されたJavascriptは、マップを含むページを読み込んだ際の全利用者に影響します */
/**********************************************************************
* 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)
*
* 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,
/* jscs:disable validateQuoteMarks, disallowQuotedKeysInObjects */
maptiles = {
"OSM": {
"tilesUrl": "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
"options": {
"wvIsExternal": true,
"wvName": "OSM",
"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=ca8e8a8e3f9a44c19a8edcf8fb5f90c4",
"options": {
"wvIsExternal": true,
"wvName": "Relief map",
"attribs": [
{
"url": "http://www.openstreetmap.org/copyright",
"name": "OpenStreetMap",
"label": "Map data"
},
{
"url": "http://www.opencyclemap.org/",
"name": "Andy Allan",
"label": "Tiles"
}
]
}
},
"gsi": {
"tilesUrl": "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
"options": {
"wvIsExternal": true,
"wvName": "GSIMap",
"attribs": [
{
"url": "https://www.gsi.go.jp/kikakuchousei/kikakuchousei40182.html",
"name": "国土地理院",
"label": "出典"
}
]
}
},
"traffic-line-network": {
"tilesUrl": "http://www.openptmap.org/tiles/{z}/{x}/{y}.png",
"options": {
"wvIsOverlay": true,
"wvIsExternal": true,
"wvName": "Traffic line network",
"attribs": [
{
"url": "http://openptmap.org/",
"name": "Openptmap.org",
"label": "Traffic lines"
}
],
"opacity": 0.5,
"maxNativeZoom": 17
}
},
"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": "Cycling",
"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": "Hiking",
"attribs": [
{
"url": "http://hiking.waymarkedtrails.org",
"name": "Waymarked Trails",
"label": "Hiking trails"
}
]
}
},
"hill-shading": {
"tilesUrl": "http://{s}.tiles.wmflabs.org/hillshading/{z}/{x}/{y}.png",
"options": {
"wvIsOverlay": true,
"wvIsExternal": true,
"wvName": "Hill shading",
"attribs": [
{
"url": "http://www2.jpl.nasa.gov/srtm/",
"name": "NASA",
"label": "Hill shading"
}
]
}
}
};
/* 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' );
$.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( 'OSM' )
.basemap( 'landscape' )
.basemap( 'gsi' )
.overlay( 'traffic-line-network' )
.overlay( 'boundaries' )
.overlay( 'hill-shading' )
.overlay( 'cycling' )
.overlay( 'hiking' )
.datalayer( map.dataLayers )
.update();
} );
} );
} );
} )( mediaWiki );