@operato/scene-google-map 8.0.0-beta.0 → 8.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -4
- package/CHANGELOG.md +0 -130
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -15
- package/logs/application-2024-01-01-16.log +0 -9
- package/logs/connections-2024-01-01-16.log +0 -41
- package/schema.graphql +0 -3966
- package/src/gmap-marker.ts +0 -306
- package/src/gmap-path.ts +0 -365
- package/src/google-map.ts +0 -222
- package/src/index.ts +0 -8
- package/src/templates/gmap-marker.ts +0 -20
- package/src/templates/gmap-path.ts +0 -25
- package/src/templates/google-map.ts +0 -20
- package/src/templates/index.ts +0 -5
- package/test/basic-test.html +0 -67
- package/test/index.html +0 -24
- package/test/unit/test-google-map.js +0 -33
- package/test/unit/util.js +0 -22
- package/tsconfig.json +0 -23
- package/tsconfig.tsbuildinfo +0 -1
package/src/google-map.ts
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
const NATURE: ComponentNature = {
|
6
|
-
mutable: false,
|
7
|
-
resizable: true,
|
8
|
-
rotatable: true,
|
9
|
-
properties: [
|
10
|
-
{
|
11
|
-
type: 'number',
|
12
|
-
label: 'latitude',
|
13
|
-
name: 'lat',
|
14
|
-
property: {
|
15
|
-
step: 0.000001,
|
16
|
-
max: 90,
|
17
|
-
min: -90
|
18
|
-
}
|
19
|
-
},
|
20
|
-
{
|
21
|
-
type: 'number',
|
22
|
-
label: 'longitude',
|
23
|
-
name: 'lng',
|
24
|
-
property: {
|
25
|
-
step: 0.000001,
|
26
|
-
min: -180,
|
27
|
-
max: 180
|
28
|
-
}
|
29
|
-
},
|
30
|
-
{
|
31
|
-
type: 'number',
|
32
|
-
label: 'zoom',
|
33
|
-
name: 'zoom'
|
34
|
-
},
|
35
|
-
{
|
36
|
-
type: 'string',
|
37
|
-
label: 'api-key',
|
38
|
-
name: 'apiKey'
|
39
|
-
}
|
40
|
-
],
|
41
|
-
'value-property': 'latlng'
|
42
|
-
// help: 'scene/component/gmap-map'
|
43
|
-
}
|
44
|
-
|
45
|
-
import {
|
46
|
-
Component,
|
47
|
-
ComponentNature,
|
48
|
-
HTMLOverlayContainer,
|
49
|
-
Properties,
|
50
|
-
ScriptLoader,
|
51
|
-
error
|
52
|
-
} from '@hatiolab/things-scene'
|
53
|
-
|
54
|
-
function getGlobalScale(component: GoogleMap) {
|
55
|
-
var scale = { x: 1, y: 1 }
|
56
|
-
var parent: Component = component
|
57
|
-
|
58
|
-
while (parent) {
|
59
|
-
let { x, y } = parent.get('scale') || { x: 1, y: 1 }
|
60
|
-
scale.x *= x || 1
|
61
|
-
scale.y *= y || 1
|
62
|
-
|
63
|
-
parent = parent.parent
|
64
|
-
}
|
65
|
-
return scale
|
66
|
-
}
|
67
|
-
|
68
|
-
export default class GoogleMap extends HTMLOverlayContainer {
|
69
|
-
static load(component: GoogleMap) {
|
70
|
-
var key = component.get('apiKey')
|
71
|
-
ScriptLoader.load('https://maps.googleapis.com/maps/api/js' + (key ? '?key=' + key : '')).then(
|
72
|
-
() => component.onload(),
|
73
|
-
error
|
74
|
-
)
|
75
|
-
}
|
76
|
-
|
77
|
-
private static loaded: boolean = false
|
78
|
-
|
79
|
-
private _listenTo?: Component
|
80
|
-
private _listener? = function (this: GoogleMap, after: any) {
|
81
|
-
after.scale && this.rescale()
|
82
|
-
}.bind(this)
|
83
|
-
|
84
|
-
private _anchor?: HTMLDivElement
|
85
|
-
private _map?: google.maps.Map
|
86
|
-
|
87
|
-
ready() {
|
88
|
-
super.ready()
|
89
|
-
|
90
|
-
if (this.rootModel) {
|
91
|
-
this._listenTo = this.rootModel
|
92
|
-
this.rootModel.on('change', this._listener!)
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
removed() {
|
97
|
-
if (this._listenTo) {
|
98
|
-
this._listenTo.off('change', this._listener!)
|
99
|
-
|
100
|
-
delete this._listenTo
|
101
|
-
delete this._listener
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
/*
|
106
|
-
* google map은 scale된 상태에서 마우스 포지션을 정확히 매핑하지 못하므로, 마커를 정상적으로 동작시키지 못한다.
|
107
|
-
* 따라서, google map의 경우에는 부모의 스케일의 역으로 transform해서, scale을 1로 맞추어야 한다.
|
108
|
-
*/
|
109
|
-
rescale() {
|
110
|
-
var anchor = this._anchor
|
111
|
-
if (!anchor) {
|
112
|
-
return
|
113
|
-
}
|
114
|
-
var scale = getGlobalScale(this)
|
115
|
-
|
116
|
-
var sx = 1 / scale.x
|
117
|
-
var sy = 1 / scale.y
|
118
|
-
|
119
|
-
var transform = `scale(${sx}, ${sy})`
|
120
|
-
|
121
|
-
;['-webkit-', '-moz-', '-ms-', '-o-', ''].forEach(prefix => {
|
122
|
-
anchor!.style[(prefix + 'transform') as any] = transform
|
123
|
-
anchor!.style[(prefix + 'transform-origin') as any] = '0px 0px'
|
124
|
-
})
|
125
|
-
|
126
|
-
var { width, height } = this.state
|
127
|
-
anchor.style.width = width * scale.x + 'px'
|
128
|
-
anchor.style.height = height * scale.y + 'px'
|
129
|
-
|
130
|
-
if (GoogleMap.loaded) {
|
131
|
-
google.maps.event.trigger(this.map, 'resize')
|
132
|
-
let { lat, lng } = this.state
|
133
|
-
this.map &&
|
134
|
-
this.map.setCenter({
|
135
|
-
lat,
|
136
|
-
lng
|
137
|
-
})
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
createElement() {
|
142
|
-
super.createElement()
|
143
|
-
this._anchor = document.createElement('div')
|
144
|
-
this.element.appendChild(this._anchor)
|
145
|
-
this.rescale()
|
146
|
-
|
147
|
-
GoogleMap.load(this)
|
148
|
-
}
|
149
|
-
|
150
|
-
onload() {
|
151
|
-
GoogleMap.loaded = true
|
152
|
-
|
153
|
-
var { lat, lng, zoom } = this.state
|
154
|
-
|
155
|
-
try {
|
156
|
-
this._map = new google.maps.Map(this._anchor!, {
|
157
|
-
zoom,
|
158
|
-
center: new google.maps.LatLng(lat, lng)
|
159
|
-
})
|
160
|
-
} finally {
|
161
|
-
/*
|
162
|
-
* setState 로 map 객체가 생성되었음을 change 이벤트로 알려줄 수 있다
|
163
|
-
* - set('map', this._map)으로 만들 지 않도록 주의한다.
|
164
|
-
* - setState('map', this._map)으로해야 컴포넌트 모델에 추가되지 않는다.
|
165
|
-
*/
|
166
|
-
this.setState('map', this._map)
|
167
|
-
this.rescale()
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
get tagName() {
|
172
|
-
return 'div'
|
173
|
-
}
|
174
|
-
|
175
|
-
get map() {
|
176
|
-
return this._map
|
177
|
-
}
|
178
|
-
|
179
|
-
dispose() {
|
180
|
-
super.dispose()
|
181
|
-
|
182
|
-
delete this._anchor
|
183
|
-
}
|
184
|
-
|
185
|
-
setElementProperties(div: HTMLDivElement) {
|
186
|
-
this.rescale()
|
187
|
-
}
|
188
|
-
|
189
|
-
onchange(after: Properties, before: Properties) {
|
190
|
-
if (GoogleMap.loaded) {
|
191
|
-
if (after.zoom) {
|
192
|
-
this.map!.setZoom(after.zoom)
|
193
|
-
}
|
194
|
-
|
195
|
-
if ('lat' in after || 'lng' in after) {
|
196
|
-
let { lat, lng } = this.state
|
197
|
-
this.map!.setCenter(new google.maps.LatLng(lat, lng))
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
super.onchange(after, before)
|
202
|
-
|
203
|
-
this.rescale()
|
204
|
-
}
|
205
|
-
|
206
|
-
get latlng() {
|
207
|
-
return {
|
208
|
-
lat: this.get('lat'),
|
209
|
-
lng: this.get('lng')
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
set latlng(latlng) {
|
214
|
-
this.set(latlng)
|
215
|
-
}
|
216
|
-
|
217
|
-
get nature() {
|
218
|
-
return NATURE
|
219
|
-
}
|
220
|
-
}
|
221
|
-
|
222
|
-
Component.register('google-map', GoogleMap)
|
package/src/index.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
const icon = new URL('../../icons/gmap-marker.png', import.meta.url).href
|
2
|
-
|
3
|
-
export default {
|
4
|
-
type: 'gmap-marker',
|
5
|
-
description: 'google map marker',
|
6
|
-
group: 'etc',
|
7
|
-
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
8
|
-
icon,
|
9
|
-
model: {
|
10
|
-
type: 'gmap-marker',
|
11
|
-
left: 150,
|
12
|
-
top: 150,
|
13
|
-
width: 40,
|
14
|
-
height: 60,
|
15
|
-
lat: 22.308117,
|
16
|
-
lng: 114.225443,
|
17
|
-
fillStyle: '#00ff00',
|
18
|
-
hidden: true
|
19
|
-
}
|
20
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
const icon = new URL('../../icons/gmap-path.png', import.meta.url).href
|
2
|
-
|
3
|
-
export default {
|
4
|
-
type: 'gmap-path',
|
5
|
-
description: 'google map path',
|
6
|
-
group: 'etc',
|
7
|
-
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
8
|
-
icon,
|
9
|
-
model: {
|
10
|
-
type: 'gmap-path',
|
11
|
-
left: 150,
|
12
|
-
top: 150,
|
13
|
-
width: 40,
|
14
|
-
height: 60,
|
15
|
-
latlngs: [
|
16
|
-
{
|
17
|
-
lat: 22.308117,
|
18
|
-
lng: 114.225443
|
19
|
-
}
|
20
|
-
],
|
21
|
-
startEndMarkerDifferentDesign: true,
|
22
|
-
fillStyle: '#00ff00',
|
23
|
-
hidden: true
|
24
|
-
}
|
25
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
const icon = new URL('../../icons/google-map.png', import.meta.url).href
|
2
|
-
|
3
|
-
export default {
|
4
|
-
type: 'google-map',
|
5
|
-
description: 'google-map',
|
6
|
-
group: 'etc',
|
7
|
-
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
8
|
-
icon,
|
9
|
-
model: {
|
10
|
-
type: 'google-map',
|
11
|
-
left: 150,
|
12
|
-
top: 150,
|
13
|
-
width: 300,
|
14
|
-
height: 200,
|
15
|
-
lat: 22.308117,
|
16
|
-
lng: 114.225443,
|
17
|
-
zoom: 20,
|
18
|
-
apiKey: 'AIzaSyBgQZb-SFqjQBC_XTxNiz0XapejNwV9PgA'
|
19
|
-
}
|
20
|
-
}
|
package/src/templates/index.ts
DELETED
package/test/basic-test.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright © HatioLab Inc. All rights reserved.
|
4
|
-
-->
|
5
|
-
<!doctype html>
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<meta charset="utf-8">
|
9
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
10
|
-
|
11
|
-
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
12
|
-
<script src="../../web-component-tester/browser.js"></script>
|
13
|
-
|
14
|
-
<!-- Step 1: import the element to test -->
|
15
|
-
<link rel="import" href="../things-scene-google-map.html">
|
16
|
-
</head>
|
17
|
-
<body>
|
18
|
-
|
19
|
-
<!-- You can use the document as a place to set up your fixtures. -->
|
20
|
-
<test-fixture id="things-scene-google-map-fixture">
|
21
|
-
<template>
|
22
|
-
<things-scene-google-map>
|
23
|
-
<h2>things-scene-google-map</h2>
|
24
|
-
</things-scene-google-map>
|
25
|
-
</template>
|
26
|
-
</test-fixture>
|
27
|
-
|
28
|
-
<script>
|
29
|
-
suite('<things-scene-google-map>', function() {
|
30
|
-
|
31
|
-
var myEl;
|
32
|
-
|
33
|
-
setup(function() {
|
34
|
-
myEl = fixture('things-scene-google-map-fixture');
|
35
|
-
});
|
36
|
-
|
37
|
-
test('defines the "author" property', function() {
|
38
|
-
assert.equal(myEl.author.name, 'Dimitri Glazkov');
|
39
|
-
assert.equal(myEl.author.image, 'http://addyosmani.com/blog/wp-content/uploads/2013/04/unicorn.jpg');
|
40
|
-
});
|
41
|
-
|
42
|
-
test('says hello', function() {
|
43
|
-
assert.equal(myEl.sayHello(), 'things-scene-google-map says, Hello World!');
|
44
|
-
|
45
|
-
var greetings = myEl.sayHello('greetings Earthlings');
|
46
|
-
assert.equal(greetings, 'things-scene-google-map says, greetings Earthlings');
|
47
|
-
});
|
48
|
-
|
49
|
-
test('fires lasers', function(done) {
|
50
|
-
myEl.addEventListener('things-scene-google-map-lasers', function(event) {
|
51
|
-
assert.equal(event.detail.sound, 'Pew pew!');
|
52
|
-
done();
|
53
|
-
});
|
54
|
-
myEl.fireLasers();
|
55
|
-
});
|
56
|
-
|
57
|
-
test('distributed children', function() {
|
58
|
-
var els = myEl.getContentChildren();
|
59
|
-
assert.equal(els.length, 1, 'one distributed node');
|
60
|
-
assert.equal(els[0], myEl.querySelector('h2'), 'content distributed correctly');
|
61
|
-
});
|
62
|
-
|
63
|
-
});
|
64
|
-
</script>
|
65
|
-
|
66
|
-
</body>
|
67
|
-
</html>
|
package/test/index.html
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright © HatioLab Inc. All rights reserved.
|
4
|
-
-->
|
5
|
-
<!DOCTYPE html>
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<meta charset="utf-8">
|
9
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
10
|
-
|
11
|
-
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
12
|
-
<script src="../../web-component-tester/browser.js"></script>
|
13
|
-
</head>
|
14
|
-
<body>
|
15
|
-
<script>
|
16
|
-
// Load and run all tests (.html, .js):
|
17
|
-
WCT.loadSuites([
|
18
|
-
'basic-test.html',
|
19
|
-
'basic-test.html?dom=shadow'
|
20
|
-
]);
|
21
|
-
</script>
|
22
|
-
|
23
|
-
</body>
|
24
|
-
</html>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import './util'
|
6
|
-
|
7
|
-
import { expect } from 'chai'
|
8
|
-
|
9
|
-
import '../../bower_components/things-scene-core/things-scene-min'
|
10
|
-
import { GoogleMap } from '../../src/index'
|
11
|
-
|
12
|
-
describe('GoogleMap', function () {
|
13
|
-
|
14
|
-
var board;
|
15
|
-
|
16
|
-
beforeEach(function () {
|
17
|
-
board = scene.create({
|
18
|
-
model: {
|
19
|
-
components: [{
|
20
|
-
id: 'google-map',
|
21
|
-
type: 'google-map'
|
22
|
-
}]
|
23
|
-
}
|
24
|
-
})
|
25
|
-
});
|
26
|
-
|
27
|
-
it('component should be found by its id.', function () {
|
28
|
-
|
29
|
-
var component = board.findById('google-map')
|
30
|
-
|
31
|
-
expect(!!component).not.to.equal(false);
|
32
|
-
});
|
33
|
-
});
|
package/test/unit/util.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
var noop = () => {}
|
6
|
-
|
7
|
-
global.Canvas = require('canvas');
|
8
|
-
|
9
|
-
Canvas.prototype.setAttribute = noop;
|
10
|
-
Canvas.prototype.style = {};
|
11
|
-
|
12
|
-
global.Image = Canvas.Image;
|
13
|
-
global.screen = {
|
14
|
-
width: 1280,
|
15
|
-
height: 800
|
16
|
-
};
|
17
|
-
|
18
|
-
global.window = global;
|
19
|
-
|
20
|
-
global.addEventListener = noop;
|
21
|
-
global.location = {};
|
22
|
-
global.getComputedStyle = noop;
|
package/tsconfig.json
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "es2018",
|
4
|
-
"module": "esnext",
|
5
|
-
"moduleResolution": "node",
|
6
|
-
"noEmitOnError": true,
|
7
|
-
"lib": ["es2019", "dom"],
|
8
|
-
"strict": true,
|
9
|
-
"esModuleInterop": false,
|
10
|
-
"allowJs": true,
|
11
|
-
"allowSyntheticDefaultImports": true,
|
12
|
-
"experimentalDecorators": true,
|
13
|
-
"importHelpers": true,
|
14
|
-
"outDir": "dist",
|
15
|
-
"sourceMap": true,
|
16
|
-
"inlineSources": true,
|
17
|
-
"rootDir": "src",
|
18
|
-
"declaration": true,
|
19
|
-
"incremental": true,
|
20
|
-
"skipLibCheck": true
|
21
|
-
},
|
22
|
-
"include": ["**/*.ts", "*.d.ts"]
|
23
|
-
}
|