Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var self = this;
- var newButton;
- L.Control.currentPosition = L.Control.extend({
- onAdd: function (map) {
- //this method is called when this new control is added later to your map
- var className = 'your-custom-container-class',
- container = L.DomUtil.create('div', className);
- newButton = this._createButton(
- '', L.drawLocal.draw.toolbar.buttons.currentPosition, 'your-custom-button-class', 'your-button-id', container, this.newButtonFunction, self);
- return container;
- },
- newButtonFunction: function(ev){
- },
- _createButton: function (html, title, className, id, container, fn, context) {
- var link = L.DomUtil.create('a', className, container);
- link.innerHTML = html;
- link.href = '#';
- link.title = title;
- link.id = id;
- var stop = L.DomEvent.stopPropagation;
- L.DomEvent
- .on(link, 'click', stop)
- .on(link, 'mousedown', stop)
- .on(link, 'dblclick', stop)
- .on(link, 'click', L.DomEvent.preventDefault)
- .on(link, 'click', fn, context);
- return link;
- }
- });
- //finally add the new control to your map object
- this.map.addControl(new L.Control.newButton());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement