nakarte

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

commit 766b5feb9ef749dea87b871f384764a25e1b1898
parent 8701e3f65af70ebb96da5096d8558e39398a8be9
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Thu, 10 Nov 2016 23:36:33 +0300

changed leaflet component directory names

Diffstat:
Msrc/App.js | 12++++++------
Rsrc/lib/control.caption/caption.js -> src/lib/leaflet.control.caption/caption.js | 0
Rsrc/lib/control.caption/style.css -> src/lib/leaflet.control.caption/style.css | 0
Rsrc/lib/control.coordinates/coordinates.css -> src/lib/leaflet.control.coordinates/coordinates.css | 0
Rsrc/lib/control.coordinates/coordinates.js -> src/lib/leaflet.control.coordinates/coordinates.js | 0
Rsrc/lib/control.coordinates/coords16.png -> src/lib/leaflet.control.coordinates/coords16.png | 0
Rsrc/lib/control.layers.hotkeys/control.Layers-hotkeys.js -> src/lib/leaflet.control.layers.hotkeys/control.Layers-hotkeys.js | 0
Rsrc/lib/control.layers.hotkeys/style.css -> src/lib/leaflet.control.layers.hotkeys/style.css | 0
Rsrc/lib/control.printPages/control.css -> src/lib/leaflet.control.printPages/control.css | 0
Rsrc/lib/control.printPages/control.js -> src/lib/leaflet.control.printPages/control.js | 0
Rsrc/lib/control.printPages/form.html -> src/lib/leaflet.control.printPages/form.html | 0
Rsrc/lib/control.printPages/images/add-page-horiz.png -> src/lib/leaflet.control.printPages/images/add-page-horiz.png | 0
Rsrc/lib/control.printPages/images/add-page-vert.png -> src/lib/leaflet.control.printPages/images/add-page-vert.png | 0
Rsrc/lib/control.printPages/images/remove-pages.png -> src/lib/leaflet.control.printPages/images/remove-pages.png | 0
Rsrc/lib/control.printPages/images/settings.png -> src/lib/leaflet.control.printPages/images/settings.png | 0
Rsrc/lib/control.printPages/map-render.js -> src/lib/leaflet.control.printPages/map-render.js | 0
Rsrc/lib/control.printPages/page-feature.css -> src/lib/leaflet.control.printPages/page-feature.css | 0
Rsrc/lib/control.printPages/pageFeature.js -> src/lib/leaflet.control.printPages/pageFeature.js | 0
Rsrc/lib/hashState/Leaflet.Control.Layers.js -> src/lib/leaflet.hashState/Leaflet.Control.Layers.js | 0
Rsrc/lib/hashState/Leaflet.Map.js -> src/lib/leaflet.hashState/Leaflet.Map.js | 0
Rsrc/lib/hashState/hashState.js -> src/lib/leaflet.hashState/hashState.js | 0
Rsrc/lib/hashState/leaflet.hashState.js -> src/lib/leaflet.hashState/leaflet.hashState.js | 0
Rsrc/lib/layer.bing/bing.js -> src/lib/leaflet.layer.bing/bing.js | 0
Rsrc/lib/layer.google/google.js -> src/lib/leaflet.layer.google/google.js | 0
Asrc/lib/leaflet.layer.soviet-topomaps-grid/soviet-topomaps-grid.js | 282+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rsrc/lib/layer.yandex/style.css -> src/lib/leaflet.layer.yandex/style.css | 0
Rsrc/lib/layer.yandex/yandex.js -> src/lib/leaflet.layer.yandex/yandex.js | 0
27 files changed, 288 insertions(+), 6 deletions(-)

diff --git a/src/App.js b/src/App.js @@ -2,13 +2,13 @@ import './App.css'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; import layers from './layers'; -import './lib/control.printPages/control' -import './lib/control.caption/caption' +import 'lib/leaflet.control.printPages/control' +import 'lib/leaflet.control.caption/caption' import config from './config' -import './lib/control.coordinates/coordinates'; -import './lib/control.layers.hotkeys/control.Layers-hotkeys'; -import './lib/hashState/Leaflet.Map'; -import './lib/hashState/Leaflet.Control.Layers'; +import 'lib/leaflet.control.coordinates/coordinates'; +import 'lib/leaflet.control.layers.hotkeys/control.Layers-hotkeys'; +import 'lib/leaflet.hashState/Leaflet.Map'; +import 'lib/leaflet.hashState/Leaflet.Control.Layers'; import fixAnimationBug from 'lib/leaflet.fixAnimationBug/leaflet.fixAnimationBug' function setUp() { diff --git a/src/lib/control.caption/caption.js b/src/lib/leaflet.control.caption/caption.js diff --git a/src/lib/control.caption/style.css b/src/lib/leaflet.control.caption/style.css diff --git a/src/lib/control.coordinates/coordinates.css b/src/lib/leaflet.control.coordinates/coordinates.css diff --git a/src/lib/control.coordinates/coordinates.js b/src/lib/leaflet.control.coordinates/coordinates.js diff --git a/src/lib/control.coordinates/coords16.png b/src/lib/leaflet.control.coordinates/coords16.png Binary files differ. diff --git a/src/lib/control.layers.hotkeys/control.Layers-hotkeys.js b/src/lib/leaflet.control.layers.hotkeys/control.Layers-hotkeys.js diff --git a/src/lib/control.layers.hotkeys/style.css b/src/lib/leaflet.control.layers.hotkeys/style.css diff --git a/src/lib/control.printPages/control.css b/src/lib/leaflet.control.printPages/control.css diff --git a/src/lib/control.printPages/control.js b/src/lib/leaflet.control.printPages/control.js diff --git a/src/lib/control.printPages/form.html b/src/lib/leaflet.control.printPages/form.html diff --git a/src/lib/control.printPages/images/add-page-horiz.png b/src/lib/leaflet.control.printPages/images/add-page-horiz.png Binary files differ. diff --git a/src/lib/control.printPages/images/add-page-vert.png b/src/lib/leaflet.control.printPages/images/add-page-vert.png Binary files differ. diff --git a/src/lib/control.printPages/images/remove-pages.png b/src/lib/leaflet.control.printPages/images/remove-pages.png Binary files differ. diff --git a/src/lib/control.printPages/images/settings.png b/src/lib/leaflet.control.printPages/images/settings.png Binary files differ. diff --git a/src/lib/control.printPages/map-render.js b/src/lib/leaflet.control.printPages/map-render.js diff --git a/src/lib/control.printPages/page-feature.css b/src/lib/leaflet.control.printPages/page-feature.css diff --git a/src/lib/control.printPages/pageFeature.js b/src/lib/leaflet.control.printPages/pageFeature.js diff --git a/src/lib/hashState/Leaflet.Control.Layers.js b/src/lib/leaflet.hashState/Leaflet.Control.Layers.js diff --git a/src/lib/hashState/Leaflet.Map.js b/src/lib/leaflet.hashState/Leaflet.Map.js diff --git a/src/lib/hashState/hashState.js b/src/lib/leaflet.hashState/hashState.js diff --git a/src/lib/hashState/leaflet.hashState.js b/src/lib/leaflet.hashState/leaflet.hashState.js diff --git a/src/lib/layer.bing/bing.js b/src/lib/leaflet.layer.bing/bing.js diff --git a/src/lib/layer.google/google.js b/src/lib/leaflet.layer.google/google.js diff --git a/src/lib/leaflet.layer.soviet-topomaps-grid/soviet-topomaps-grid.js b/src/lib/leaflet.layer.soviet-topomaps-grid/soviet-topomaps-grid.js @@ -0,0 +1,282 @@ +//@require leaflet + +(function(){ + "use strict"; + function zeroPad(num, size) { + var s = num + ""; + while (s.length < size) { + s = "0" + s; + } + return s; + } + + var Nomenclature = { + getQuadName1m: function(column, row, join) { + var name = ''; + if (row < 0) { + row = -row - 1; + name = name + 'x'; + } + column = column + 31; + name += 'ABCDEFGHIJKLMNOPQRSTUV'[row] + ' &ndash; ' + zeroPad(column, 2); + for (var n=1; n <= join-1; n++) { + name += ',' + zeroPad(column+n, 2); + } + return name; + }, + + getQuadName500k: function(column, row, join) { + var name = this.getQuadName1m(Math.floor(column / 2), Math.floor(row / 2), 1); + var subquad = 2-(row & 1) * 2 + (column & 1) + 1; + name = name + ' &ndash; ' + subquad; + if (join > 1) { + name += ',' + (subquad + 1); + } + if (join == 4) { + name += ',' + this.getQuadName1m(Math.floor((column + 2) / 2), Math.floor(row / 2), 1) + ' &ndash; ' + subquad + ',' + (subquad + 1); + } + return name; + }, + + getQuadName100k: function(column, row, join) { + var name = this.getQuadName1m(Math.floor(column / 12), Math.floor(row / 12), 1); + var subquad = 132-(row % 12) * 12 + (column % 12) + 1; + name = name + ' &ndash; ' + zeroPad(subquad, 3); + if (join > 1) { + name += ',' + zeroPad(subquad+1, 3); + } + if (join == 4) { + name += ',' + zeroPad(subquad+2, 3) + ',' + zeroPad(subquad+3, 3); + } + + return name; + }, + + getQuadName050k: function(column, row, join) { + var name = this.getQuadName100k(Math.floor(column / 2), Math.floor(row / 2), 1); + var subquad = 2-(row & 1) * 2 + (column & 1) + 1; + name = name + ' &ndash; ' + subquad; + if (join > 1) { + name += ',' + (subquad + 1); + } + if (join == 4) { + name += ',' + this.getQuadName100k(Math.floor((column + 2) / 2), Math.floor(row / 2), 1) + ' &ndash; ' + subquad + ',' + (subquad + 1); + } + return name; + }, + + _getQuads: function(bounds, row_height, column_width, name_factory) { + bounds = L.latLngBounds(bounds); + var quads = []; + var min_lat = Math.max(bounds.getSouth(), -84); + var max_lat = Math.min(bounds.getNorth(), 84); + var min_row = Math.floor(min_lat / row_height); + for (var row = min_row; row * row_height < max_lat; row++) { + var row_south = row * row_height; + var row_north = row_south + row_height; + var joined_quads; + if (row_south >= 76 || row_north <= -76) { + joined_quads = 4; + } else if (row_south >= 60 || row_north <= -60) { + joined_quads = 2; + } else { + joined_quads = 1; + } + var min_lon = Math.max(bounds.getWest(), -180); + var max_lon = Math.min(bounds.getEast(), 180); + var min_column = Math.floor((min_lon+180) / column_width / joined_quads) * joined_quads - Math.round(180/column_width); + for (var column = min_column; column * column_width < max_lon; column += joined_quads) { + var column_west = column * column_width; + var column_east = column_west + column_width * joined_quads; + var quad_bounds = L.latLngBounds([[row_south, column_west], [row_north, column_east]]); + var name = name_factory(column, row, joined_quads); + quads.push({'name': name, 'bounds': quad_bounds}); + } + } + return quads; + }, + + getQuads1m: function(bounds) { + return this._getQuads(bounds, 4, 6, this.getQuadName1m); + }, + + getQuads500k: function(bounds) { + return this._getQuads(bounds, 2, 3, this.getQuadName500k.bind(this)); + }, + + getQuads100k: function(bounds) { + return this._getQuads(bounds, 4/12, 6/12, this.getQuadName100k.bind(this)); + }, + + getQuads050k: function(bounds) { + return this._getQuads(bounds, 4/12/2, 6/12/2, this.getQuadName050k.bind(this)); + } + + + }; + + L.SovietTopoGrid = L.LayerGroup.extend({ + options: {}, + + initialize: function(options) { + L.LayerGroup.prototype.initialize.call(this, options); + L.Util.setOptions(this, options); + this._updatePathViewport = L.Util.limitExecByInterval(this.__updatePathViewport, 100, this); + this._quads = {}; + }, + + onAdd: function(map) { + this._map = map; + map.on('zoomend', this._reset, this); + map.on('move', this._update, this); + this._update(); + }, + + onRemove: function(map) { + map.off('zoomend', this._reset, this); + map.off('move', this._update, this); + this._cleanupQuads(true); + }, + + _addQuad: function(bounds, id, title, color, layer) { + if (id in this._quads) { + return; + } + var rect_options = {smoothFactor: 0, + noClip: true, + clickable: false, + fill: false, + opacity: {1: 0.7, 2: 0.4}[layer], + color: color, + weight: {1: 1, 2: 3}[layer] + }; + var rect = L.rectangle(bounds, rect_options); + this.addLayer(rect); + if (layer == 1) { + rect.bringToBack(); + } + var objects = [rect]; + var html = L.Util.template('<span style="color:{color}">{title}</span>', {color:color, title: title}); + var icon = L.divIcon({html: html, className: 'leaflet-sovietgrid-quadtitle-'+layer, iconSize: null}); + var marker = L.marker(L.latLngBounds(bounds).getCenter(), {icon: icon}); + this.addLayer(marker); + objects.push(marker); + this._quads[id] = objects; + }, + + _removeQuad: function(id) { + var objects = this._quads[id]; + for (var i=0; i<objects.length; i++) { + this.removeLayer(objects[i]); + } + delete this._quads[id]; + }, + + + _addQuads: function(quads, id_prefix, color, layer) { + quads.forEach(function(quad){ + var id = id_prefix + quad.name; + this._addQuad(quad.bounds, id, quad.name, color, layer); + }.bind(this)); + }, + + _addGrid: function() { + var quads; + var layer; + var map_bbox = this._map.getBounds(); + var zoom = this._map.getZoom(); + + if (zoom >= 10) { + quads = Nomenclature.getQuads050k(map_bbox); + layer = (zoom >= 12) ? 2 : 1; + this._addQuads(quads, '050k', '#50d', layer); + } + + if (zoom >= 8 && zoom < 12) { + quads = Nomenclature.getQuads100k(map_bbox); + layer = (zoom >= 10) ? 2 : 1; + this._addQuads(quads, '100k', '#d50', layer); + } + + + if (zoom >= 6 && zoom < 10) { + quads = Nomenclature.getQuads500k(map_bbox); + layer = (zoom >= 8) ? 2 : 1; + this._addQuads(quads, '500k', '#099', layer); + } + + if (zoom >= 4 && zoom < 8) { + layer = (zoom >= 6) ? 2 : 1; + quads = Nomenclature.getQuads1m(map_bbox); + this._addQuads(quads, '1m', 'blue', layer); + } + }, + + __updatePathViewport: function() { + try { + this._map._updateSvgViewport(); + } catch (e) {} + }, + + _reset: function() { + this._update(true); + }, + + _cleanupQuads: function(reset) { + if (reset===true) { + this.clearLayers(); + this._quads = {}; + } else { + var map_bbox = this._map.getBounds(); + for (var quad_id in this._quads) { + var rect = this._quads[quad_id][0]; + if (!map_bbox.intersects(rect.getBounds())) { + this._removeQuad(quad_id); + } + } + } + }, + + _update: function(reset) { + var t = new Date().getTime(); + this._cleanupQuads(reset); + this._updatePathViewport(); + this._addGrid(); + t = new Date().getTime() - t; + console.log('Time:', t); + console.log('Objects:', this.getLayers().length); + } + }); + + (function inject_css() { + var css = ''+ + '.leaflet-sovietgrid-quadtitle-1, .leaflet-sovietgrid-quadtitle-2 {'+ + ' width: 100px;'+ + ' height: 50px;'+ + ' margin-left: -50px;'+ + ' margin-top: -25px;'+ + ' text-align: center;'+ + ' line-height: 50px;'+ + ' font-family: "Times New Roman";'+ + ' font-weight: bold;'+ + ' text-shadow: 1px 0 0.5px #eee,'+ + ' 1px 1px 0.5px #eee,'+ + ' 0 1px 0.5px #eee,'+ + ' -1px 1px 0.5px #eee,'+ + ' -1px 0 0.5px #eee,'+ + ' -1px -1px 0.5px #eee,'+ + ' 0 -1px 0.5px #eee,'+ + ' 1px -1px 0.5px #eee;'+ + ' white-space: nowrap;'+ + '}'+ + '.leaflet-sovietgrid-quadtitle-1 {'+ + ' font-size: 14px;'+ + '}'+ + '.leaflet-sovietgrid-quadtitle-2 {'+ + ' font-size: 32px;'+ + '}'; + var st = document.createElement('style'); + st.appendChild(document.createTextNode(css)); + document.getElementsByTagName('head')[0].appendChild(st); + })(); +})(); diff --git a/src/lib/layer.yandex/style.css b/src/lib/leaflet.layer.yandex/style.css diff --git a/src/lib/layer.yandex/yandex.js b/src/lib/leaflet.layer.yandex/yandex.js