Add prettier and reformat code
This commit is contained in:
parent
68eb00bae9
commit
970a34981f
37 changed files with 3459 additions and 1969 deletions
|
|
@ -3,7 +3,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
defaultOverlays: BR.confLayers.defaultOverlays,
|
||||
legacyNameToIdMap: BR.confLayers.legacyNameToIdMap,
|
||||
|
||||
initialize: function (map) {
|
||||
initialize: function(map) {
|
||||
this._map = map;
|
||||
|
||||
this._addLeafletProvidersLayers();
|
||||
|
|
@ -13,7 +13,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
|
||||
loadDefaultLayers: function() {
|
||||
if (BR.Util.localStorageAvailable()) {
|
||||
var item = localStorage.getItem("map/defaultLayers");
|
||||
var item = localStorage.getItem('map/defaultLayers');
|
||||
if (item) {
|
||||
var defaultLayers = JSON.parse(item);
|
||||
this.defaultBaseLayers = defaultLayers.baseLayers;
|
||||
|
|
@ -22,17 +22,20 @@ BR.LayersConfig = L.Class.extend({
|
|||
}
|
||||
},
|
||||
|
||||
storeDefaultLayers: function (baseLayers, overlays) {
|
||||
storeDefaultLayers: function(baseLayers, overlays) {
|
||||
if (BR.Util.localStorageAvailable()) {
|
||||
var defaultLayers = {
|
||||
baseLayers: baseLayers,
|
||||
overlays: overlays
|
||||
};
|
||||
localStorage.setItem("map/defaultLayers", JSON.stringify(defaultLayers));
|
||||
localStorage.setItem(
|
||||
'map/defaultLayers',
|
||||
JSON.stringify(defaultLayers)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_addLeafletProvidersLayers: function () {
|
||||
_addLeafletProvidersLayers: function() {
|
||||
var includeList = BR.confLayers.leafletProvidersIncludeList;
|
||||
|
||||
for (var i = 0; i < includeList.length; i++) {
|
||||
|
|
@ -44,13 +47,13 @@ BR.LayersConfig = L.Class.extend({
|
|||
name: id.replace('.', ' '),
|
||||
dataSource: 'leaflet-providers'
|
||||
},
|
||||
type: "Feature"
|
||||
type: 'Feature'
|
||||
};
|
||||
BR.layerIndex[id] = obj;
|
||||
}
|
||||
},
|
||||
|
||||
_customizeLayers: function () {
|
||||
_customizeLayers: function() {
|
||||
var propertyOverrides = BR.confLayers.getPropertyOverrides();
|
||||
|
||||
for (id in propertyOverrides) {
|
||||
|
|
@ -68,10 +71,11 @@ BR.LayersConfig = L.Class.extend({
|
|||
}
|
||||
}
|
||||
|
||||
BR.layerIndex['MtbMap'].geometry = BR.confLayers.europeGeofabrik;
|
||||
BR.layerIndex['1069'].geometry = BR.confLayers.europeGeofabrik;
|
||||
BR.layerIndex['MtbMap'].geometry = BR.confLayers.europeGeofabrik;
|
||||
BR.layerIndex['1069'].geometry = BR.confLayers.europeGeofabrik;
|
||||
|
||||
BR.layerIndex['OpenStreetMap.CH'].geometry = BR.confLayers.switzerlandPadded;
|
||||
BR.layerIndex['OpenStreetMap.CH'].geometry =
|
||||
BR.confLayers.switzerlandPadded;
|
||||
},
|
||||
|
||||
isDefaultLayer: function(id, overlay) {
|
||||
|
|
@ -111,7 +115,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
|
||||
// own convention: key placeholder with prefix
|
||||
// e.g. ?api_key={keys_openrouteservice}
|
||||
getKeyName: function (url) {
|
||||
getKeyName: function(url) {
|
||||
var result = null;
|
||||
// L.Util.template only matches [\w_-]
|
||||
var prefix = 'keys_';
|
||||
|
|
@ -132,7 +136,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
return result;
|
||||
},
|
||||
|
||||
createLayer: function (layerData) {
|
||||
createLayer: function(layerData) {
|
||||
var props = layerData.properties;
|
||||
var url = props.url;
|
||||
var layer;
|
||||
|
|
@ -167,7 +171,12 @@ BR.LayersConfig = L.Class.extend({
|
|||
if (attr.html) {
|
||||
result = attr.html;
|
||||
} else if (attr.url && attr.text) {
|
||||
result = '<a href="' + attr.url + '" target="_blank" rel="noopener">' + attr.text + '</a>';
|
||||
result =
|
||||
'<a href="' +
|
||||
attr.url +
|
||||
'" target="_blank" rel="noopener">' +
|
||||
attr.text +
|
||||
'</a>';
|
||||
} else if (attr.text) {
|
||||
result = attr.text;
|
||||
}
|
||||
|
|
@ -179,13 +188,20 @@ BR.LayersConfig = L.Class.extend({
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
var options = {
|
||||
maxZoom: this._map.getMaxZoom(),
|
||||
bounds: layerData.geometry && !props.worldTiles ? L.geoJson(layerData.geometry).getBounds() : null
|
||||
bounds:
|
||||
layerData.geometry && !props.worldTiles
|
||||
? L.geoJson(layerData.geometry).getBounds()
|
||||
: null
|
||||
};
|
||||
if (props.mapUrl) {
|
||||
options.mapLink = '<a target="_blank" href="' + props.mapUrl + '">' + (props.nameShort || props.name) + '</a>';
|
||||
options.mapLink =
|
||||
'<a target="_blank" href="' +
|
||||
props.mapUrl +
|
||||
'">' +
|
||||
(props.nameShort || props.name) +
|
||||
'</a>';
|
||||
}
|
||||
if (props.attribution) {
|
||||
options.attribution = props.attribution;
|
||||
|
|
@ -200,15 +216,17 @@ BR.LayersConfig = L.Class.extend({
|
|||
layer = L.tileLayer.provider(props.id);
|
||||
|
||||
var layerOptions = L.Util.extend(options, {
|
||||
maxNativeZoom: layer.options.maxZoom,
|
||||
maxNativeZoom: layer.options.maxZoom
|
||||
});
|
||||
L.setOptions(layer, layerOptions);
|
||||
|
||||
} else if (props.dataSource === 'LayersCollection') {
|
||||
layer = L.tileLayer(url, L.Util.extend(options, {
|
||||
minZoom: props.minZoom || 0,
|
||||
maxNativeZoom: props.maxZoom
|
||||
}));
|
||||
layer = L.tileLayer(
|
||||
url,
|
||||
L.Util.extend(options, {
|
||||
minZoom: props.minZoom || 0,
|
||||
maxNativeZoom: props.maxZoom
|
||||
})
|
||||
);
|
||||
if (props.subdomains) {
|
||||
layer.subdomains = props.subdomains;
|
||||
}
|
||||
|
|
@ -225,10 +243,13 @@ BR.LayersConfig = L.Class.extend({
|
|||
});
|
||||
|
||||
if (props.type && props.type === 'wms') {
|
||||
layer = L.tileLayer.wms(url, L.Util.extend(josmOptions, {
|
||||
layers: props.layers,
|
||||
format: props.format
|
||||
}));
|
||||
layer = L.tileLayer.wms(
|
||||
url,
|
||||
L.Util.extend(josmOptions, {
|
||||
layers: props.layers,
|
||||
format: props.format
|
||||
})
|
||||
);
|
||||
} else {
|
||||
layer = L.tileLayer(url, josmOptions);
|
||||
}
|
||||
|
|
@ -237,9 +258,9 @@ BR.LayersConfig = L.Class.extend({
|
|||
// Layer attribution here only as short link to original site,
|
||||
// to keep current position use placeholders: {zoom}/{lat}/{lon}
|
||||
// Copyright attribution in index.html #credits
|
||||
var getAttribution = function () {
|
||||
var getAttribution = function() {
|
||||
return this.options.mapLink;
|
||||
}
|
||||
};
|
||||
layer.getAttribution = getAttribution;
|
||||
|
||||
layer.id = props.id;
|
||||
|
|
@ -248,6 +269,6 @@ BR.LayersConfig = L.Class.extend({
|
|||
}
|
||||
});
|
||||
|
||||
BR.layersConfig = function (map) {
|
||||
return new BR.LayersConfig(map);
|
||||
BR.layersConfig = function(map) {
|
||||
return new BR.LayersConfig(map);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue