lundi 1 décembre 2014

Clickable L.control on leaflet


I am trying to add a L.Control element to my leaflet map. However once I added the element to my map, I noticed that its not clickable. I would like to display a form inside this L.Control element, however I cant select any elements from my drop down menus, since the clicks always go through to the map.


Here a JSfiddle: http://ift.tt/1wd5lGr


as well as my JS code:



var map = L.map('map').setView([0.27, 37.66], 6);

// add an OpenStreetMap tile layer
L.tileLayer('http://ift.tt/1lSj3Er', {
attribution: '&copy; <a href="http://ift.tt/VGR6Z6">OpenStreetMap</a> contributors'
}).addTo(map);


var mainMenu = L.Control.extend({
options: {position: 'topright'},

onAdd : function (map) {
this._div = L.DomUtil.create('div', 'mainMenu');
this._div.innerHTML = '<h3>Main Menu</h3>';

this._div.innerHTML += '<h4>Data:</h4> MODIS NDVI <h4>AOI:</h4> Kenya, Africa <br><br>'
this._div.innerHTML += '<h4>Indicator:</h4>'
this._div.innerHTML += '<form><form id="form" class="form" action="" method="POST">' +
'<select name="indicator"><option value="NDVI_ABS">NDVI<br>' +
'<option value="NDVI_VCI">VCI<br>' +
'<option value="RAIN_ABS">Precipitation<br>' +
'</select>';
this._div.innerHTML += '<input type="submit" value="Refresh Map" name="submit"></form>';
return this._div;
},
});
map.addControl(new mainMenu());


Any suggestions on how to make it clickable?





Aucun commentaire:

Enregistrer un commentaire