nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 463a11cc2540ec4fd9e3183bf5b28e7ea6ed1f4b
parent 32307b1c173206d9a6b91e49e233dbb195107c45
Author: Sergey Orlov <wladimirych@gmail.com>
Date:   Sun, 28 Jun 2020 19:59:22 +0200

add new layer Yandex tracks, #384

Diffstat:
Msrc/layers.js | 23++++++++++++++++++++---
Msrc/lib/leaflet.layer.rasterize/Yandex.js | 16++++++++++++++--
Msrc/lib/leaflet.layer.yandex/index.js | 43+++++++++++++++++++++++++++++++------------
3 files changed, 65 insertions(+), 17 deletions(-)

diff --git a/src/layers.js b/src/layers.js @@ -45,7 +45,7 @@ import urlViaCorsProxy from '~/lib/CORSProxy'; { title: 'Yandex map', isDefault: true, - layer: new L.Layer.Yandex('map', + layer: new L.Layer.Yandex.Map( { scaleDependent: true, code: 'Y', @@ -59,7 +59,7 @@ import urlViaCorsProxy from '~/lib/CORSProxy'; { title: 'Yandex Satellite', isDefault: true, - layer: new L.Layer.Yandex('sat', + layer: new L.Layer.Yandex.Sat( { scaleDependent: false, code: 'S', @@ -915,7 +915,22 @@ import urlViaCorsProxy from '~/lib/CORSProxy'; noCors: true, }) }, - + { + title: 'Yandex tracks', + isDefault: false, + layer: new L.Layer.Yandex.Tracks( + { + scaleDependent: true, + code: 'Ytr', + isOverlay: true, + isOverlayTransparent: true, + print: true, + jnx: false, + shortName: 'yandex_tracks', + noCors: true, + } + ) + }, ]; const groupsDefs = [ @@ -990,6 +1005,7 @@ import urlViaCorsProxy from '~/lib/CORSProxy'; 'Strava heatmap (run)', 'Strava heatmap (ride)', 'Strava heatmap (winter)', + 'Yandex tracks', ], }, @@ -1076,6 +1092,7 @@ import urlViaCorsProxy from '~/lib/CORSProxy'; 'Strava heatmap (run)', 'Strava heatmap (ride)', 'Strava heatmap (winter)', + 'Yandex tracks', 'Soviet topo maps grid', 'Wikimapia', diff --git a/src/lib/leaflet.layer.rasterize/Yandex.js b/src/lib/leaflet.layer.rasterize/Yandex.js @@ -1,8 +1,20 @@ import L from 'leaflet'; import '~/lib/leaflet.layer.yandex'; -L.Layer.Yandex.include({ +L.Layer.Yandex.Map.include({ cloneForPrint: function(options) { - return new L.Layer.Yandex(this._mapType, L.Util.extend({}, this.options, options)); + return new L.Layer.Yandex.Map({...this.options, ...options}); + }, +}); + +L.Layer.Yandex.Sat.include({ + cloneForPrint: function(options) { + return new L.Layer.Yandex.Sat({...this.options, ...options}); + }, +}); + +L.Layer.Yandex.Tracks.include({ + cloneForPrint: function(options) { + return new L.Layer.Yandex.Tracks({...this.options, ...options}); }, }); diff --git a/src/lib/leaflet.layer.yandex/index.js b/src/lib/leaflet.layer.yandex/index.js @@ -10,18 +10,6 @@ L.Layer.Yandex = L.TileLayer.extend({ yandexScale: L.Browser.retina ? 2 : 1 }, - initialize: function(mapType, options) { - let url; - this._mapType = mapType; - if (mapType === 'sat') { - url = 'https://sat0{s}.maps.yandex.net/tiles?l=sat&x={x}&y={y}&z={z}'; - } else { - url = 'https://vec0{s}.maps.yandex.net/tiles?l=map&x={x}&y={y}&z={z}&scale={yandexScale}'; - } - - L.TileLayer.prototype.initialize.call(this, url, options); - }, - _getTilePos: function(coords) { const tilePosLatLng = yandexCrs.pointToLatLng(coords.scaleBy(this.getTileSize()), coords.z); return this._map.project(tilePosLatLng, coords.z).subtract(this._level.origin).round(); @@ -49,3 +37,34 @@ L.Layer.Yandex = L.TileLayer.extend({ } } ); + +L.Layer.Yandex.Map = L.Layer.Yandex.extend({ + initialize: function(options) { + L.Layer.Yandex.prototype.initialize.call( + this, + 'https://vec0{s}.maps.yandex.net/tiles?l=map&x={x}&y={y}&z={z}&scale={yandexScale}', + options + ); + }, +}); + +L.Layer.Yandex.Sat = L.Layer.Yandex.extend({ + initialize: function(options) { + L.Layer.Yandex.prototype.initialize.call( + this, + 'https://sat0{s}.maps.yandex.net/tiles?l=sat&x={x}&y={y}&z={z}', + options + ); + }, +}); + +L.Layer.Yandex.Tracks = L.Layer.Yandex.extend({ + initialize: function(options) { + options = {minZoom: 10, maxNativeZoom: 16, ...options}; + L.Layer.Yandex.prototype.initialize.call( + this, + 'https://core-gpstiles.maps.yandex.net/tiles?style=point&x={x}&y={y}&z={z}', + options + ); + }, +});