@naivemap/mapbox-gl-image-layer 0.6.0-beta.0 → 0.6.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Naive Map
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,97 +1,11 @@
1
- ## ImageLayer class
2
-
3
- ```bash
4
- npm i @naivemap/mapbox-gl-image-layer proj4
5
- ```
6
-
7
- <b>Signature:</b>
8
-
9
- ```typescript
10
- export default class ImageLayer implements mapboxgl.CustomLayerInterface
11
- ```
12
-
13
- <b>Implements:</b> mapboxgl.CustomLayerInterface
14
-
15
- ## Constructors
16
-
17
- | Constructor | Description |
18
- | --- | --- |
19
- | (constructor)(`id`: `string`, `option`: `ImageOption`) | Constructs a new instance of the <code>ImageLayer</code> class |
20
-
21
- ### Parameters
22
-
23
- **id** `(string)` The ID of the layer.
24
-
25
- **option** `(ImageOption)` The option of the image.
26
-
27
- | Name | Description |
28
- | --- | --- |
29
- | **option.url** <br />(`string`) | URL that points to an image. |
30
- | **option.projection** <br />(`string`) | Projection with EPSG code that points to the image. |
31
- | **option.coordinates** <br />(`Array<Array<number>>`) | Corners of image specified in longitude, latitude pairs: top left, top right, bottom right, bottom left. ref: [coordinates](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#image-coordinates) |
32
- | **option.resampling** <br />(Optional `enum`. One of `"linear"`, `"nearest"`. Defaults to `"linear"`) | The resampling/interpolation method to use for overscaling, also known as texture magnification filter. ref: [raster-resampling](https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#paint-raster-raster-resampling) |
33
- | **option.opacity** <br />(Optional `number` between 0 and 1 inclusive. Defaults to 1. | The opacity at which the image will be drawn. |
34
- | **option.crossOrigin** <br />(`string`) | The crossOrigin attribute is a string which specifies the Cross-Origin Resource Sharing ([CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS)) setting to use when retrieving the image. |
35
- | **option.mask** <br />(`MaskProperty`) | The polygonal mask or multipolygonal mask for the image. |
36
-
37
- ```ts
38
- export type ImageOption = {
39
- url: string
40
- projection: string
41
- coordinates: Coordinates
42
- resampling?: 'linear' | 'nearest'
43
- opacity?: number
44
- crossOrigin?: string
45
- mask?: MaskProperty
46
- }
47
-
48
- // top left, top right, bottom right, bottom left.
49
- export type Coordinates = [[number, number], [number, number], [number, number], [number, number]]
50
-
51
- export type MaskProperty = {
52
- type?: 'in' | 'out' // default: in
53
- data: GeoJSON.Polygon | GeoJSON.MultiPolygon
54
- }
55
- ```
56
-
57
- ### Methods
58
-
59
- #### updateImage
60
-
61
- Updates the URL, the projection, the coordinates, the opacity or the resampling of the image.
62
-
63
- ```ts
64
- updateImage(option: {
65
- url?: string
66
- projection?: string
67
- coordinates?: Coordinates
68
- opacity?: number
69
- resampling?: 'linear' | 'nearest'
70
- }): this
71
- ```
72
-
73
- #### updateMask
74
-
75
- Updates the mask property.
76
-
77
- ```ts
78
- updateMask(mask: Partial<MaskProperty>): this
79
- ```
80
-
81
- ## Example
82
-
83
- ```ts
84
- const layer = new ImageLayer('layer-id', {
85
- url: '/4326.png',
86
- projection: 'EPSG:4326',
87
- resampling: 'nearest',
88
- coordinates: [
89
- [105.289838, 32.204171], // top-left
90
- [110.195632, 32.204171], // top-right
91
- [110.195632, 28.164713], // bottom-right
92
- [105.289838, 28.164713], // bottom-left
93
- ],
94
- })
95
-
96
- map.addLayer(layer)
97
- ```
1
+ # @naivemap/mapbox-gl-image-layer
2
+
3
+ ImageLayer ([@naivemap/mapbox-gl-image-layer](https://www.npmjs.com/package/@naivemap/mapbox-gl-image-layer)): A versatile layer for displaying georeferenced images with **various projections** on the map. It supports loading and correctly positioning images from different coordinate systems, making it ideal for integrating non-standard raster data, historical maps, or aerial imagery.
4
+
5
+ [API References](https://www.naivemap.com/map-gl-layers/api/image-layer/)
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @naivemap/mapbox-gl-image-layer proj4
11
+ ```
@@ -0,0 +1,6 @@
1
+ export * from './mapbox-gl-image-layer/src/index'
2
+ export {}
3
+ import ImageLayer from './mapbox-gl-image-layer/src/index'
4
+ export default ImageLayer
5
+ export * from './mapbox-gl-image-layer/src/index'
6
+ export {}