Skip to main content

Load vector tile service

show
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Loading vector tile map service</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<style>
body {
margin: 0;
padding: 0;
}

#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.16.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
let map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.72541613154851, 31.31171803927643],
zoom: 14,
pitch:60,
userId: '***', // Authorization code
});

map.on('load', function () {

//Load vector tile service
map.addSource("roadCross",{
"type": "vector",
"url": "<your source url>"
})

map.addLayer({
"id": "roadCross",
"type": 'circle', // MVT data source supports circle/ line/ fill/ symbol/ fill-extrusion/ heatmap
"source": "roadCross", // Vector tile service ID
"source-layer": "b_roadCross", // Layer ID within the service
"layout": {},
"paint": {
"circle-color": "#98fffa",
"circle-radius": 5, // The radius of the point
"circle-stroke-color": "#ffffff", // Circle border color
"circle-stroke-width": 2, // The width of the circle border
"circle-stroke-opacity":0.8, // The transparency of the circle border
}
})
})
</script>
</body>
</html>