Is there a way to prevent an overlaying div
on a leaflet map from being clickthrough? I tried setting pointer-events: none
and auto
on the overlaying div, but it didn't work. Setting pointer-events
to none
resulted in the radiobutton not being clickable anymore...
// Adding a tile layer to the map
var osmUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {
maxZoom: 18,
attribution: osmAttrib
});
// Initializing the map
var map = L.map('map').setView([19.04469, 72.9258], 12).addLayer(osm);
// Function for adding marker on map click
function onMapClick(e) {
var marker = L.marker(e.latlng, {
draggable: true,
title: "Resource location",
alt: "Resource Location",
riseOnHover: true
}).addTo(map)
.bindPopup(e.latlng.toString()).openPopup();
// Update marker position on drag end
marker.on("dragend", function(ev) {
var changedPos = ev.target.getLatLng();
this.bindPopup(changedPos.toString()).openPopup();
});
}
map.on('click', onMapClick);
#map {
height: 500px;
width: 80%;
z-index: 1;
position: relative;
}
.overlay {
height: 500px;
width: 100px;
position: absolute;
right: 0px;
z-index: 2;
background-color: rgba(255, 50, 50, 0.5);
pointer-events: auto;
}
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<link href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" rel="stylesheet" />
<div id="map">
<div class = "overlay">
<input type="radio" class = "someButton">Foo Bar
</div>
</div>