On Mon, Apr 21, 2008 at 6:30 PM, Diego Guidi <[EMAIL PROTECTED]> wrote:
> I retry to make the same questions... sorry for the "spam" but I hope
> to get some suggests on how to fix my problem
Hi Diego,
I managed to do what you want to do by implementing my own version of
the NavToolBar class. See the attached patch to
examples/navtoolbar.html to understand what I did.
Hope that helps,
--
Eric
Index: examples/navtoolbar.html
===================================================================
--- examples/navtoolbar.html (revision 6989)
+++ examples/navtoolbar.html (working copy)
@@ -18,15 +18,72 @@
var zoom = 5;
var map, layer;
+ OpenLayers.Control.NavToolbar2 = OpenLayers.Class(OpenLayers.Control.Panel, {
+
+ /**
+ * Constructor: OpenLayers.Control.NavToolbar
+ * Add our two mousedefaults controls.
+ *
+ * Parameters:
+ * options - {Object} An optional object whose properties will be used
+ * to extend the control.
+ */
+ initialize: function(options) {
+ OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
+ this.addControls([
+ new OpenLayers.Control.Navigation(),
+ new OpenLayers.Control.ZoomBox(
+ {keyMask: OpenLayers.Handler.MOD_NONE})
+ ]);
+ },
+
+ /**
+ * Method: draw
+ * calls the default draw, and then activates mouse defaults.
+ */
+ draw: function() {
+ var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
+ this.activateControl(this.controls[0]);
+ return div;
+ },
+
+ CLASS_NAME: "OpenLayers.Control.NavToolbar2"
+ });
+
function init() {
map = new OpenLayers.Map( 'map', { controls: [new OpenLayers.Control.PanZoom()] } );
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
- var panel = new OpenLayers.Control.NavToolbar();
+ var panel = new OpenLayers.Control.NavToolbar2(
+ {displayClass: 'olControlNavToolbar'}
+ );
map.addControl(panel);
+ var customBox = new OpenLayers.Control();
+ OpenLayers.Util.extend(customBox, {
+ draw: function () {
+ this.box = new OpenLayers.Handler.Box(customBox,
+ { "done": this.notice },
+ { keyMask: OpenLayers.Handler.MOD_SHIFT }
+ );
+ this.box.activate();
+ },
+ notice: function (bounds) {
+ var ll = map.getLonLatFromPixel(new
+ OpenLayers.Pixel(bounds.left, bounds.bottom));
+ var ur = map.getLonLatFromPixel(new
+ OpenLayers.Pixel(bounds.right, bounds.top));
+ alert(ll.lon.toFixed(4) + ", " +
+ ll.lat.toFixed(4) + ", " +
+ ur.lon.toFixed(4) + ", " +
+ ur.lat.toFixed(4));
+ }
+ });
+ map.addControl(customBox);
+ customBox.activate();
+
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
}
</script>
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users