@operato/scene-google-map 1.3.6
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 +15 -0
- package/assets/favicon.ico +0 -0
- package/assets/images/spinner.png +0 -0
- package/dist/gmap-marker.d.ts +67 -0
- package/dist/gmap-marker.js +230 -0
- package/dist/gmap-marker.js.map +1 -0
- package/dist/gmap-path.d.ts +54 -0
- package/dist/gmap-path.js +296 -0
- package/dist/gmap-path.js.map +1 -0
- package/dist/google-map.d.ts +49 -0
- package/dist/google-map.js +178 -0
- package/dist/google-map.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/gmap-marker.d.ts +18 -0
- package/dist/templates/gmap-marker.js +20 -0
- package/dist/templates/gmap-marker.js.map +1 -0
- package/dist/templates/gmap-path.d.ts +21 -0
- package/dist/templates/gmap-path.js +25 -0
- package/dist/templates/gmap-path.js.map +1 -0
- package/dist/templates/google-map.d.ts +18 -0
- package/dist/templates/google-map.js +20 -0
- package/dist/templates/google-map.js.map +1 -0
- package/dist/templates/index.d.ts +53 -0
- package/dist/templates/index.js +5 -0
- package/dist/templates/index.js.map +1 -0
- package/helps/scene/component/gmap-map.ko.md +3 -0
- package/helps/scene/component/gmap-map.md +3 -0
- package/helps/scene/component/gmap-map.zh.md +3 -0
- package/helps/scene/component/gmap-marker.ko.md +3 -0
- package/helps/scene/component/gmap-marker.md +3 -0
- package/helps/scene/component/gmap-marker.zh.md +3 -0
- package/helps/scene/component/gmap-path.ko.md +3 -0
- package/helps/scene/component/gmap-path.md +3 -0
- package/helps/scene/component/gmap-path.zh.md +3 -0
- package/icons/gmap-marker.png +0 -0
- package/icons/gmap-path.png +0 -0
- package/icons/google-map.png +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +15 -0
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +15 -0
- package/logs/application-2024-01-01-16.log +9 -0
- package/logs/connections-2024-01-01-16.log +41 -0
- package/package.json +62 -0
- package/schema.graphql +3966 -0
- package/src/gmap-marker.ts +306 -0
- package/src/gmap-path.ts +365 -0
- package/src/google-map.ts +215 -0
- package/src/index.ts +8 -0
- package/src/templates/gmap-marker.ts +20 -0
- package/src/templates/gmap-path.ts +25 -0
- package/src/templates/google-map.ts +20 -0
- package/src/templates/index.ts +5 -0
- package/test/basic-test.html +67 -0
- package/test/index.html +24 -0
- package/test/unit/test-google-map.js +33 -0
- package/test/unit/util.js +22 -0
- package/things-scene.config.js +5 -0
- package/translations/en.json +6 -0
- package/translations/ja.json +6 -0
- package/translations/ko.json +6 -0
- package/translations/zh.json +6 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
|
+
|
6
|
+
## [1.3.6](https://github.com/things-scene/operato-scene/compare/v1.3.5...v1.3.6) (2024-01-01)
|
7
|
+
|
8
|
+
|
9
|
+
### :bug: Bug Fix
|
10
|
+
|
11
|
+
* google-map module moved from things-factory ([86c129f](https://github.com/things-scene/operato-scene/commit/86c129f14d91ec951f0e81a746005a3dfa857156))
|
package/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
## things-scene-google-map
|
2
|
+
|
3
|
+
## build
|
4
|
+
|
5
|
+
`$ yarn build`
|
6
|
+
|
7
|
+
| type | filename | for | tested |
|
8
|
+
| ---- | ----------------------------- | -------------- | ------ |
|
9
|
+
| UMD | things-scene-google-map.js | modern browser | O |
|
10
|
+
| UMD | things-scene-google-map-ie.js | ie 11 | O |
|
11
|
+
| ESM | things-scene-google-map.mjs | modern browser | O |
|
12
|
+
|
13
|
+
## publish
|
14
|
+
|
15
|
+
`$ yarn publish`
|
Binary file
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/// <reference types="googlemaps" />
|
2
|
+
/// <reference types="googlemaps" />
|
3
|
+
/// <reference types="googlemaps" />
|
4
|
+
import { Component, InfoWindow, Properties, Shape } from '@hatiolab/things-scene';
|
5
|
+
import GoogleMap from './google-map';
|
6
|
+
declare const GMapMarker_base: typeof Shape;
|
7
|
+
export default class GMapMarker extends GMapMarker_base {
|
8
|
+
private _infoWindow?;
|
9
|
+
private _marker?;
|
10
|
+
private _map?;
|
11
|
+
private _targetMap?;
|
12
|
+
dispose(): void;
|
13
|
+
ready(): void;
|
14
|
+
get map(): google.maps.Map<Element> | null | undefined;
|
15
|
+
get infoWindow(): google.maps.InfoWindow;
|
16
|
+
findInfoWindow(type: string): Component | undefined;
|
17
|
+
setInfoContent(sceneInfoWindow: InfoWindow): void;
|
18
|
+
openInfoWindow(iw: InfoWindow): void;
|
19
|
+
onmarkerclick(e: Event): void;
|
20
|
+
onmarkermouseover(e: Event): void;
|
21
|
+
onmarkermouseout(e: Event): void;
|
22
|
+
set marker(marker: google.maps.Marker | null | undefined);
|
23
|
+
get marker(): google.maps.Marker | null | undefined;
|
24
|
+
get hidden(): boolean;
|
25
|
+
set hidden(hidden: boolean);
|
26
|
+
render(context: CanvasRenderingContext2D): void;
|
27
|
+
get controls(): never[];
|
28
|
+
onchangeTargetMap(): void;
|
29
|
+
get targetMap(): GoogleMap | null | undefined;
|
30
|
+
onchange(after: Properties, before: Properties): void;
|
31
|
+
get latlng(): {
|
32
|
+
lat: any;
|
33
|
+
lng: any;
|
34
|
+
};
|
35
|
+
set latlng(latlng: {
|
36
|
+
lat: any;
|
37
|
+
lng: any;
|
38
|
+
});
|
39
|
+
get nature(): {
|
40
|
+
mutable: boolean;
|
41
|
+
resizable: boolean;
|
42
|
+
rotatable: boolean;
|
43
|
+
properties: ({
|
44
|
+
type: string;
|
45
|
+
label: string;
|
46
|
+
name: string;
|
47
|
+
property: {
|
48
|
+
component: string;
|
49
|
+
step?: undefined;
|
50
|
+
max?: undefined;
|
51
|
+
min?: undefined;
|
52
|
+
};
|
53
|
+
} | {
|
54
|
+
type: string;
|
55
|
+
label: string;
|
56
|
+
name: string;
|
57
|
+
property: {
|
58
|
+
step: number;
|
59
|
+
max: number;
|
60
|
+
min: number;
|
61
|
+
component?: undefined;
|
62
|
+
};
|
63
|
+
})[];
|
64
|
+
'value-property': string;
|
65
|
+
};
|
66
|
+
}
|
67
|
+
export {};
|
@@ -0,0 +1,230 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
5
|
+
const NATURE = {
|
6
|
+
mutable: false,
|
7
|
+
resizable: true,
|
8
|
+
rotatable: true,
|
9
|
+
properties: [
|
10
|
+
{
|
11
|
+
type: 'id-input',
|
12
|
+
label: 'target-map',
|
13
|
+
name: 'targetMap',
|
14
|
+
property: {
|
15
|
+
component: 'google-map'
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{
|
19
|
+
type: 'number',
|
20
|
+
label: 'latitude',
|
21
|
+
name: 'lat',
|
22
|
+
property: {
|
23
|
+
step: 0.000001,
|
24
|
+
max: 90,
|
25
|
+
min: -90
|
26
|
+
}
|
27
|
+
},
|
28
|
+
{
|
29
|
+
type: 'number',
|
30
|
+
label: 'longitude',
|
31
|
+
name: 'lng',
|
32
|
+
property: {
|
33
|
+
step: 0.000001,
|
34
|
+
max: 180,
|
35
|
+
min: -180
|
36
|
+
}
|
37
|
+
}
|
38
|
+
],
|
39
|
+
'value-property': 'latlng'
|
40
|
+
// help: 'scene/component/gmap-marker'
|
41
|
+
};
|
42
|
+
const MARKER_PATH = 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z M -2,-30 a 2,2 0 1,1 4,0 2,2 0 1,1 -4,0';
|
43
|
+
export default class GMapMarker extends RectPath(Shape) {
|
44
|
+
dispose() {
|
45
|
+
this.marker && this.marker.setMap(null);
|
46
|
+
this.marker = null;
|
47
|
+
delete this._infoWindow;
|
48
|
+
super.dispose();
|
49
|
+
}
|
50
|
+
ready() {
|
51
|
+
super.ready();
|
52
|
+
if (this.isTemplate()) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
this.onchangeTargetMap();
|
56
|
+
}
|
57
|
+
get map() {
|
58
|
+
return this._map;
|
59
|
+
}
|
60
|
+
get infoWindow() {
|
61
|
+
if (!this._infoWindow)
|
62
|
+
this._infoWindow = new google.maps.InfoWindow();
|
63
|
+
return this._infoWindow;
|
64
|
+
}
|
65
|
+
findInfoWindow(type) {
|
66
|
+
var eventSetting = (this.state.event && this.state.event[type]) || {};
|
67
|
+
var infoWindow =
|
68
|
+
/* event spec v1.0 */ eventSetting.infoWindow ||
|
69
|
+
/* event spec v1.1 */ (eventSetting.action == 'infoWindow' && eventSetting.target);
|
70
|
+
if (infoWindow) {
|
71
|
+
return this.root.findById(infoWindow);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
setInfoContent(sceneInfoWindow) {
|
75
|
+
var tpl = Component.template(sceneInfoWindow.model.frontSideTemplate);
|
76
|
+
var content = `<style>${sceneInfoWindow.model.style}</style>` + tpl(this);
|
77
|
+
this.infoWindow.setContent(content);
|
78
|
+
}
|
79
|
+
openInfoWindow(iw) {
|
80
|
+
this.setInfoContent(iw);
|
81
|
+
if (!this.map) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
this.infoWindow.open(this.map, this.marker);
|
85
|
+
}
|
86
|
+
onmarkerclick(e) {
|
87
|
+
var iw = this.findInfoWindow('tap');
|
88
|
+
iw && this.openInfoWindow(iw);
|
89
|
+
this.trigger('click', e);
|
90
|
+
}
|
91
|
+
onmarkermouseover(e) {
|
92
|
+
var iw = this.findInfoWindow('hover');
|
93
|
+
iw && this.openInfoWindow(iw);
|
94
|
+
}
|
95
|
+
onmarkermouseout(e) {
|
96
|
+
var iw = this.findInfoWindow('hover');
|
97
|
+
iw && this.infoWindow.close();
|
98
|
+
}
|
99
|
+
set marker(marker) {
|
100
|
+
if (this._marker) {
|
101
|
+
this._marker.setMap(null);
|
102
|
+
google.maps.event.clearInstanceListeners(this._marker);
|
103
|
+
delete this._marker;
|
104
|
+
}
|
105
|
+
if (marker) {
|
106
|
+
marker.addListener('click', this.onmarkerclick.bind(this));
|
107
|
+
marker.addListener('mouseover', this.onmarkermouseover.bind(this));
|
108
|
+
marker.addListener('mouseout', this.onmarkermouseout.bind(this));
|
109
|
+
this._marker = marker;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
get marker() {
|
113
|
+
if (!this._marker && this.map) {
|
114
|
+
let { lat, lng, fillStyle: fillColor, alpha: fillOpacity = 1, strokeStyle: strokeColor, lineWidth: strokeWeight } = this.state;
|
115
|
+
var marker = new google.maps.Marker({
|
116
|
+
position: {
|
117
|
+
lat: Number(lat) || 0,
|
118
|
+
lng: Number(lng) || 0
|
119
|
+
},
|
120
|
+
map: this.map,
|
121
|
+
icon: {
|
122
|
+
path: MARKER_PATH,
|
123
|
+
fillColor,
|
124
|
+
fillOpacity,
|
125
|
+
strokeColor,
|
126
|
+
strokeWeight
|
127
|
+
}
|
128
|
+
});
|
129
|
+
this.marker = marker;
|
130
|
+
}
|
131
|
+
return this._marker;
|
132
|
+
}
|
133
|
+
get hidden() {
|
134
|
+
return super.hidden || this.app.isViewMode;
|
135
|
+
}
|
136
|
+
set hidden(hidden) {
|
137
|
+
super.hidden = hidden;
|
138
|
+
}
|
139
|
+
render(context) {
|
140
|
+
var { top, left, width, height } = this.state;
|
141
|
+
context.translate(left, top);
|
142
|
+
// 마커 모양 그리기
|
143
|
+
context.beginPath();
|
144
|
+
context.moveTo(width / 2, height * 0.9);
|
145
|
+
context.bezierCurveTo(width / 2.3, height * 0.6, 0, height / 2, 0, height / 4);
|
146
|
+
context.ellipse(width / 2, height / 4, width / 2, height / 4, 0, Math.PI * 1, Math.PI * 0);
|
147
|
+
context.bezierCurveTo(width, height / 2, width / 1.7, height * 0.6, width / 2, height * 0.9);
|
148
|
+
context.closePath();
|
149
|
+
context.translate(-left, -top);
|
150
|
+
}
|
151
|
+
get controls() {
|
152
|
+
return [];
|
153
|
+
}
|
154
|
+
onchangeTargetMap() {
|
155
|
+
if (this.targetMap) {
|
156
|
+
this._targetMap = null;
|
157
|
+
this._map = null;
|
158
|
+
}
|
159
|
+
var id = this.get('targetMap');
|
160
|
+
if (id !== undefined) {
|
161
|
+
this._targetMap = this.root.findById(id);
|
162
|
+
if (this.targetMap) {
|
163
|
+
this._map = this.targetMap.map;
|
164
|
+
if (!this.map) {
|
165
|
+
var listener = (after) => {
|
166
|
+
if ('map' in after) {
|
167
|
+
this._map = after.map;
|
168
|
+
this.marker && this.marker.setMap(this.map);
|
169
|
+
this.targetMap.off('change', listener);
|
170
|
+
}
|
171
|
+
};
|
172
|
+
this.targetMap.on('change', listener);
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
this.marker && this.marker.setMap(this.map);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
get targetMap() {
|
181
|
+
return this._targetMap;
|
182
|
+
}
|
183
|
+
// get click_handler() {
|
184
|
+
// if (!this._click_handler)
|
185
|
+
// this._click_handler = this.onmarkerclick.bind(this);
|
186
|
+
// return this._click_handler;
|
187
|
+
// }
|
188
|
+
onchange(after, before) {
|
189
|
+
if ('targetMap' in after) {
|
190
|
+
this.onchangeTargetMap();
|
191
|
+
}
|
192
|
+
if ('lat' in after || 'lng' in after) {
|
193
|
+
var { lat, lng } = this.state;
|
194
|
+
this.latlng = {
|
195
|
+
lat,
|
196
|
+
lng
|
197
|
+
};
|
198
|
+
}
|
199
|
+
if (('fillStyle' in after || 'strokeStyle' in after || 'lineWidth' in after) && this.marker) {
|
200
|
+
let { fillStyle: fillColor, alpha: fillOpacity = 1, strokeStyle: strokeColor, lineWidth: strokeWeight } = this.state;
|
201
|
+
this.marker.setIcon({
|
202
|
+
path: MARKER_PATH,
|
203
|
+
fillColor,
|
204
|
+
fillOpacity,
|
205
|
+
strokeColor,
|
206
|
+
strokeWeight
|
207
|
+
});
|
208
|
+
}
|
209
|
+
super.onchange && super.onchange(after, before);
|
210
|
+
}
|
211
|
+
get latlng() {
|
212
|
+
return {
|
213
|
+
lat: this.getState('lat'),
|
214
|
+
lng: this.getState('lng')
|
215
|
+
};
|
216
|
+
}
|
217
|
+
set latlng(latlng) {
|
218
|
+
var { lat, lng } = latlng;
|
219
|
+
this.marker && this.marker.setPosition(new google.maps.LatLng(lat, lng));
|
220
|
+
this.setState({
|
221
|
+
lat,
|
222
|
+
lng
|
223
|
+
});
|
224
|
+
}
|
225
|
+
get nature() {
|
226
|
+
return NATURE;
|
227
|
+
}
|
228
|
+
}
|
229
|
+
Component.register('gmap-marker', GMapMarker);
|
230
|
+
//# sourceMappingURL=gmap-marker.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gmap-marker.js","sourceRoot":"","sources":["../src/gmap-marker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAA0B,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAG3F,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE;gBACR,SAAS,EAAE,YAAY;aACxB;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,EAAE;gBACP,GAAG,EAAE,CAAC,EAAE;aACT;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE;gBACR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AA;QACzB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QAExE,IAAI,CAAC,QAAQ,CAAC;YACZ,GAAG;YACH,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, InfoWindow, Properties, RectPath, Shape } from '@hatiolab/things-scene'\nimport GoogleMap from './google-map'\n\nconst NATURE = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'id-input',\n label: 'target-map',\n name: 'targetMap',\n property: {\n component: 'google-map'\n }\n },\n {\n type: 'number',\n label: 'latitude',\n name: 'lat',\n property: {\n step: 0.000001,\n max: 90,\n min: -90\n }\n },\n {\n type: 'number',\n label: 'longitude',\n name: 'lng',\n property: {\n step: 0.000001,\n max: 180,\n min: -180\n }\n }\n ],\n 'value-property': 'latlng'\n // help: 'scene/component/gmap-marker'\n}\n\nconst MARKER_PATH =\n 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z M -2,-30 a 2,2 0 1,1 4,0 2,2 0 1,1 -4,0'\n\nexport default class GMapMarker extends RectPath(Shape) {\n private _infoWindow?: google.maps.InfoWindow\n private _marker?: google.maps.Marker | null\n private _map?: google.maps.Map | null\n private _targetMap?: GoogleMap | null\n\n dispose() {\n this.marker && this.marker.setMap(null)\n\n this.marker = null\n delete this._infoWindow\n\n super.dispose()\n }\n\n ready() {\n super.ready()\n\n if (this.isTemplate()) {\n return\n }\n\n this.onchangeTargetMap()\n }\n\n get map() {\n return this._map\n }\n\n get infoWindow() {\n if (!this._infoWindow) this._infoWindow = new google.maps.InfoWindow()\n\n return this._infoWindow\n }\n\n findInfoWindow(type: string) {\n var eventSetting = (this.state.event && this.state.event[type]) || {}\n\n var infoWindow =\n /* event spec v1.0 */ eventSetting.infoWindow ||\n /* event spec v1.1 */ (eventSetting.action == 'infoWindow' && eventSetting.target)\n\n if (infoWindow) {\n return this.root.findById(infoWindow)\n }\n }\n\n setInfoContent(sceneInfoWindow: InfoWindow) {\n var tpl = Component.template(sceneInfoWindow.model.frontSideTemplate)\n var content = `<style>${sceneInfoWindow.model.style}</style>` + tpl(this)\n\n this.infoWindow.setContent(content)\n }\n\n openInfoWindow(iw: InfoWindow) {\n this.setInfoContent(iw)\n\n if (!this.map) {\n return\n }\n\n this.infoWindow.open(this.map, this.marker!)\n }\n\n onmarkerclick(e: Event) {\n var iw = this.findInfoWindow('tap')\n iw && this.openInfoWindow(iw)\n\n this.trigger('click', e)\n }\n\n onmarkermouseover(e: Event) {\n var iw = this.findInfoWindow('hover')\n iw && this.openInfoWindow(iw)\n }\n\n onmarkermouseout(e: Event) {\n var iw = this.findInfoWindow('hover')\n iw && this.infoWindow.close()\n }\n\n set marker(marker) {\n if (this._marker) {\n this._marker.setMap(null)\n google.maps.event.clearInstanceListeners(this._marker)\n\n delete this._marker\n }\n\n if (marker) {\n marker.addListener('click', this.onmarkerclick.bind(this))\n marker.addListener('mouseover', this.onmarkermouseover.bind(this))\n marker.addListener('mouseout', this.onmarkermouseout.bind(this))\n\n this._marker = marker\n }\n }\n\n get marker() {\n if (!this._marker && this.map) {\n let {\n lat,\n lng,\n fillStyle: fillColor,\n alpha: fillOpacity = 1,\n strokeStyle: strokeColor,\n lineWidth: strokeWeight\n } = this.state\n\n var marker = new google.maps.Marker({\n position: {\n lat: Number(lat) || 0,\n lng: Number(lng) || 0\n },\n map: this.map,\n icon: {\n path: MARKER_PATH,\n fillColor,\n fillOpacity,\n strokeColor,\n strokeWeight\n }\n })\n\n this.marker = marker\n }\n\n return this._marker\n }\n\n get hidden() {\n return super.hidden || this.app.isViewMode\n }\n\n set hidden(hidden) {\n super.hidden = hidden\n }\n\n render(context: CanvasRenderingContext2D) {\n var { top, left, width, height } = this.state\n\n context.translate(left, top)\n\n // 마커 모양 그리기\n context.beginPath()\n\n context.moveTo(width / 2, height * 0.9)\n context.bezierCurveTo(width / 2.3, height * 0.6, 0, height / 2, 0, height / 4)\n\n context.ellipse(width / 2, height / 4, width / 2, height / 4, 0, Math.PI * 1, Math.PI * 0)\n\n context.bezierCurveTo(width, height / 2, width / 1.7, height * 0.6, width / 2, height * 0.9)\n context.closePath()\n\n context.translate(-left, -top)\n }\n\n get controls() {\n return []\n }\n\n onchangeTargetMap() {\n if (this.targetMap) {\n this._targetMap = null\n this._map = null\n }\n\n var id = this.get('targetMap')\n if (id !== undefined) {\n this._targetMap = this.root.findById(id) as GoogleMap\n\n if (this.targetMap) {\n this._map = this.targetMap.map\n\n if (!this.map) {\n var listener = (after: any) => {\n if ('map' in after) {\n this._map = after.map\n this.marker && this.marker.setMap(this.map!)\n\n this.targetMap!.off('change', listener)\n }\n }\n this.targetMap.on('change', listener)\n } else {\n this.marker && this.marker.setMap(this.map)\n }\n }\n }\n }\n\n get targetMap() {\n return this._targetMap\n }\n\n // get click_handler() {\n // if (!this._click_handler)\n // this._click_handler = this.onmarkerclick.bind(this);\n\n // return this._click_handler;\n // }\n\n onchange(after: Properties, before: Properties) {\n if ('targetMap' in after) {\n this.onchangeTargetMap()\n }\n\n if ('lat' in after || 'lng' in after) {\n var { lat, lng } = this.state\n this.latlng = {\n lat,\n lng\n }\n }\n\n if (('fillStyle' in after || 'strokeStyle' in after || 'lineWidth' in after) && this.marker) {\n let {\n fillStyle: fillColor,\n alpha: fillOpacity = 1,\n strokeStyle: strokeColor,\n lineWidth: strokeWeight\n } = this.state\n\n this.marker.setIcon({\n path: MARKER_PATH,\n fillColor,\n fillOpacity,\n strokeColor,\n strokeWeight\n })\n }\n\n super.onchange && super.onchange(after, before)\n }\n\n get latlng() {\n return {\n lat: this.getState('lat'),\n lng: this.getState('lng')\n }\n }\n\n set latlng(latlng) {\n var { lat, lng } = latlng\n this.marker && this.marker.setPosition(new google.maps.LatLng(lat, lng))\n\n this.setState({\n lat,\n lng\n })\n }\n\n get nature() {\n return NATURE\n }\n}\n\nComponent.register('gmap-marker', GMapMarker)\n"]}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/// <reference types="googlemaps" />
|
2
|
+
/// <reference types="googlemaps" />
|
3
|
+
/// <reference types="googlemaps" />
|
4
|
+
/// <reference types="googlemaps" />
|
5
|
+
import { Component, InfoWindow, Properties, Shape } from '@hatiolab/things-scene';
|
6
|
+
import GoogleMap from './google-map';
|
7
|
+
declare const GMapPath_base: typeof Shape;
|
8
|
+
export default class GMapPath extends GMapPath_base {
|
9
|
+
private _infoWindow?;
|
10
|
+
private _markers;
|
11
|
+
private _map?;
|
12
|
+
private _targetMap?;
|
13
|
+
private _trackPath?;
|
14
|
+
dispose(): void;
|
15
|
+
ready(): void;
|
16
|
+
get map(): google.maps.Map<Element> | null | undefined;
|
17
|
+
findInfoWindow(type: string): Component | undefined;
|
18
|
+
getInfoContent(sceneInfoWindow: InfoWindow, index: number): string;
|
19
|
+
openInfoWindow(iw: InfoWindow, index: number): google.maps.InfoWindow | undefined;
|
20
|
+
buildMarkers(): void;
|
21
|
+
set markers(markers: google.maps.Marker[]);
|
22
|
+
get markers(): google.maps.Marker[];
|
23
|
+
get trackPath(): google.maps.Polyline | undefined;
|
24
|
+
set trackPath(trackPath: google.maps.Polyline | undefined);
|
25
|
+
get hidden(): boolean;
|
26
|
+
set hidden(hidden: boolean);
|
27
|
+
render(context: CanvasRenderingContext2D): void;
|
28
|
+
get controls(): never[];
|
29
|
+
onchangeTargetMap(): void;
|
30
|
+
get targetMap(): GoogleMap | null | undefined;
|
31
|
+
onchange(after: Properties, before: Properties): void;
|
32
|
+
get latlngs(): any;
|
33
|
+
set latlngs(latlngs: any);
|
34
|
+
get nature(): {
|
35
|
+
mutable: boolean;
|
36
|
+
resizable: boolean;
|
37
|
+
rotatable: boolean;
|
38
|
+
properties: ({
|
39
|
+
type: string;
|
40
|
+
label: string;
|
41
|
+
name: string;
|
42
|
+
property: {
|
43
|
+
component: string;
|
44
|
+
};
|
45
|
+
} | {
|
46
|
+
type: string;
|
47
|
+
label: string;
|
48
|
+
name: string;
|
49
|
+
property?: undefined;
|
50
|
+
})[];
|
51
|
+
'value-property': string;
|
52
|
+
};
|
53
|
+
}
|
54
|
+
export {};
|