commit 94601aee1837af45afdf5d4547d3c5fd8a39431a
parent 6a60417f8204aa033c01b14d1bf6ad2d19d382b8
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Tue, 24 Oct 2017 17:57:38 +0300
added layer with bing images dates
Diffstat:
4 files changed, 63 insertions(+), 22 deletions(-)
diff --git a/src/layers.js b/src/layers.js
@@ -1,7 +1,8 @@
import L from "leaflet";
import 'lib/leaflet.layer.yandex';
import 'lib/leaflet.layer.google';
-import 'lib/leaflet.layer.bing';
+import {BingLayer} from 'lib/leaflet.layer.bing';
+import {BingDates} from 'lib/leaflet.layer.bing/dates';
import config from './config';
import 'lib/leaflet.layer.soviet-topomaps-grid';
import 'lib/leaflet.layer.westraPasses';
@@ -74,7 +75,7 @@ export default function getLayers() {
order: 70,
isOverlay: false,
isDefault: true,
- layer: L.bingLayer(config.bingKey, {code: 'I', scaleDependent: false, print: true, jnx: true})
+ layer: new BingLayer(config.bingKey, {code: 'I', scaleDependent: false, print: true, jnx: true})
},
{
@@ -348,6 +349,26 @@ export default function getLayers() {
}]
},
{
+ group: 'Satellite images',
+ layers: [
+ {
+ title: 'Bing imagery acquisition dates',
+ order: 1111,
+ isOverlay: true,
+ isDefault: false,
+ layer: new BingDates({
+ code: 'Bd',
+ maxNativeZoom: 18,
+ print: true,
+ jnx: false,
+ scaleDependent: false,
+ noCors: true
+ })
+ }
+ ]
+ },
+
+ {
group: 'Norway <a href="https://www.ut.no/kart/">https://www.ut.no/kart/</a>',
layers: [
{
diff --git a/src/lib/leaflet.layer.bing/dates.js b/src/lib/leaflet.layer.bing/dates.js
@@ -0,0 +1,18 @@
+import L from 'leaflet';
+import {tile2quad} from './index';
+
+const BingDates = L.TileLayer.extend({
+ _url: 'http://mvexel.dev.openstreetmap.org/bingimageanalyzer/tile.php?t={quad}&nodepth=1',
+
+ initialize: function(options) {
+ L.Util.setOptions(this, options);
+ },
+
+ getTileUrl: function(tilePoint) {
+ var zoom = this._getZoomForUrl();
+ return this._url.replace('{quad}', tile2quad(tilePoint.x, tilePoint.y, zoom));
+ },
+ }
+);
+
+export {BingDates};
+\ No newline at end of file
diff --git a/src/lib/leaflet.layer.bing/index.js b/src/lib/leaflet.layer.bing/index.js
@@ -1,6 +1,19 @@
import L from 'leaflet';
-L.BingLayer = L.TileLayer.extend({
+
+function tile2quad(x, y, z) {
+ var quad = '';
+ for (var i = z; i > 0; i--) {
+ var digit = 0;
+ var mask = 1 << (i - 1);
+ if ((x & mask) !== 0) digit += 1;
+ if ((y & mask) !== 0) digit += 2;
+ quad += digit;
+ }
+ return quad;
+}
+
+const BingLayer = L.TileLayer.extend({
options: {
subdomains: [0, 1, 2, 3],
type: 'Aerial',
@@ -17,24 +30,13 @@ L.BingLayer = L.TileLayer.extend({
this.metaRequested = false;
},
- tile2quad: function (x, y, z) {
- var quad = '';
- for (var i = z; i > 0; i--) {
- var digit = 0;
- var mask = 1 << (i - 1);
- if ((x & mask) !== 0) digit += 1;
- if ((y & mask) !== 0) digit += 2;
- quad += digit;
- }
- return quad;
- },
getTileUrl: function (tilePoint) {
var zoom = this._getZoomForUrl();
var subdomains = this.options.subdomains,
s = this.options.subdomains[Math.abs((tilePoint.x + tilePoint.y) % subdomains.length)];
return this._url.replace('{subdomain}', s)
- .replace('{quadkey}', this.tile2quad(tilePoint.x, tilePoint.y, zoom))
+ .replace('{quadkey}', tile2quad(tilePoint.x, tilePoint.y, zoom))
.replace('{culture}', this.options.culture);
},
@@ -127,6 +129,5 @@ L.BingLayer = L.TileLayer.extend({
}
});
-L.bingLayer = function (key, options) {
- return new L.BingLayer(key, options);
-};
-\ No newline at end of file
+
+export {BingLayer, tile2quad};
+\ No newline at end of file
diff --git a/src/lib/leaflet.layer.rasterize/Bing.js b/src/lib/leaflet.layer.rasterize/Bing.js
@@ -1,7 +1,7 @@
import L from 'leaflet';
-import 'lib/leaflet.layer.bing';
+import {BingLayer} from 'lib/leaflet.layer.bing';
-L.BingLayer.include({
+BingLayer.include({
waitTilesReadyToGrab: function() {
if (this._url) {
return Promise.resolve();
@@ -20,7 +20,7 @@ L.BingLayer.include({
},
cloneForPrint: function(options) {
- return new L.BingLayer(this._key, L.Util.extend({}, this.options, options));
+ return new BingLayer(this._key, L.Util.extend({}, this.options, options));
},
}
);