NavToolbar.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
  2. * full list of contributors). Published under the Clear BSD license.
  3. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
  4. * full text of the license. */
  5. /**
  6. * @requires OpenLayers/Control/Panel.js
  7. * @requires OpenLayers/Control/Navigation.js
  8. * @requires OpenLayers/Control/ZoomBox.js
  9. */
  10. /**
  11. * Class: OpenLayers.Control.NavToolbar
  12. * This Toolbar is an alternative to the Navigation control that displays
  13. * the state of the control, and provides a UI for changing state to
  14. * use the zoomBox via a Panel control.
  15. *
  16. * If you wish to change the properties of the Navigation control used
  17. * in the NavToolbar, see:
  18. * http://trac.openlayers.org/wiki/Toolbars#SubclassingNavToolbar
  19. *
  20. *
  21. * Inherits from:
  22. * - <OpenLayers.Control.Panel>
  23. */
  24. OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {
  25. /**
  26. * Constructor: OpenLayers.Control.NavToolbar
  27. * Add our two mousedefaults controls.
  28. *
  29. * Parameters:
  30. * options - {Object} An optional object whose properties will be used
  31. * to extend the control.
  32. */
  33. initialize: function(options) {
  34. OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
  35. this.addControls([
  36. new OpenLayers.Control.Navigation(),
  37. new OpenLayers.Control.ZoomBox()
  38. ]);
  39. },
  40. /**
  41. * Method: draw
  42. * calls the default draw, and then activates mouse defaults.
  43. */
  44. draw: function() {
  45. var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
  46. if (this.defaultControl === null) {
  47. this.defaultControl = this.controls[0];
  48. }
  49. return div;
  50. },
  51. CLASS_NAME: "OpenLayers.Control.NavToolbar"
  52. });