Point layer (point helper)
This example shows how to add a point layer to the map using the point layer helper with the default values. Download the earthquake sample data.
In this example, the color is chosen randomly from a predetermined list of colors. This is the standard default behavior when no specific color is mentioned.
NPM module setup
npm install --save @maptiler/sdk
import { Map, MapStyle, config, helpers } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
container: 'map',
zoom: 4.30,
center: [-119.602, 35.732],
style: MapStyle.DATAVIZ.LIGHT
});
map.on('load', async function () {
await helpers.addPoint(map, {
data: 'YOUR_MAPTILER_DATASET_ID_HERE',
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Point layer (point helper) | NPM example</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="map"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
Related examples
Point layer scaled radius by property (point helper)
ExamplesScale point layer radius and color by property.