ユーザーコントロール:ourCustomControl を作成してmapに登録。
ちなみにユーザーコントロールのクリックイベントが発生するとMAPにもイベントが伝搬してしまうので、
クリックイベントではe.stopPropagation();を読んでMAPにイベントだ伝搬することを停止。
[code]
var ourCustomControl = L.Control.extend({
options: {
position: ‘topleft’
//control position – allowed: ‘topleft’, ‘topright’, ‘bottomleft’, ‘bottomright’
},
onAdd: function (map) {
var container = L.DomUtil.create(‘div’, ‘leaflet-bar leaflet-control leaflet-control-custom’);
container.style.backgroundColor = ‘white’;
container.style.width = ’30px’;
container.style.height = ’30px’;
container.onclick = function(e){
e.stopPropagation();
console.log(‘buttonClicked’);
//drawControl.options.draw = true;
new L.Draw.Marker(map, drawControl.options.marker).enable();
}
return container;
},
});
map.addControl(new ourCustomControl());
[/code]