aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/tile/TileLayer.WMS.js
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
committerJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
commit3d0d3bc97270095fae5f9a2508068631c46a5e61 (patch)
tree76778fcacaae35fc5662f276dab512a07bcee186 /extlib/leaflet/src/layer/tile/TileLayer.WMS.js
parentd7bec8577ea1b4d83df097f586324445fed1ef50 (diff)
parent9542a2ba076b7e00e79d7adb1a4e90a095427645 (diff)
downloadmediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.lz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.xz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.zip
Merge remote-tracking branch 'joar/exif-rebase'
Diffstat (limited to 'extlib/leaflet/src/layer/tile/TileLayer.WMS.js')
-rw-r--r--extlib/leaflet/src/layer/tile/TileLayer.WMS.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/extlib/leaflet/src/layer/tile/TileLayer.WMS.js b/extlib/leaflet/src/layer/tile/TileLayer.WMS.js
new file mode 100644
index 00000000..2f4ad05a
--- /dev/null
+++ b/extlib/leaflet/src/layer/tile/TileLayer.WMS.js
@@ -0,0 +1,47 @@
+L.TileLayer.WMS = L.TileLayer.extend({
+ defaultWmsParams: {
+ service: 'WMS',
+ request: 'GetMap',
+ version: '1.1.1',
+ layers: '',
+ styles: '',
+ format: 'image/jpeg',
+ transparent: false
+ },
+
+ initialize: function(/*String*/ url, /*Object*/ options) {
+ this._url = url;
+
+ this.wmsParams = L.Util.extend({}, this.defaultWmsParams);
+ this.wmsParams.width = this.wmsParams.height = this.options.tileSize;
+
+ for (var i in options) {
+ // all keys that are not TileLayer options go to WMS params
+ if (!this.options.hasOwnProperty(i)) {
+ this.wmsParams[i] = options[i];
+ }
+ }
+
+ L.Util.setOptions(this, options);
+ },
+
+ onAdd: function(map) {
+ var projectionKey = (parseFloat(this.wmsParams.version) >= 1.3 ? 'crs' : 'srs');
+ this.wmsParams[projectionKey] = map.options.crs.code;
+
+ L.TileLayer.prototype.onAdd.call(this, map);
+ },
+
+ getTileUrl: function(/*Point*/ tilePoint, /*Number*/ zoom)/*-> String*/ {
+ var tileSize = this.options.tileSize,
+ nwPoint = tilePoint.multiplyBy(tileSize),
+ sePoint = nwPoint.add(new L.Point(tileSize, tileSize)),
+ nwMap = this._map.unproject(nwPoint, this._zoom, true),
+ seMap = this._map.unproject(sePoint, this._zoom, true),
+ nw = this._map.options.crs.project(nwMap),
+ se = this._map.options.crs.project(seMap),
+ bbox = [nw.x, se.y, se.x, nw.y].join(',');
+
+ return this._url + L.Util.getParamString(this.wmsParams) + "&bbox=" + bbox;
+ }
+}); \ No newline at end of file