JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="./resources/ol.css">
<link rel="stylesheet" href="resources/fontawesome-all.min.css">
<link rel="stylesheet" type="text/css" href="resources/horsey.min.css">
<link rel="stylesheet" type="text/css" href="resources/ol3-search-layer.min.css">
<link rel="stylesheet" href="./resources/ol-layerswitcher.css">
<link rel="stylesheet" href="./resources/qgis2web.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<style>
.search-layer {
top: 135px;
left: .5em;
}
.ol-touch .search-layer {
top: 180px;
}
</style>
<style>
html, body {
background-color: #ffffff;
}
.ol-control button {
background-color: #f8f8f8 !important;
color: #000000 !important;
border-radius: 0px !important;
}
.ol-zoom, .geolocate, .gcd-gl-control .ol-control {
background-color: rgba(255,255,255,.4) !important;
padding: 3px !important;
}
.ol-scale-line {
background: none !important;
}
.ol-scale-line-inner {
border: 2px solid #f8f8f8 !important;
border-top: none !important;
background: rgba(255, 255, 255, 0.5) !important;
color: black !important;
}
</style>
<style>
.geolocate {
top: 65px;
left: .5em;
}
.ol-touch .geolocate {
top: 80px;
}
</style>
<style>
.tooltip {
position: relative;
background:...
JavaScript
isTracking = false;
var geolocateControl = (function (Control) {
geolocateControl = function(opt_options) {
var options = opt_options || {};
var button = document.createElement('button');
button.className += ' fa fa-map-marker';
var handleGeolocate = function() {
if (isTracking) {
map.removeLayer(geolocateOverlay);
isTracking = false;
} else if (geolocation.getTracking()) {
map.addLayer(geolocateOverlay);
map.getView().setCenter(geolocation.getPosition());
isTracking = true;
}
};
button.addEventListener('click', handleGeolocate, false);
button.addEventListener('touchstart', handleGeolocate, false);
var element = document.createElement('div');
element.className = 'geolocate ol-unselectable ol-control';
element.appendChild(button);
ol.control.Control.call(this, {
element: element,
target: options.target
});
};
if (Control) geolocateControl.__proto__ = Control;
geolocateControl.prototype = Object.create(Control && Control.prototype);
geolocateControl.prototype.constructor = geolocateControl;
return geolocateControl;
}(ol.control.Control));
var measuring = false;
var measureControl = (function (Control) {
measureControl = function(opt_options) {
var options = opt_options || {};
var button = document.createElement('button');
button.className += ' fas fa-ruler ';
var this_ = this;
var handleMeasure = function(e) {
if (!measuring) {
this_.getMap().addInteraction(draw);
createHelpTooltip();
createMeasureTooltip();
measuring = true;
} else {
this_.getMap().removeInteraction(draw);
measuring = false;
this_.getMap().removeOverlay(helpTooltip);
...