@maptiler/sdk 3.8.0-rc5 → 3.8.0-rc7
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 +44 -0
- package/dist/maptiler-sdk.mjs +2827 -2445
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/ImageViewer/ImageViewer.d.ts +256 -15
- package/dist/src/ImageViewer/events.d.ts +24 -2
- package/dist/src/ImageViewer/index.d.ts +3 -0
- package/dist/src/ImageViewer/monkeyPatchML.d.ts +4 -0
- package/dist/src/Map.d.ts +3 -3
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +4 -1
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +7 -0
- package/dist/src/custom-layers/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/{ImageViewer/utils.d.ts → utils/errors.d.ts} +1 -1
- package/dist/src/utils/webgl-utils.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -675,6 +675,50 @@ Note: if `space.color` or `space.<faces | path | preset>` are not explicitly set
|
|
|
675
675
|
|
|
676
676
|
Further code examples can be found in `~/demos/`
|
|
677
677
|
|
|
678
|
+
# `ImageViewer`
|
|
679
|
+
|
|
680
|
+
MapTiler's `ImageViewer` component allows you to display tiled, non-georeferenced images but interact with them the same way you would if you were displaying map. These can be handy for zoomable non-georeferenced, geographically "inaccurate" maps such as hotel maps, golf courses, theme parks etc. Think pixels instead of lattitudes and longtidues.
|
|
681
|
+
|
|
682
|
+
```ts
|
|
683
|
+
export type ImageViewerConstructorOptions = {
|
|
684
|
+
imageUUID: string; // the unique UUID of the image object you are displaying
|
|
685
|
+
center?: [number, number]; // the center you want the viewer to init on, defaults to the center of the image.
|
|
686
|
+
container: string | HTMLElement // the container element you want to mount the viewer on
|
|
687
|
+
apiKey: string; // your MapTiler API Key
|
|
688
|
+
zoom?: number;
|
|
689
|
+
maxZoom?: number;
|
|
690
|
+
minZoom?: number;
|
|
691
|
+
bearing?: number;
|
|
692
|
+
debug?: boolean; // whether you want to debug the tiles
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
const imageViewer = new ImageViewer({
|
|
696
|
+
container: document.getElementById("map")!, // the container element you want to use
|
|
697
|
+
apiKey: "YOUR_MAPTILER_API_KEY", // your api key
|
|
698
|
+
imageUUID: "11111111-2222-3333-4444-555555555555", // unique UUID of the image object
|
|
699
|
+
// ...other options, see below
|
|
700
|
+
}: ImageViewerConstructorOptions);
|
|
701
|
+
|
|
702
|
+
await imageViewer.onReadyAsync()
|
|
703
|
+
|
|
704
|
+
// OR
|
|
705
|
+
|
|
706
|
+
imageViewer.on("imageviewerready", () => { console.log('Ready!') })
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
## Methods
|
|
710
|
+
`ImageViewer` provides a subset of methods for interaction with the map. A major caveat is that the `ImageViewer` component works in pixels and not in LngLat. Thus, when using methods such as `setCenter` or `flyTo` the pixel values provided refer to the _absolute pixel position_ on the image, not screen pixel position.
|
|
711
|
+
|
|
712
|
+
Imagine your image is 10,000px x 10,000px, if regardless if your zoom is 2 or 4, calling `.setCenter(500,500)` will always position the viewer over the same part of the image.
|
|
713
|
+
|
|
714
|
+
For full details on supported methods see the type declaration for `ImageViewer`.
|
|
715
|
+
|
|
716
|
+
## Events
|
|
717
|
+
In a similar manner, a subset of map events are fired by the image viewer. All UI interaction events that would normally include a `LngLat` in the event data instead receive an `imageX` and `imageY` field, representing an absolute pixel position of the image. This is same for `flyTo`, `jumpTo`, `panTo` etc.
|
|
718
|
+
|
|
719
|
+
A full list of supported events can be found in the exported type declaration `ImageViewerEventTypes`
|
|
720
|
+
|
|
721
|
+
|
|
678
722
|
# Easy language switching
|
|
679
723
|
The language generally depends on the style but we made it possible to easily set and update from a built-in list of languages.
|
|
680
724
|
|