@operato/scene-openlayers 10.0.0-beta.2 → 10.0.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,34 @@
1
- ## build
1
+ # @operato/scene-openlayers
2
2
 
3
- `$ yarn build`
3
+ > OpenLayers component for things-scene
4
4
 
5
- | type | filename | for | tested |
6
- | ---- | ------------------------------------------ | -------------- | ------ |
7
- | UMD | things-scene-scene-openlayers.js | modern browser | O |
8
- | UMD | things-scene-scene-openlayers-ie.js | ie 11 | O |
9
- | ESM | things-scene-scene-openlayers.mjs | modern browser | O |
5
+ <!-- AUTOGEN_BEGIN: do not edit between markers (run scripts/regenerate-readmes.mjs to update) -->
10
6
 
11
- ## publish
7
+ ## Components
12
8
 
13
- `$ yarn publish`
9
+ - `Openlayers`
10
+ - `OpenLayersMarker`
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ yarn add @operato/scene-openlayers
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { Openlayers, OpenLayersMarker } from '@operato/scene-openlayers'
22
+ ```
23
+
24
+ ## Build
25
+
26
+ ```bash
27
+ yarn build
28
+ ```
29
+
30
+ Output: ESM module at `dist/index.js` (single bundle, no UMD/IE legacy).
31
+
32
+ _Version: 10.0.0-beta.2_
33
+
34
+ <!-- AUTOGEN_END -->
@@ -53,7 +53,7 @@ declare const OpenLayersMarker_base: (new (...args: any[]) => {
53
53
  get disposed(): boolean;
54
54
  isLayer(): boolean;
55
55
  isGroup(): boolean;
56
- isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component.js").Container;
56
+ isContainer(): this is import("@hatiolab/things-scene").Container;
57
57
  isLine(): boolean;
58
58
  isRoot(): boolean;
59
59
  isRootModel(): boolean;
@@ -69,9 +69,9 @@ declare const OpenLayersMarker_base: (new (...args: any[]) => {
69
69
  get(property: any): any;
70
70
  set(props: any, propval?: any): any;
71
71
  getState(property: any): any;
72
- setState(props: any, propval?: any): any;
72
+ setState(props: Partial<import("@hatiolab/things-scene").State> | string, propval?: any): any;
73
73
  get model(): any;
74
- get state(): any;
74
+ get state(): import("@hatiolab/things-scene").State;
75
75
  get hierarchy(): any;
76
76
  get volatile(): never[];
77
77
  _applyProps(target: any, props: any, options: any): any;
@@ -162,7 +162,7 @@ declare const OpenLayersMarker_base: (new (...args: any[]) => {
162
162
  findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
163
163
  capture(x: number, y: number, except?: (c: Component) => boolean): any;
164
164
  findAnchor(name: string): any;
165
- isDescendible(container: Component): boolean;
165
+ isDescendible(container: Component | any): boolean;
166
166
  getContext(component?: unknown): any;
167
167
  get root(): Component;
168
168
  get rootModel(): Component;
@@ -206,9 +206,13 @@ declare const OpenLayersMarker_base: (new (...args: any[]) => {
206
206
  toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
207
207
  toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
208
208
  toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
209
+ on<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
209
210
  on(name: string | object, callback: Function, context?: any): any;
211
+ off<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback?: ((...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void) | undefined, context?: any): any;
210
212
  off(name?: string | object, callback?: Function, context?: any): any;
213
+ once<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, callback: (...args: import("@hatiolab/things-scene").ComponentEventMap[K]) => void, context?: any): any;
211
214
  once(name: string | object, callback: Function, context?: any): any;
215
+ trigger<K extends keyof import("@hatiolab/things-scene").ComponentEventMap>(name: K, ...args: import("@hatiolab/things-scene").ComponentEventMap[K]): any;
212
216
  trigger(name: string, ...args: any[]): any;
213
217
  delegate_on(delegator: any): any;
214
218
  delegate_off(delegator: any): any;
@@ -1 +1 @@
1
- {"version":3,"file":"openlayers.js","sourceRoot":"","sources":["../src/openlayers.ts"],"names":[],"mappings":"AAAA;;GAEG;;;AAEH,iDAAiD;AACjD,OAAO,eAAe,MAAM,yBAAyB,CAAA;AAErD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACvC,OAAO,EAAE,MAAM,IAAI,WAAW,EAAQ,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AACnE,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAY,KAAK,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EAEL,oBAAoB,EAIpB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,GACf,kHAAkH,CAAA;AAEpH,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;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,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,CAAC,GAAG;gBACT,GAAG,EAAE,GAAG;aACT;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAA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AAA;IACvB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;;AA7MkB,UAAU;IAD9B,cAAc,CAAC,YAAY,CAAC;GACR,UAAU,CA8M9B;eA9MoB,UAAU","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\n// @ts-expect-error -- webpack text-loader import\nimport OpenLayersStyle from '!!text-loader!ol/ol.css'\n\nimport { Feature, Map, View } from 'ol'\nimport { Circle as CircleStyle, Fill, Icon, Stroke, Style } from 'ol/style.js'\nimport { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer'\nimport { Vector as VectorSource, OSM } from 'ol/source'\nimport { fromLonLat } from 'ol/proj'\nimport { Geometry, Point } from 'ol/geom'\n\nimport {\n Component,\n HTMLOverlayContainer,\n Properties,\n ComponentNature,\n error,\n sceneComponent\n} from '@hatiolab/things-scene'\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\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\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 min: -180,\n max: 180\n }\n },\n {\n type: 'number',\n label: 'zoom',\n name: 'zoom'\n },\n {\n type: 'boolean',\n label: 'show-marker',\n name: 'showMarker'\n }\n ],\n 'value-property': 'latlng',\n help: 'scene/component/openlayers'\n}\n\nfunction getGlobalScale(component: Component) {\n var scale = { x: 1, y: 1 }\n var parent = component\n\n while (parent) {\n let { x, y } = parent.get('scale') || { x: 1, y: 1 }\n scale.x *= x || 1\n scale.y *= y || 1\n\n parent = parent.parent\n }\n return scale\n}\n\n@sceneComponent('openlayers')\nexport default class Openlayers extends HTMLOverlayContainer {\n static markerStyle: Style = new Style({\n image: new Icon({\n src:\n 'data:image/svg+xml;charset=utf-8,' +\n encodeURIComponent('<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">' + MARKER_PATH + '</svg>'),\n anchor: [0.5, 1]\n })\n })\n\n _anchor?: HTMLDivElement\n _map: Map | null = null\n _listenTo?: Component\n _listener?: Function\n _vectorSource?: VectorSource<Feature>\n _marker: Feature | null = null\n\n get eventMap() {\n return {\n 'model-layer': {\n '(self)': {\n change: (after: any) => {\n after.scale && this.rescale()\n }\n }\n }\n }\n }\n\n /*\n * 부모의 스케일의 역으로 transform해서, scale을 1로 맞추어준다.\n */\n rescale() {\n var anchor = this._anchor\n if (!anchor) {\n return\n }\n\n var scale = getGlobalScale(this as any)\n\n var sx = 1 / scale.x\n var sy = 1 / scale.y\n\n var transform = `scale(${sx}, ${sy})`\n\n anchor!.style.transform = transform\n anchor!.style.transformOrigin = '0px 0px'\n\n var { width, height } = this.state\n anchor.style.width = width * scale.x + 'px'\n anchor.style.height = height * scale.y + 'px'\n }\n\n createElement() {\n super.createElement()\n this._anchor = document.createElement('div')\n\n const style = document.createElement('style')\n style.textContent = `\n ${OpenLayersStyle}\n `\n\n this.element!.appendChild(style)\n this.element!.appendChild(this._anchor)\n\n const { lat, lng, zoom, showMarker } = this.state\n\n // 지도의 중심 좌표\n const center = fromLonLat([lng || 126.9783882, lat || 37.5666103])\n\n // 타일 레이어 생성 (배경 지도)\n const tileLayer = new TileLayer({\n source: new OSM({\n attributions: ''\n })\n })\n\n // 벡터 레이어 생성\n const styles: { [name: string]: Style } = {\n route: new Style({\n stroke: new Stroke({\n width: 6,\n color: [237, 212, 0, 0.8]\n })\n }),\n marker: Openlayers.markerStyle,\n circle: new Style({\n image: new CircleStyle({\n radius: 7,\n stroke: new Stroke({\n color: 'black',\n width: 2\n })\n })\n })\n }\n\n const vectorSource = new VectorSource()\n const vectorLayer = new VectorLayer({\n source: vectorSource,\n style: function (feature) {\n return styles[feature.get('type')]\n }\n })\n\n // 지도 생성\n const map = new Map({\n target: this._anchor,\n layers: [tileLayer, vectorLayer],\n view: new View({\n center,\n zoom\n })\n })\n\n this._map = map\n this._vectorSource = vectorSource\n\n showMarker && this.refreshMarker()\n\n this.rescale()\n }\n\n get tagName() {\n return 'div'\n }\n\n get map() {\n return this._map\n }\n\n dispose() {\n super.dispose()\n\n delete this._anchor\n }\n\n setElementProperties(div: HTMLDivElement) {\n this.rescale()\n }\n\n refreshMarker() {\n const { showMarker, lat, lng } = this.state\n\n if (this._marker) {\n this.vectorSource?.removeFeature(this._marker)\n this._marker = null\n }\n\n if (showMarker) {\n // 지도의 중심 좌표\n const center = fromLonLat([lng || 126.9783882, lat || 37.5666103])\n\n this._marker = new Feature({\n type: 'circle',\n geometry: new Point(center)\n })\n\n this.vectorSource?.addFeatures([this._marker])\n }\n }\n\n onchange(after: Properties, before: Properties) {\n if ('zoom' in after) {\n const view = this.map?.getView()\n view?.setZoom(after.zoom)\n }\n\n if ('lat' in after || 'lng' in after) {\n let { lat, lng } = this.state\n const view = this.map?.getView()\n view?.setCenter(fromLonLat([lng, lat]))\n\n if (this._marker) {\n const geometry = this._marker.getGeometry()\n if (geometry instanceof Point) {\n geometry.setCoordinates(fromLonLat([lng, lat]))\n }\n }\n }\n\n if ('showMarker' in after) {\n this.refreshMarker()\n }\n\n super.onchange(after, before)\n\n this.rescale()\n }\n\n get latlng() {\n const { lat, lng } = this.state\n return { lat, lng }\n }\n\n set latlng(latlng) {\n this.setState(latlng)\n }\n\n get vectorSource() {\n return this._vectorSource\n }\n\n get nature() {\n return NATURE\n }\n}\n"]}
1
+ {"version":3,"file":"openlayers.js","sourceRoot":"","sources":["../src/openlayers.ts"],"names":[],"mappings":"AAAA;;GAEG;;;AAEH,iDAAiD;AACjD,OAAO,eAAe,MAAM,yBAAyB,CAAA;AAErD,OAAO,E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,CA8M9B;eA9MoB,UAAU","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\n// @ts-expect-error -- webpack text-loader import\nimport OpenLayersStyle from '!!text-loader!ol/ol.css'\n\nimport { Feature, Map, View } from 'ol'\nimport { Circle as CircleStyle, Fill, Icon, Stroke, Style } from 'ol/style.js'\nimport { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer'\nimport { Vector as VectorSource, OSM } from 'ol/source'\nimport { fromLonLat } from 'ol/proj'\nimport { Geometry, Point } from 'ol/geom'\n\nimport {\n Component,\n HTMLOverlayContainer,\n Properties,\n ComponentNature,\n error,\n sceneComponent\n} from '@hatiolab/things-scene'\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\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\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 min: -180,\n max: 180\n }\n },\n {\n type: 'number',\n label: 'zoom',\n name: 'zoom'\n },\n {\n type: 'boolean',\n label: 'show-marker',\n name: 'showMarker'\n }\n ],\n 'value-property': 'latlng',\n help: 'scene/component/openlayers'\n}\n\nfunction getGlobalScale(component: Component | any) {\n var scale = { x: 1, y: 1 }\n var parent = component\n\n while (parent) {\n let { x, y } = parent.get('scale') || { x: 1, y: 1 }\n scale.x *= x || 1\n scale.y *= y || 1\n\n parent = parent.parent\n }\n return scale\n}\n\n@sceneComponent('openlayers')\nexport default class Openlayers extends HTMLOverlayContainer {\n static markerStyle: Style = new Style({\n image: new Icon({\n src:\n 'data:image/svg+xml;charset=utf-8,' +\n encodeURIComponent('<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\">' + MARKER_PATH + '</svg>'),\n anchor: [0.5, 1]\n })\n })\n\n _anchor?: HTMLDivElement\n _map: Map | null = null\n _listenTo?: Component\n _listener?: Function\n _vectorSource?: VectorSource<Feature>\n _marker: Feature | null = null\n\n get eventMap() {\n return {\n 'model-layer': {\n '(self)': {\n change: (after: any) => {\n after.scale && this.rescale()\n }\n }\n }\n }\n }\n\n /*\n * 부모의 스케일의 역으로 transform해서, scale을 1로 맞추어준다.\n */\n rescale() {\n var anchor = this._anchor\n if (!anchor) {\n return\n }\n\n var scale = getGlobalScale(this)\n\n var sx = 1 / scale.x\n var sy = 1 / scale.y\n\n var transform = `scale(${sx}, ${sy})`\n\n anchor!.style.transform = transform\n anchor!.style.transformOrigin = '0px 0px'\n\n var { width, height } = this.state\n anchor.style.width = width * scale.x + 'px'\n anchor.style.height = height * scale.y + 'px'\n }\n\n createElement() {\n super.createElement()\n this._anchor = document.createElement('div')\n\n const style = document.createElement('style')\n style.textContent = `\n ${OpenLayersStyle}\n `\n\n this.element!.appendChild(style)\n this.element!.appendChild(this._anchor)\n\n const { lat, lng, zoom, showMarker } = this.state\n\n // 지도의 중심 좌표\n const center = fromLonLat([lng || 126.9783882, lat || 37.5666103])\n\n // 타일 레이어 생성 (배경 지도)\n const tileLayer = new TileLayer({\n source: new OSM({\n attributions: ''\n })\n })\n\n // 벡터 레이어 생성\n const styles: { [name: string]: Style } = {\n route: new Style({\n stroke: new Stroke({\n width: 6,\n color: [237, 212, 0, 0.8]\n })\n }),\n marker: Openlayers.markerStyle,\n circle: new Style({\n image: new CircleStyle({\n radius: 7,\n stroke: new Stroke({\n color: 'black',\n width: 2\n })\n })\n })\n }\n\n const vectorSource = new VectorSource()\n const vectorLayer = new VectorLayer({\n source: vectorSource,\n style: function (feature) {\n return styles[feature.get('type')]\n }\n })\n\n // 지도 생성\n const map = new Map({\n target: this._anchor,\n layers: [tileLayer, vectorLayer],\n view: new View({\n center,\n zoom\n })\n })\n\n this._map = map\n this._vectorSource = vectorSource\n\n showMarker && this.refreshMarker()\n\n this.rescale()\n }\n\n get tagName() {\n return 'div'\n }\n\n get map() {\n return this._map\n }\n\n dispose() {\n super.dispose()\n\n delete this._anchor\n }\n\n setElementProperties(div: HTMLDivElement) {\n this.rescale()\n }\n\n refreshMarker() {\n const { showMarker, lat, lng } = this.state\n\n if (this._marker) {\n this.vectorSource?.removeFeature(this._marker)\n this._marker = null\n }\n\n if (showMarker) {\n // 지도의 중심 좌표\n const center = fromLonLat([lng || 126.9783882, lat || 37.5666103])\n\n this._marker = new Feature({\n type: 'circle',\n geometry: new Point(center)\n })\n\n this.vectorSource?.addFeatures([this._marker])\n }\n }\n\n onchange(after: Properties, before: Properties) {\n if ('zoom' in after) {\n const view = this.map?.getView()\n view?.setZoom(after.zoom)\n }\n\n if ('lat' in after || 'lng' in after) {\n let { lat, lng } = this.state\n const view = this.map?.getView()\n view?.setCenter(fromLonLat([lng, lat]))\n\n if (this._marker) {\n const geometry = this._marker.getGeometry()\n if (geometry instanceof Point) {\n geometry.setCoordinates(fromLonLat([lng, lat]))\n }\n }\n }\n\n if ('showMarker' in after) {\n this.refreshMarker()\n }\n\n super.onchange(after, before)\n\n this.rescale()\n }\n\n get latlng() {\n const { lat, lng } = this.state\n return { lat, lng }\n }\n\n set latlng(latlng) {\n this.setState(latlng)\n }\n\n get vectorSource() {\n return this._vectorSource\n }\n\n get nature() {\n return NATURE\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@operato/scene-openlayers",
3
3
  "description": "OpenLayers component for things-scene",
4
- "version": "10.0.0-beta.2",
4
+ "version": "10.0.0-beta.31",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "things-scene": true,
@@ -59,5 +59,5 @@
59
59
  "prettier --write"
60
60
  ]
61
61
  },
62
- "gitHead": "350ece104754d007967cf8e3f54d0d157465e94a"
62
+ "gitHead": "fdafbd04fd083a43690be937230c7d96a3ee5da3"
63
63
  }