Keith Turkowski
unread,Jun 6, 2012, 6:17:19 PM6/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to leafl...@googlegroups.com
I've updated to the latest master, and I'm trying to create a custom control... I've looked at several examples, but I can't quite figure it out.
I'm just trying to create a custom button in upper right corner that does an alert("Hello World"); when clicked.
So far I've got something like this...
L.Control.Hello = L.Control.extend({
options: {
position: 'topright'
},
onAdd: function (<what goes here??>) {
var className = 'leaflet-control-hello';
container = L.DomUtil.create('div', className);
var link = L.DomUtil.create('a', className + '-button', container);
link.href = '#';
link.title = 'Hello Button';
L.DomEvent.addListener(link, 'click', L.DomEvent.stopPropagation)
L.DomEvent.addListener(link, 'click', L.DomEvent.preventDefault)
L.DomEvent.addListener(link, 'click', alert('Hello World'), <what goes here??>);
return container;
}
});
....
map.addControl(new L.Control.Hello());
....
Any help would be appreciated, thanks!