Difference between revisions of "Widget:SpaceAPI"
m (added BBQ sensor) |
m (added debug mode, shortened list) |
||
Line 73: | Line 73: | ||
SpaceAPI.prototype._colorClosed = "#f00"; | SpaceAPI.prototype._colorClosed = "#f00"; | ||
SpaceAPI.prototype._colorUnknown = "#f70"; | SpaceAPI.prototype._colorUnknown = "#f70"; | ||
+ | SpaceAPI.prototype._debug = null; | ||
SpaceAPI.prototype.start = function( ) | SpaceAPI.prototype.start = function( ) | ||
{ | { | ||
// Use interval timer id as image id | // Use interval timer id as image id | ||
+ | this._debug = ( location.hash.split("#").slice(1).indexOf("debug") !== -1 ); | ||
+ | |||
this._intervalId = 0; | this._intervalId = 0; | ||
if ( this._interval > 0 ) | if ( this._interval > 0 ) | ||
Line 212: | Line 215: | ||
attribution: '© <a href="//openstreetmap.org/copyright">OpenStreetMap</a> contributors', | attribution: '© <a href="//openstreetmap.org/copyright">OpenStreetMap</a> contributors', | ||
minZoom: 2, | minZoom: 2, | ||
− | maxZoom: | + | maxZoom: 28, |
maxNativeZoom: 19 | maxNativeZoom: 19 | ||
}).addTo( this._leaflet.map ); | }).addTo( this._leaflet.map ); | ||
− | + | // Generic zoom (note that this will cause 404s | |
+ | L.tileLayer("/images/ACK_{x}_{y}_{z}.png", { | ||
attribution: 'ACKspace', | attribution: 'ACKspace', | ||
− | minZoom: | + | minZoom: 24, |
− | maxZoom: | + | maxZoom: 28, |
maxNativeZoom: 23 | maxNativeZoom: 23 | ||
}).addTo( this._leaflet.map ); | }).addTo( this._leaflet.map ); | ||
+ | // special zoom | ||
var funcLayer = new L.TileLayer.Functional( function( view ) | var funcLayer = new L.TileLayer.Functional( function( view ) | ||
{ | { | ||
− | + | var bounds = { | |
+ | 21 : { cl: 1083360, ch: 1083361, rl: 703073, rh: 703074 }, | ||
+ | 22 : { cl: 2166720, ch: 2166723, rl: 1406146, rh: 1406148 }, | ||
+ | 23 : { cl: 4333441, ch: 4333446, rl: 2812292, rh: 2812296 }, | ||
+ | 24 : { cl: 8666890, ch: 8666890, rl: 5624590, rh: 5624590 }, | ||
+ | 25 : { cl: 17333781, ch: 17333781, rl: 11249181, rh: 11249181 }, | ||
+ | 26 : { cl: 34667562, ch: 34667562, rl: 22498362, rh: 22498362 }, | ||
+ | 27 : { cl: 69335125, ch: 69335125, rl: 44996725, rh: 44996725 }, | ||
+ | 28 : { cl: 138670250, ch: 138670251, rl: 89993450, rh: 89993451 } | ||
+ | } | ||
+ | if ( bounds[ view.zoom ] ) | ||
{ | { | ||
− | + | if ( view.tile.column < bounds[ view.zoom ].cl || view.tile.column > bounds[ view.zoom ].ch ) | |
− | + | return "/images/blank.png"; | |
− | + | if ( view.tile.row < bounds[ view.zoom ].rl || view.tile.row > bounds[ view.zoom ].rh ) | |
− | + | return "/images/blank.png"; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
Line 261: | Line 258: | ||
{ | { | ||
attribution: 'ACKspace', | attribution: 'ACKspace', | ||
− | minZoom: | + | minZoom: 21, |
− | maxZoom: | + | maxZoom: 28 |
− | |||
} ).addTo( this._leaflet.map ); | } ).addTo( this._leaflet.map ); | ||
Line 275: | Line 271: | ||
}, this ); | }, this ); | ||
− | if ( | + | if ( this._debug ) |
{ | { | ||
this._leaflet.map.on( "click", function( _e ) | this._leaflet.map.on( "click", function( _e ) |
Revision as of 09:18, 30 March 2017
This widget allows you to display the Space API data (provided as JSON)
Created by Xopr
Using this widget
To insert this widget, use the following code:
{{#widget:SpaceAPI |url=/spaceAPI/ |width=260px |height=20px |padding=8px |interval=20 |float=right |features= }}
This will give the following result:
Notes
- url is mandatory, the rest is optional (leave out interval to make the data static).
- it also must be written without protocol since colon (:) is not allowed, and may be relative, for example: //ackspace.nl/spaceAPI/ or /spaceAPI/
- You must provide a unit for the sizes (i.e. px, %, etc.)
Copy to your site
To use this widget on your site, just install MediaWiki Widgets extension and copy full source code of this page to your wiki as Widget:SpaceAPI article.