Adding a Wrld polygon with elevation
Add a Wrld polygon to a map with elevation.
<!DOCTYPE HTML>
<html>
<head>
<script src="https://cdn-webgl.wrld3d.com/wrldjs/dist/latest/wrld.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" rel="stylesheet" />
</head>
<body>
<div style="position: relative">
<div id="map" style="height: 400px"></div>
<script>
var map = L.Wrld.map("map", "your_api_key_here", {
center: [55.942953, -3.161405],
zoom: 15
});
var polygonPoints = [
[55.945976, -3.162339],
[55.943671, -3.158673],
[55.941648, -3.159911],
[55.943248, -3.163275]];
// Red polygon with altitude offset from terrain height
var polyTerrainLevel = L.Wrld.polygon(polygonPoints,
{ elevation: 200, elevationMode: "heightAboveGround" })
.setColor([255,0,0,128])
.addTo(map);
// Blue polygon with altitude offset from sea level.
var polySeaLevel = L.Wrld.polygon(polygonPoints,
{ elevation: 200, elevationMode: "heightAboveSeaLevel" })
.setColor([0,0,255,128])
.addTo(map);
</script>
</div>
</body>
</html>