Skip to content

Commit 9cc7d18

Browse files
committed
Skip except OSM/XYZ tile source case
Fixed visible default value Signed-off-by: Ko Nagase <[email protected]>
1 parent aacc7ed commit 9cc7d18

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/components/gtt-client.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'ol-ext/filter/Base'
55
import { Geometry, Point } from 'ol/geom'
66
import { GeoJSON, WKT } from 'ol/format'
77
import { Layer, Tile, Vector as VectorLayer } from 'ol/layer'
8-
import { Tile as TileSource, OSM, XYZ } from 'ol/source'
8+
import { OSM, XYZ } from 'ol/source'
99
import { Style, Fill, Stroke, Circle } from 'ol/style'
1010
import { OrderFunction } from 'ol/render'
1111
import {
@@ -139,22 +139,25 @@ export class GttClient {
139139
const layers = JSON.parse(this.contents.layers) as [LayerObject]
140140
layers.forEach((layer) => {
141141
const s = layer.type.split('.')
142-
const l = new Tile({
143-
visible: true,
144-
source: new (getTileSource(s[1], s[2]))(layer.options)
145-
})
146-
l.set('lid', layer.id)
147-
l.set('title', layer.name)
148-
l.set('baseLayer', true)
149-
l.on('change:visible', e => {
150-
const target = e.target as Tile
151-
if (target.getVisible()) {
152-
const lid = target.get('lid')
153-
document.cookie = `_redmine_gtt_basemap=${lid};path=/`
154-
}
155-
})
156-
this.layerArray.push(l)
157-
this.map.addLayer(l)
142+
const tileSource = getTileSource(s[1], s[2])
143+
if (tileSource) {
144+
const l = new Tile({
145+
visible: false,
146+
source: new (tileSource)(layer.options)
147+
})
148+
l.set('lid', layer.id)
149+
l.set('title', layer.name)
150+
l.set('baseLayer', true)
151+
l.on('change:visible', e => {
152+
const target = e.target as Tile
153+
if (target.getVisible()) {
154+
const lid = target.get('lid')
155+
document.cookie = `_redmine_gtt_basemap=${lid};path=/`
156+
}
157+
})
158+
this.layerArray.push(l)
159+
this.map.addLayer(l)
160+
}
158161
}, this)
159162
}
160163

@@ -1142,7 +1145,7 @@ const getTileSource = (source: string, class_name: string): any => {
11421145
return XYZ
11431146
}
11441147
}
1145-
return TileSource
1148+
return undefined
11461149
}
11471150

11481151
const getCookie = (cname:string):string => {

0 commit comments

Comments
 (0)