You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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 helper
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 =awaitfetch(gpxFilePath);
1002
+
const gpxStr =awaitres.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 =awaitfetch(kmlFilePath);
1017
+
const kmlStr =awaitres.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.
0 commit comments