diff --git a/Layout/default/Building/Index.php b/Layout/default/Building/Index.php index b53781942..efff4a2d8 100644 --- a/Layout/default/Building/Index.php +++ b/Layout/default/Building/Index.php @@ -397,7 +397,7 @@ }); } } else { - buildingMap = L.map('building-map', {fullscreenControl: true}).setView([, ], 12); + buildingMap = L.map('building-map', {fullscreenControl: true, centerControl: true, switchviewControl: true}).setView([, ], 12); } if(!(currentTileset in tileLayers)) { diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 245bb7e86..19650db08 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -437,7 +437,7 @@ }); } } else { - preorderMap = L.map('preorder-map', {fullscreenControl: true}).setView([, ], 12); + preorderMap = L.map('preorder-map', {fullscreenControl: true, centerControl: true, switchviewControl: true}).setView([, ], 12); } if(!(currentTileset in tileLayers)) { diff --git a/Layout/default/header.php b/Layout/default/header.php index 1a1f26627..960564812 100644 --- a/Layout/default/header.php +++ b/Layout/default/header.php @@ -20,6 +20,8 @@ + + @@ -42,6 +44,8 @@ + + diff --git a/public/assets/css/leaflet-ext/leaflet.center-button.css b/public/assets/css/leaflet-ext/leaflet.center-button.css new file mode 100644 index 000000000..08dca6d7d --- /dev/null +++ b/public/assets/css/leaflet-ext/leaflet.center-button.css @@ -0,0 +1,11 @@ +.leaflet-control-center a { + background:#fff url(map-center-button.png) no-repeat 0 0; +} + +@media +(-webkit-min-device-pixel-ratio:2), +(min-resolution:192dpi) { + .leaflet-control-center a { + background-image:url(map-center-button-2x.png); + } +} diff --git a/public/assets/css/leaflet-ext/leaflet.switch-view-button.css b/public/assets/css/leaflet-ext/leaflet.switch-view-button.css new file mode 100644 index 000000000..1b83816af --- /dev/null +++ b/public/assets/css/leaflet-ext/leaflet.switch-view-button.css @@ -0,0 +1,11 @@ +.leaflet-control-switch-view a { + background:#fff url(map-switch-view.png) no-repeat 0 0; +} + +@media +(-webkit-min-device-pixel-ratio:2), +(min-resolution:192dpi) { + .leaflet-control-switch-view a { + background-image:url(map-switch-view-2x.png); + } +} diff --git a/public/assets/css/leaflet-ext/map-center-button-2x.png b/public/assets/css/leaflet-ext/map-center-button-2x.png new file mode 100644 index 000000000..13953611a Binary files /dev/null and b/public/assets/css/leaflet-ext/map-center-button-2x.png differ diff --git a/public/assets/css/leaflet-ext/map-center-button.png b/public/assets/css/leaflet-ext/map-center-button.png new file mode 100644 index 000000000..f309dfc9f Binary files /dev/null and b/public/assets/css/leaflet-ext/map-center-button.png differ diff --git a/public/assets/css/leaflet-ext/map-switch-view-2x.png b/public/assets/css/leaflet-ext/map-switch-view-2x.png new file mode 100644 index 000000000..c11d280c3 Binary files /dev/null and b/public/assets/css/leaflet-ext/map-switch-view-2x.png differ diff --git a/public/assets/css/leaflet-ext/map-switch-view.png b/public/assets/css/leaflet-ext/map-switch-view.png new file mode 100644 index 000000000..d5e6cbd7b Binary files /dev/null and b/public/assets/css/leaflet-ext/map-switch-view.png differ diff --git a/public/assets/js/leaflet-ext/leaflet.center-button.js b/public/assets/js/leaflet-ext/leaflet.center-button.js new file mode 100644 index 000000000..0c0bd2637 --- /dev/null +++ b/public/assets/js/leaflet-ext/leaflet.center-button.js @@ -0,0 +1,64 @@ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define(['leaflet'], factory); + } else if (typeof module !== 'undefined') { + // Node/CommonJS + module.exports = factory(require('leaflet')); + } else { + // Browser globals + if (typeof window.L === 'undefined') { + throw new Error('Leaflet must be loaded first'); + } + factory(window.L); + } +}(function (L) { + L.Control.Center = L.Control.extend({ + options: { + position: 'bottomleft', + title: 'Zentrieren' + }, + + onAdd: function (map) { + var container = L.DomUtil.create('div', 'leaflet-control-center leaflet-bar leaflet-control'); + + this.link = L.DomUtil.create('a', 'leaflet-control-center-button leaflet-bar-part', container); + this.link.href = '#'; + + this._map = map; + this.link.title = this.options.title; + + L.DomEvent.on(this.link, 'click', this._click, this); + + return container; + }, + + _click: function (e) { + L.DomEvent.stopPropagation(e); + L.DomEvent.preventDefault(e); + this._map.centerMap(); + }, + + }); + + L.Map.include({ + centerMap: function() { + if(typeof mapCenterPos !== 'undefined') { + this.setView(mapCenterPos); + } + + }, + + }); + + L.Map.addInitHook(function () { + if (this.options.centerControl) { + this.centerControl = new L.Control.Center(this.options.centerControl); + this.addControl(this.centerControl); + } + }); + + L.control.center = function (options) { + return new L.Control.Center(options); + }; +})); \ No newline at end of file diff --git a/public/assets/js/leaflet-ext/leaflet.switch-view-button.js b/public/assets/js/leaflet-ext/leaflet.switch-view-button.js new file mode 100644 index 000000000..20467dd7b --- /dev/null +++ b/public/assets/js/leaflet-ext/leaflet.switch-view-button.js @@ -0,0 +1,62 @@ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define(['leaflet'], factory); + } else if (typeof module !== 'undefined') { + // Node/CommonJS + module.exports = factory(require('leaflet')); + } else { + // Browser globals + if (typeof window.L === 'undefined') { + throw new Error('Leaflet must be loaded first'); + } + factory(window.L); + } +}(function (L) { + L.Control.Switchview = L.Control.extend({ + options: { + position: 'bottomleft', + title: 'Zwischen Karte und Satellitenansicht wechseln' + }, + + onAdd: function (map) { + var container = L.DomUtil.create('div', 'leaflet-control-switch-view leaflet-bar leaflet-control'); + + this.link = L.DomUtil.create('a', 'leaflet-control-switch-view-button leaflet-bar-part', container); + this.link.href = '#'; + + this._map = map; + this.link.title = this.options.title; + + L.DomEvent.on(this.link, 'click', this._click, this); + + return container; + }, + + _click: function (e) { + L.DomEvent.stopPropagation(e); + L.DomEvent.preventDefault(e); + this._map.toggleTileset(); + }, + + }); + + L.Map.include({ + toggleTileset: function() { + toggleTileset(); + + }, + + }); + + L.Map.addInitHook(function () { + if (this.options.switchviewControl) { + this.switchviewControl = new L.Control.Switchview(this.options.switchviewControl); + this.addControl(this.switchviewControl); + } + }); + + L.control.switchview = function (options) { + return new L.Control.Switchview(options); + }; +})); \ No newline at end of file