Hello list, Sorry but I don't know how the previous message was sent incomplete and by mistake. I'll go on: I managed to develope a custom control called IktSelectTool.js which basically selects and highlights fetures from a WFS layer . The control doesn't select features, but it registers a click event on the map to select the WFS features (that's my idea). The registry of the event and the selection of the features works fine, and know I want to make a tool. Basically the source of this file is: /* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ /** * @requires OpenLayers/Control.js * * Class: OpenLayers.Control.IktSelectTool * * Inherits from: * - <OpenLayers.Control> */ OpenLayers.Control.IktSelectTool = OpenLayers.Class(OpenLayers.Control, { /** * Property: type * {OpenLayers.Control.TYPE} */ type: OpenLayers.Control.TYPE_TOOL, /** * Constructor: OpenLayers.Control.Switch * Fires a user defined function when toggled on/off * * Parameters: * options - {func} An optional object whose properties will be used * to extend the control. */ initialize: function(on, off, options) { OpenLayers.Control.prototype.initialize.apply(this, [options]); this.userOn = on; this.userOff = off; }, /** * Method: activate * Override OpenLayers.Control.activate to call user defined "on" function */ activate: function () { if (this.active) { return false; } if (this.handler) { this.handler.activate(); } this.active = true; this.userOn(); return true; }, /** * Method: deactivate * Override OpenLayers.Control.deactivate to call user defined "off" function */ deactivate: function () { if (this.active) { if (this.handler) { this.handler.deactivate(); } this.active = false; this.userOff(); return true; } return false; }, /** * Method: userOn * placeholder for the user defined function that will be fired when Switch is activated */ userOn: function(){ }, /** * Method: userOn * placeholder for the user defined function that will be fired when Switch is deactivated */ userOff: function(){ }, CLASS_NAME: "OpenLayers.Control.IktSelectTool" }); I create the control in my init function in this way: var oDrawSelCtrl = new OpenLayers.Control.IktSelectTool(f1,f2,{ id:"oSelFeatureCtrl", title: 'Selección', displayClass: 'olSelectFeature'}); where f1 is the function which is triggered when the control is activated and f2 is the function which is triggered when the function is deactivated. For my test they are only two functions that do nothing (just create somo strings to see if they work), but the idea is to register or unregister a map event. Then I add this control to my panel by this way: panel.addControls([oDragPanCtrl,history.next, history.previous,zoombox,oZoomBoxOutCtrl, zoomtomaxextent,oDrawLnCtrl,oDrawPtCtrl,oDrawPolCtrl,oDrawSelCtrl]); And in my index.html I've defined the corresponding CSS class: /* SelectFeature */ .olControlPanel .olSelectFeatureItemActive{ background-image: url("images/Select_on.png"); background-repeat: no-repeat; background-position: 0px 0px; } .olControlPanel .olSelectFeatureItemInactive{ background-image: url("images/Select_off.png"); background-repeat: no-repeat; background-position: 0px 0px; } At this point everything is OK, the page can be loaded without errors and all that stuff. The strange behaviour I'm talking about is that when I select the tool, the tool's image is not uploaded, I mean, it doesn't change from Select_off.png to Select_on.png, but if I drag a bit on the map or make a zoom, the tool's image is uploaded. I'd like to figure out what's happening because the user, future user of the app, won't know that the tool is activated until he makes a zoom or something related to the map. Can someone, please, help me with this problem. Thanks again.
Un saludo, ·················································································· David Alda Fernández de Lezea Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad IKT Granja Modelo s/n · 01192 · Arkaute (Araba) ·················································································· Tlfnos.: 945-00-32-95 Fax: 945-00.32.90 ·················································································· email: [email protected] web: www.ikt.es <http://www.ikt.es/> ··················································································
<<logo.gif>>
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
