@operato/scene-openlayers 1.2.54
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/README.md +13 -0
- package/assets/favicon.ico +0 -0
- package/assets/images/spinner.png +0 -0
- package/db.sqlite +0 -0
- package/dist/editors/index.d.ts +0 -0
- package/dist/editors/index.js +2 -0
- package/dist/editors/index.js.map +1 -0
- package/dist/groups/geography.d.ts +6 -0
- package/dist/groups/geography.js +48 -0
- package/dist/groups/geography.js.map +1 -0
- package/dist/groups/index.d.ts +7 -0
- package/dist/groups/index.js +3 -0
- package/dist/groups/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/ol-marker.d.ts +79 -0
- package/dist/ol-marker.js +247 -0
- package/dist/ol-marker.js.map +1 -0
- package/dist/openlayers.d.ts +37 -0
- package/dist/openlayers.js +211 -0
- package/dist/openlayers.js.map +1 -0
- package/dist/templates/index.d.ts +14 -0
- package/dist/templates/index.js +4 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/ol-marker copy.d.ts +14 -0
- package/dist/templates/ol-marker copy.js +16 -0
- package/dist/templates/ol-marker copy.js.map +1 -0
- package/dist/templates/ol-marker.d.ts +14 -0
- package/dist/templates/ol-marker.js +16 -0
- package/dist/templates/ol-marker.js.map +1 -0
- package/dist/templates/ol-path.d.ts +14 -0
- package/dist/templates/ol-path.js +16 -0
- package/dist/templates/ol-path.js.map +1 -0
- package/dist/templates/openlayers.d.ts +14 -0
- package/dist/templates/openlayers.js +16 -0
- package/dist/templates/openlayers.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/icons/ol-marker-template.png +0 -0
- package/icons/ol-path-template.png +0 -0
- package/icons/openlayers-template.png +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +15 -0
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +15 -0
- package/logs/application-2023-09-02-17.log +15 -0
- package/logs/connections-2023-09-02-17.log +76 -0
- package/package.json +63 -0
- package/schema.gql +3702 -0
- package/src/editors/index.ts +0 -0
- package/src/groups/geography.ts +48 -0
- package/src/groups/index.ts +3 -0
- package/src/index.ts +2 -0
- package/src/ol-marker.ts +318 -0
- package/src/ol-path.ts_x +368 -0
- package/src/openlayers.ts +256 -0
- package/src/templates/index.ts +4 -0
- package/src/templates/ol-marker.ts +16 -0
- package/src/templates/ol-path.ts +16 -0
- package/src/templates/openlayers.ts +16 -0
- package/things-scene.config.js +7 -0
- package/translations/en.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
- package/tsconfig.json +23 -0
- package/tsconfig.tsbuildinfo +1 -0
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
const icon = `
|
2
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
3
|
+
viewBox="0 0 35 35" style="enable-background:new 0 0 35 35;" xml:space="preserve">
|
4
|
+
<style type="text/css">
|
5
|
+
.st0{fill:{{strokeColor}};}
|
6
|
+
</style>
|
7
|
+
<g>
|
8
|
+
<g>
|
9
|
+
<path class="st0" d="M33.2,15.2v4.6h-4.6v-4.6H33.2 M34,14.4h-6.1v6.1H34V14.4L34,14.4z"/>
|
10
|
+
</g>
|
11
|
+
<g>
|
12
|
+
<g>
|
13
|
+
<path class="st0" d="M17.5,15.3l2.2,2.2l-2.2,2.2l-2.2-2.2L17.5,15.3 M17.5,14.2l-3.3,3.3l3.3,3.3l3.3-3.3L17.5,14.2L17.5,14.2z"
|
14
|
+
/>
|
15
|
+
</g>
|
16
|
+
<g>
|
17
|
+
<path class="st0" d="M19.8,7.2v4.6h-4.6V7.2H19.8 M20.6,6.5h-6.1v6.1h6.1V6.5L20.6,6.5z"/>
|
18
|
+
</g>
|
19
|
+
<g>
|
20
|
+
<path class="st0" d="M19.8,23.1v4.6h-4.6v-4.6H19.8 M20.6,22.4h-6.1v6.1h6.1V22.4L20.6,22.4z"/>
|
21
|
+
</g>
|
22
|
+
</g>
|
23
|
+
<g>
|
24
|
+
<g>
|
25
|
+
<polygon class="st0" points="13.3,17.4 10.6,19.6 10.6,15.2 13.3,17.4 "/>
|
26
|
+
</g>
|
27
|
+
<rect x="8.2" y="16.9" class="st0" width="3.4" height="0.9"/>
|
28
|
+
</g>
|
29
|
+
<g>
|
30
|
+
<g>
|
31
|
+
<polygon class="st0" points="26.8,17.4 24,19.6 24,15.2 26.8,17.4 "/>
|
32
|
+
</g>
|
33
|
+
<rect x="21.7" y="16.9" class="st0" width="3.4" height="0.9"/>
|
34
|
+
</g>
|
35
|
+
<g>
|
36
|
+
<path class="st0" d="M4.1,15.2c1.3,0,2.3,1,2.3,2.3s-1,2.3-2.3,2.3s-2.3-1-2.3-2.3S2.8,15.2,4.1,15.2 M4.1,14.4
|
37
|
+
c-1.7,0-3.1,1.4-3.1,3.1c0,1.7,1.4,3.1,3.1,3.1s3.1-1.4,3.1-3.1C7.1,15.8,5.8,14.4,4.1,14.4L4.1,14.4z"/>
|
38
|
+
</g>
|
39
|
+
</g>
|
40
|
+
</svg>
|
41
|
+
`
|
42
|
+
|
43
|
+
export const geography = {
|
44
|
+
name: 'geography',
|
45
|
+
description: 'a group of Geographic Components',
|
46
|
+
icon,
|
47
|
+
templates: []
|
48
|
+
}
|
package/src/index.ts
ADDED
package/src/ol-marker.ts
ADDED
@@ -0,0 +1,318 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { Component, InfoWindow as SceneInfoWindow, Properties, RectPath, Shape } from '@hatiolab/things-scene'
|
6
|
+
import Openlayers from './openlayers'
|
7
|
+
|
8
|
+
import 'ol/ol.css'
|
9
|
+
import { Map, MapBrowserEvent, Overlay, View } from 'ol'
|
10
|
+
import { fromLonLat } from 'ol/proj'
|
11
|
+
import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer'
|
12
|
+
import { OSM, Vector as VectorSource } from 'ol/source'
|
13
|
+
import { Icon, Style } from 'ol/style'
|
14
|
+
import { Feature } from 'ol'
|
15
|
+
import Point from 'ol/geom/Point'
|
16
|
+
|
17
|
+
const NATURE = {
|
18
|
+
mutable: false,
|
19
|
+
resizable: true,
|
20
|
+
rotatable: true,
|
21
|
+
properties: [
|
22
|
+
{
|
23
|
+
type: 'id-input',
|
24
|
+
label: 'target-map',
|
25
|
+
name: 'targetMap',
|
26
|
+
property: {
|
27
|
+
component: 'openlayers'
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
type: 'number',
|
32
|
+
label: 'latitude',
|
33
|
+
name: 'lat',
|
34
|
+
property: {
|
35
|
+
step: 0.000001,
|
36
|
+
max: 90,
|
37
|
+
min: -90
|
38
|
+
}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
type: 'number',
|
42
|
+
label: 'longitude',
|
43
|
+
name: 'lng',
|
44
|
+
property: {
|
45
|
+
step: 0.000001,
|
46
|
+
max: 180,
|
47
|
+
min: -180
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
type: 'select',
|
52
|
+
label: 'style',
|
53
|
+
name: 'style',
|
54
|
+
property: {
|
55
|
+
options: ['circle', 'marker']
|
56
|
+
}
|
57
|
+
}
|
58
|
+
],
|
59
|
+
'value-property': 'latlng'
|
60
|
+
// help: 'scene/component/gmap-marker'
|
61
|
+
}
|
62
|
+
|
63
|
+
const MARKER_PATH = 'M10 0 C14.42 0 18 3.58 18 8 C18 12.42 14.42 16 10 16 C5.58 16 2 12.42 2 8 C2 3.58 5.58 0 10 0 Z'
|
64
|
+
|
65
|
+
export default class OpenLayersMarker extends RectPath(Shape) {
|
66
|
+
_infoWindow: any
|
67
|
+
_marker: any
|
68
|
+
_map: Map | null = null
|
69
|
+
|
70
|
+
static markerStyle: Style = new Style({
|
71
|
+
image: new Icon({
|
72
|
+
anchor: [0.5, 1], // 이미지 중심 아래쪽을 지도 위치에 맞춤
|
73
|
+
src:
|
74
|
+
'data:image/svg+xml;charset=utf-8,' +
|
75
|
+
encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">' + MARKER_PATH + '</svg>')
|
76
|
+
})
|
77
|
+
})
|
78
|
+
|
79
|
+
dispose() {
|
80
|
+
this.detachFromOldOpenlayers(this.targetMap)
|
81
|
+
|
82
|
+
this.marker = null
|
83
|
+
delete this._infoWindow
|
84
|
+
|
85
|
+
super.dispose()
|
86
|
+
}
|
87
|
+
|
88
|
+
ready() {
|
89
|
+
super.ready()
|
90
|
+
|
91
|
+
if (this.isTemplate()) {
|
92
|
+
return
|
93
|
+
}
|
94
|
+
|
95
|
+
this.attachToNewOpenlayers(this.targetMap)
|
96
|
+
}
|
97
|
+
|
98
|
+
get map() {
|
99
|
+
return this._map
|
100
|
+
}
|
101
|
+
|
102
|
+
get infoWindow() {
|
103
|
+
if (!this._infoWindow) {
|
104
|
+
// this._infoWindow = new google.maps.InfoWindow()
|
105
|
+
|
106
|
+
// 인포윈도우 생성
|
107
|
+
this._infoWindow = new Overlay({
|
108
|
+
element: document.getElementById('info')!,
|
109
|
+
positioning: 'bottom-center',
|
110
|
+
stopEvent: false
|
111
|
+
})
|
112
|
+
|
113
|
+
// // 마커 클릭 이벤트 리스너 추가
|
114
|
+
// marker.on('click', event => {
|
115
|
+
// const coordinate = event.coordinate
|
116
|
+
// const content = '<div>Hello, This is InfoWindow!</div>'
|
117
|
+
// infoWindow.setPosition(coordinate)
|
118
|
+
// infoWindow.getElement().innerHTML = content
|
119
|
+
// map.addOverlay(infoWindow)
|
120
|
+
// })
|
121
|
+
|
122
|
+
// // 지도에 레이어 추가
|
123
|
+
// map.addLayer(markerLayer)
|
124
|
+
|
125
|
+
// // 인포윈도우를 닫는 함수
|
126
|
+
// const closeInfoWindow = () => {
|
127
|
+
// infoWindow.setPosition(undefined)
|
128
|
+
// infoWindow.getElement().innerHTML = ''
|
129
|
+
// }
|
130
|
+
}
|
131
|
+
|
132
|
+
return this._infoWindow
|
133
|
+
}
|
134
|
+
|
135
|
+
findInfoWindow(type: string) {
|
136
|
+
var eventSetting = (this.state.event && this.state.event[type]) || {}
|
137
|
+
|
138
|
+
var infoWindow =
|
139
|
+
/* event spec v1.0 */ eventSetting.infoWindow ||
|
140
|
+
/* event spec v1.1 */ (eventSetting.action == 'infoWindow' && eventSetting.target)
|
141
|
+
|
142
|
+
if (infoWindow) {
|
143
|
+
return this.root.findById(infoWindow)
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
setInfoContent(sceneInfoWindow: SceneInfoWindow) {
|
148
|
+
var tpl = Component.template(sceneInfoWindow.model.frontSideTemplate)
|
149
|
+
var content = `<style>${sceneInfoWindow.model.style}</style>` + tpl(this)
|
150
|
+
|
151
|
+
this.infoWindow.setContent(content)
|
152
|
+
}
|
153
|
+
|
154
|
+
openInfoWindow(iw: SceneInfoWindow) {
|
155
|
+
this.setInfoContent(iw)
|
156
|
+
|
157
|
+
if (!this.map) return
|
158
|
+
|
159
|
+
this.infoWindow.open(this.map, this.marker)
|
160
|
+
}
|
161
|
+
|
162
|
+
onmarkerclick(e: MapBrowserEvent<UIEvent>) {
|
163
|
+
var iw = this.findInfoWindow('tap')
|
164
|
+
iw && this.openInfoWindow(iw)
|
165
|
+
|
166
|
+
// this.trigger('click', e.ya) ??????
|
167
|
+
}
|
168
|
+
|
169
|
+
onmarkermouseover(e: MapBrowserEvent<UIEvent>) {
|
170
|
+
var iw = this.findInfoWindow('hover')
|
171
|
+
iw && this.openInfoWindow(iw)
|
172
|
+
}
|
173
|
+
|
174
|
+
onmarkermouseout(e: MapBrowserEvent<UIEvent>) {
|
175
|
+
var iw = this.findInfoWindow('hover')
|
176
|
+
iw && this.infoWindow.close()
|
177
|
+
}
|
178
|
+
|
179
|
+
set marker(marker) {
|
180
|
+
this._marker = marker
|
181
|
+
}
|
182
|
+
|
183
|
+
get marker() {
|
184
|
+
return this._marker
|
185
|
+
}
|
186
|
+
|
187
|
+
render(context: CanvasRenderingContext2D) {
|
188
|
+
var { top, left, width, height } = this.state
|
189
|
+
|
190
|
+
context.translate(left, top)
|
191
|
+
|
192
|
+
// 마커 모양 그리기
|
193
|
+
context.beginPath()
|
194
|
+
|
195
|
+
context.moveTo(width / 2, height * 0.9)
|
196
|
+
context.bezierCurveTo(width / 2.3, height * 0.6, 0, height / 2, 0, height / 4)
|
197
|
+
|
198
|
+
context.ellipse(width / 2, height / 4, width / 2, height / 4, 0, Math.PI * 1, Math.PI * 0)
|
199
|
+
|
200
|
+
context.bezierCurveTo(width, height / 2, width / 1.7, height * 0.6, width / 2, height * 0.9)
|
201
|
+
context.closePath()
|
202
|
+
|
203
|
+
context.translate(-left, -top)
|
204
|
+
}
|
205
|
+
|
206
|
+
detachFromOldOpenlayers(map: Openlayers) {
|
207
|
+
if (this._marker && map) {
|
208
|
+
map.vectorSource?.removeFeature(this._marker)
|
209
|
+
this._marker = null
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
attachToNewOpenlayers(map: Openlayers) {
|
214
|
+
if (!this._marker && map) {
|
215
|
+
let {
|
216
|
+
lat,
|
217
|
+
lng,
|
218
|
+
style = 'circle',
|
219
|
+
fillStyle: fillColor,
|
220
|
+
alpha: fillOpacity = 1,
|
221
|
+
strokeStyle: strokeColor,
|
222
|
+
lineWidth: strokeWeight
|
223
|
+
} = this.state
|
224
|
+
|
225
|
+
const marker = new Feature({
|
226
|
+
type: style,
|
227
|
+
geometry: new Point(fromLonLat([lng || 0, lat || 0]))
|
228
|
+
})
|
229
|
+
|
230
|
+
map.vectorSource?.addFeatures([marker])
|
231
|
+
|
232
|
+
if (marker) {
|
233
|
+
//@ts-ignore
|
234
|
+
marker.on('click', this.onmarkerclick.bind(this))
|
235
|
+
//@ts-ignore
|
236
|
+
marker.on('mouseover', this.onmarkermouseover.bind(this))
|
237
|
+
//@ts-ignore
|
238
|
+
marker.on('mouseout', this.onmarkermouseout.bind(this))
|
239
|
+
}
|
240
|
+
|
241
|
+
this._marker = marker
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
onchangeTargetMap(after: string, before: string) {
|
246
|
+
const oldMap = this.root.findById(before) as Openlayers
|
247
|
+
const newMap = this.root.findById(after) as Openlayers
|
248
|
+
|
249
|
+
this.detachFromOldOpenlayers(oldMap)
|
250
|
+
this.attachToNewOpenlayers(newMap)
|
251
|
+
}
|
252
|
+
|
253
|
+
get targetMap() {
|
254
|
+
const { targetMap } = this.state
|
255
|
+
return this.root.findById(targetMap) as Openlayers
|
256
|
+
}
|
257
|
+
|
258
|
+
onchange(after: Properties, before: Properties) {
|
259
|
+
if ('targetMap' in after) {
|
260
|
+
this.onchangeTargetMap(after.targetMap, before.targetMap)
|
261
|
+
}
|
262
|
+
|
263
|
+
if ('lat' in after || 'lng' in after) {
|
264
|
+
var { lat, lng } = this.state
|
265
|
+
this.latlng = {
|
266
|
+
lat,
|
267
|
+
lng
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
if (('fillStyle' in after || 'strokeStyle' in after || 'lineWidth' in after) && this.marker) {
|
272
|
+
let {
|
273
|
+
fillStyle: fillColor,
|
274
|
+
alpha: fillOpacity = 1,
|
275
|
+
strokeStyle: strokeColor,
|
276
|
+
lineWidth: strokeWeight
|
277
|
+
} = this.state
|
278
|
+
|
279
|
+
this.marker.setIcon({
|
280
|
+
path: MARKER_PATH,
|
281
|
+
fillColor,
|
282
|
+
fillOpacity,
|
283
|
+
strokeColor,
|
284
|
+
strokeWeight
|
285
|
+
})
|
286
|
+
}
|
287
|
+
|
288
|
+
if ('style' in after) {
|
289
|
+
const { targetMap } = this.state
|
290
|
+
this.onchangeTargetMap(targetMap, targetMap)
|
291
|
+
}
|
292
|
+
|
293
|
+
super.onchange && super.onchange(after, before)
|
294
|
+
}
|
295
|
+
|
296
|
+
get latlng() {
|
297
|
+
return {
|
298
|
+
lat: this.getState('lat'),
|
299
|
+
lng: this.getState('lng')
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
set latlng(latlng) {
|
304
|
+
var { lat, lng } = latlng
|
305
|
+
this.marker?.getGeometry().setCoordinates(fromLonLat([lng, lat]))
|
306
|
+
|
307
|
+
this.setState({
|
308
|
+
lat,
|
309
|
+
lng
|
310
|
+
})
|
311
|
+
}
|
312
|
+
|
313
|
+
get nature() {
|
314
|
+
return NATURE
|
315
|
+
}
|
316
|
+
}
|
317
|
+
|
318
|
+
Component.register('ol-marker', OpenLayersMarker)
|