Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. var self = this;
  2. var newButton;
  3. L.Control.currentPosition = L.Control.extend({
  4. onAdd: function (map) {
  5. //this method is called when this new control is added later to your map
  6. var className = 'your-custom-container-class',
  7. container = L.DomUtil.create('div', className);
  8. newButton = this._createButton(
  9. '', L.drawLocal.draw.toolbar.buttons.currentPosition, 'your-custom-button-class', 'your-button-id', container, this.newButtonFunction, self);
  10. return container;
  11. },
  12.  
  13. newButtonFunction: function(ev){
  14.  
  15. },
  16.  
  17. _createButton: function (html, title, className, id, container, fn, context) {
  18. var link = L.DomUtil.create('a', className, container);
  19. link.innerHTML = html;
  20. link.href = '#';
  21. link.title = title;
  22. link.id = id;
  23. var stop = L.DomEvent.stopPropagation;
  24. L.DomEvent
  25. .on(link, 'click', stop)
  26. .on(link, 'mousedown', stop)
  27. .on(link, 'dblclick', stop)
  28. .on(link, 'click', L.DomEvent.preventDefault)
  29. .on(link, 'click', fn, context);
  30. return link;
  31. }
  32. });
  33.  
  34. //finally add the new control to your map object
  35. this.map.addControl(new L.Control.newButton());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement