chore: do not introduce a new global, use L and L.U already there
This commit is contained in:
parent
1f5bfcb567
commit
68f2de7f44
6 changed files with 26 additions and 29 deletions
|
@ -7,4 +7,4 @@ import { Request, ServerRequest, RequestError, HTTPError, NOKError } from './req
|
||||||
|
|
||||||
// Copy the leaflet module, it's expected by leaflet plugins to be writeable.
|
// Copy the leaflet module, it's expected by leaflet plugins to be writeable.
|
||||||
window.L = { ...L }
|
window.L = { ...L }
|
||||||
window.umap = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser }
|
window.L.U = { URLs, Request, ServerRequest, RequestError, HTTPError, NOKError, Browser }
|
||||||
|
|
|
@ -13,7 +13,7 @@ L.U.AutoComplete = L.Class.extend({
|
||||||
initialize: function (el, options) {
|
initialize: function (el, options) {
|
||||||
this.el = el
|
this.el = el
|
||||||
const ui = new L.U.UI(document.querySelector('header'))
|
const ui = new L.U.UI(document.querySelector('header'))
|
||||||
this.server = new window.umap.ServerRequest(ui)
|
this.server = new L.U.ServerRequest(ui)
|
||||||
L.setOptions(this, options)
|
L.setOptions(this, options)
|
||||||
let CURRENT = null
|
let CURRENT = null
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -739,7 +739,19 @@ L.U.DataLayer.addInitHook(function () {
|
||||||
if (this.isVisible()) this.propagateShow()
|
if (this.isVisible()) this.propagateShow()
|
||||||
})
|
})
|
||||||
|
|
||||||
L.U.Map.include({
|
const ControlsMixin = {
|
||||||
|
HIDDABLE_CONTROLS: [
|
||||||
|
'zoom',
|
||||||
|
'search',
|
||||||
|
'fullscreen',
|
||||||
|
'embed',
|
||||||
|
'locate',
|
||||||
|
'measure',
|
||||||
|
'editinosm',
|
||||||
|
'datalayers',
|
||||||
|
'star',
|
||||||
|
'tilelayers',
|
||||||
|
],
|
||||||
_openFacet: function () {
|
_openFacet: function () {
|
||||||
const container = L.DomUtil.create('div', 'umap-facet-search'),
|
const container = L.DomUtil.create('div', 'umap-facet-search'),
|
||||||
title = L.DomUtil.add('h3', 'umap-filter-title', container, L._('Facet search')),
|
title = L.DomUtil.add('h3', 'umap-filter-title', container, L._('Facet search')),
|
||||||
|
@ -1043,7 +1055,7 @@ L.U.Map.include({
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
/* Used in view mode to define the current tilelayer */
|
/* Used in view mode to define the current tilelayer */
|
||||||
L.U.TileLayerControl = L.Control.IconLayers.extend({
|
L.U.TileLayerControl = L.Control.IconLayers.extend({
|
||||||
|
@ -1065,7 +1077,10 @@ L.U.TileLayerControl = L.Control.IconLayers.extend({
|
||||||
// when the tilelayer is actually added to the map (needs this._tileZoom
|
// when the tilelayer is actually added to the map (needs this._tileZoom
|
||||||
// to be defined)
|
// to be defined)
|
||||||
// Fixme when https://github.com/Leaflet/Leaflet/pull/9201 is released
|
// Fixme when https://github.com/Leaflet/Leaflet/pull/9201 is released
|
||||||
const icon = L.Util.template(layer.options.url_template, this.map.demoTileInfos)
|
const icon = L.Util.template(
|
||||||
|
layer.options.url_template,
|
||||||
|
this.map.demoTileInfos
|
||||||
|
)
|
||||||
layers.push({
|
layers.push({
|
||||||
title: layer.options.name,
|
title: layer.options.name,
|
||||||
layer: layer,
|
layer: layer,
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
/* Poor man pub/sub handler, enough for now */
|
|
||||||
|
|
||||||
L.UmapSingleton = L.Evented.extend({})
|
|
||||||
L.U = new L.UmapSingleton()
|
|
||||||
L.U.Map = L.Map.extend({})
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utils
|
* Utils
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,20 +55,8 @@ L.Map.mergeOptions({
|
||||||
featuresHaveOwner: false,
|
featuresHaveOwner: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
L.U.Map.include({
|
L.U.Map = L.Map.extend({
|
||||||
HIDDABLE_CONTROLS: [
|
includes: [ControlsMixin],
|
||||||
'zoom',
|
|
||||||
'search',
|
|
||||||
'fullscreen',
|
|
||||||
'embed',
|
|
||||||
'locate',
|
|
||||||
'measure',
|
|
||||||
'editinosm',
|
|
||||||
'datalayers',
|
|
||||||
'star',
|
|
||||||
'tilelayers',
|
|
||||||
],
|
|
||||||
|
|
||||||
editableOptions: {
|
editableOptions: {
|
||||||
'zoom': undefined,
|
'zoom': undefined,
|
||||||
'scrollWheelZoom': Boolean,
|
'scrollWheelZoom': Boolean,
|
||||||
|
@ -154,13 +142,13 @@ L.U.Map.include({
|
||||||
|
|
||||||
// After calling parent initialize, as we are doing initCenter our-selves
|
// After calling parent initialize, as we are doing initCenter our-selves
|
||||||
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
|
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
|
||||||
this.urls = new window.umap.URLs(this.options.urls)
|
this.urls = new L.U.URLs(this.options.urls)
|
||||||
|
|
||||||
this.ui = new L.U.UI(this._container)
|
this.ui = new L.U.UI(this._container)
|
||||||
this.ui.on('dataloading', (e) => this.fire('dataloading', e))
|
this.ui.on('dataloading', (e) => this.fire('dataloading', e))
|
||||||
this.ui.on('dataload', (e) => this.fire('dataload', e))
|
this.ui.on('dataload', (e) => this.fire('dataload', e))
|
||||||
this.server = new window.umap.ServerRequest(this.ui)
|
this.server = new L.U.ServerRequest(this.ui)
|
||||||
this.request = new window.umap.Request(this.ui)
|
this.request = new L.U.Request(this.ui)
|
||||||
|
|
||||||
this.initLoader()
|
this.initLoader()
|
||||||
this.name = this.options.name
|
this.name = this.options.name
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.addEventListener('DOMContentLoaded', event => {
|
window.addEventListener('DOMContentLoaded', event => {
|
||||||
const ui = new L.U.UI(document.querySelector('header'))
|
const ui = new L.U.UI(document.querySelector('header'))
|
||||||
const server = new window.umap.ServerRequest(ui)
|
const server = new L.U.ServerRequest(ui)
|
||||||
const getMore = async function (e) {
|
const getMore = async function (e) {
|
||||||
L.DomEvent.stop(e)
|
L.DomEvent.stop(e)
|
||||||
const [{html}, response, error] = await server.get(this.href)
|
const [{html}, response, error] = await server.get(this.href)
|
||||||
|
|
Loading…
Reference in a new issue