code
Snippet
language
CDN
package_2
NPM
content_copy
Copy
open_in_new
Open
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 14
});
const path = [
[ 2.2945 , 48.8584 ], [ 2.3050 , 48.8590 ], [ 2.3200 , 48.8600 ],
[ 2.3376 , 48.8606 ], [ 2.3500 , 48.8530 ]
];
const marker = new maptilersdk. Marker ({ color: '#9C27B0' })
. setLngLat (path[ 0 ]). addTo (map);
let i = 0 ;
setInterval (() => {
i = (i + 1 ) % path. length ;
marker. setLngLat (path[i]);
map. panTo (path[i]);
}, 2000 ); content_copy
Copy
open_in_new
Open
<! doctype html >
< html lang = "en" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >Live GPS Tracking with MapTiler SDK</ title >
< link rel = "stylesheet" href = "https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css" >
< script src = "https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js" ></ script >
< style >
body { margin : 0 ; padding : 0 ; }
#map { width : 100 % ; height : 100 vh ; }
</ style >
</ head >
< body >
< div id = "map" ></ div >
< script >
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 14
});
const path = [
[ 2.2945 , 48.8584 ], [ 2.3050 , 48.8590 ], [ 2.3200 , 48.8600 ],
[ 2.3376 , 48.8606 ], [ 2.3500 , 48.8530 ]
];
const marker = new maptilersdk. Marker ({ color: '#9C27B0' })
. setLngLat (path[ 0 ]). addTo (map);
let i = 0 ;
setInterval (() => {
i = (i + 1 ) % path. length ;
marker. setLngLat (path[i]);
map. panTo (path[i]);
}, 2000 );
</ script >
</ body >
</ html > content_copy
Copy
open_in_new
Open
import * as maptilersdk from '@maptiler/sdk' ;
import '@maptiler/sdk/dist/maptiler-sdk.css' ;
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY' ;
const map = new maptilersdk. Map ({
container: 'map' ,
style: maptilersdk.MapStyle. STREETS ,
center: [ 2.3522 , 48.8566 ],
zoom: 14
});
const path = [
[ 2.2945 , 48.8584 ], [ 2.3050 , 48.8590 ], [ 2.3200 , 48.8600 ],
[ 2.3376 , 48.8606 ], [ 2.3500 , 48.8530 ]
];
const marker = new maptilersdk. Marker ({ color: '#9C27B0' })
. setLngLat (path[ 0 ]). addTo (map);
let i = 0 ;
setInterval (() => {
i = (i + 1 ) % path. length ;
marker. setLngLat (path[i]);
map. panTo (path[i]);
}, 2000 );
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 14
});
const path = [
[2.2945, 48.8584], [2.3050, 48.8590], [2.3200, 48.8600],
[2.3376, 48.8606], [2.3500, 48.8530]
];
const marker = new maptilersdk.Marker({ color: '#9C27B0' })
.setLngLat(path[0]).addTo(map);
let i = 0;
setInterval(() => {
i = (i + 1) % path.length;
marker.setLngLat(path[i]);
map.panTo(path[i]);
}, 2000); <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live GPS Tracking with MapTiler SDK</title>
<link rel="stylesheet" href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css">
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script>
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 14
});
const path = [
[2.2945, 48.8584], [2.3050, 48.8590], [2.3200, 48.8600],
[2.3376, 48.8606], [2.3500, 48.8530]
];
const marker = new maptilersdk.Marker({ color: '#9C27B0' })
.setLngLat(path[0]).addTo(map);
let i = 0;
setInterval(() => {
i = (i + 1) % path.length;
marker.setLngLat(path[i]);
map.panTo(path[i]);
}, 2000);
</script>
</body>
</html> import * as maptilersdk from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 14
});
const path = [
[2.2945, 48.8584], [2.3050, 48.8590], [2.3200, 48.8600],
[2.3376, 48.8606], [2.3500, 48.8530]
];
const marker = new maptilersdk.Marker({ color: '#9C27B0' })
.setLngLat(path[0]).addTo(map);
let i = 0;
setInterval(() => {
i = (i + 1) % path.length;
marker.setLngLat(path[i]);
map.panTo(path[i]);
}, 2000);
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live GPS Tracking with MapTiler SDK</title>
<link rel="stylesheet" href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css">
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script>
maptilersdk.config.apiKey = 'LKv9WPh4aJggV1CHU4Y8';
const map = new maptilersdk.Map({
container: 'map',
style: maptilersdk.MapStyle.STREETS,
center: [2.3522, 48.8566],
zoom: 14
});
const path = [
[2.2945, 48.8584], [2.3050, 48.8590], [2.3200, 48.8600],
[2.3376, 48.8606], [2.3500, 48.8530]
];
const marker = new maptilersdk.Marker({ color: '#9C27B0' })
.setLngLat(path[0]).addTo(map);
let i = 0;
setInterval(() => {
i = (i + 1) % path.length;
marker.setLngLat(path[i]);
map.panTo(path[i]);
}, 2000);
</script>
</body>
</html>