@maptiler/sdk 2.5.0 → 2.5.1
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/dist/maptiler-sdk.mjs +493 -471
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/MaptilerGeolocateControl.d.ts +1 -0
- package/package.json +1 -1
- package/readme.md +34 -1
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -987,7 +987,40 @@ Turning off *zoom compensation* allows for more accurate adjustments to the visu
|
|
|
987
987
|
|
|
988
988
|
All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#heatmap) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=heatmap+helper).
|
|
989
989
|
|
|
990
|
-
# Other
|
|
990
|
+
# Other helpers
|
|
991
|
+
## Convert GPX and KML to GeoJSON
|
|
992
|
+
In the [Polyline helper section](#polyline-layer-helper) above, we have seen that one can feed the helper directly with a path to a GPX or KML file, that is then converted under the hood client-side into a GeoJSON `FeatureCollection` object. This conversion feature is also exposed and can be used as such:
|
|
993
|
+
|
|
994
|
+
```ts
|
|
995
|
+
import { gpx } from "@maptiler/sdk";
|
|
996
|
+
|
|
997
|
+
// ... assuming inside an async function
|
|
998
|
+
|
|
999
|
+
// Fetching the GPX file as a string:
|
|
1000
|
+
const gpxFilePath = "some_gps_trace.gpx";
|
|
1001
|
+
const gpxResponse = await fetch(gpxFilePath);
|
|
1002
|
+
const gpxStr = await res.text();
|
|
1003
|
+
|
|
1004
|
+
// Converting the GPX payload into a GeoJSON FeatureCollection:
|
|
1005
|
+
const features = maptilersdk.gpx(gpxStr);
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
And for KML files:
|
|
1009
|
+
```ts
|
|
1010
|
+
import { kml } from "@maptiler/sdk";
|
|
1011
|
+
|
|
1012
|
+
// ... assuming inside an async function
|
|
1013
|
+
|
|
1014
|
+
// Fetching the KML file as a string:
|
|
1015
|
+
const kmlFilePath = "some_gps_trace.kml";
|
|
1016
|
+
const kmlResponse = await fetch(kmlFilePath);
|
|
1017
|
+
const kmlStr = await res.text();
|
|
1018
|
+
|
|
1019
|
+
// Converting the KML payload into a GeoJSON FeatureCollection:
|
|
1020
|
+
const features = maptilersdk.gpx(kmlStr);
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
|
|
991
1024
|
## Take Screenshots, programmatically
|
|
992
1025
|
There are two different ways to create screenshot, corresponding to two very different usecases. Note that screenshots will not contain *DOM elements* such as `Marker` and `Popup`, since those are not part of the rendering context.
|
|
993
1026
|
|