Add inline button toggle to map
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://app.vexcelgroup.com/map/v1/public/css/styles.css" type="text/css"/>
<style>
.map {
height: 800px;
}
.toggle-button {
right: 0.5em;
top: 0.5em;
}
.toggle-button.ol-active button {
background: rgba(60, 136, 0, 0.7);
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="text/javascript" src="https://app.vexcelgroup.com/map/v1/public/Vexcel.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
main.js
const API_KEY = "YOUR_KEY";
const core = new Vexcel.Map({
target: "map",
token: API_KEY,
init: {
layers: false,
callback: () => {
const toggle = new Vexcel.Control.Toggle({
html: '<i class="fa fa-exclamation" ></i>',
class: 'toggle-button',
title: "Point",
onToggle(active) {
alert(`Button is ${active}`);
},
});
core.addControl(toggle);
},
},
});