[OpenLayers-Users] overwriting functions

Christopher Schmidt crschmidt at metacarta.com
Mon Sep 17 09:41:13 EDT 2007


On Mon, Sep 17, 2007 at 03:22:20PM +0200, Kevin Kempfer wrote:
> Hi,
> 
> simple question: How can I overwrite specific functions? For example, I 
> would like to overwrite OpenLayers.Control.SelectFeature.downfeature() 
> with my own function. Here's what I tried:

I don't se a 'downFeature' in the SVN trunk, so I'm going to assume that
you're looking at 2.4. Please correct me if I'm wrong. 

You probably don't want to override downFeature/clickFeature -- the
reason being that this is where all the logic for selecting Features
goes. Additionally, it's not an API method, so changing it means that
you don't have backwards compatibility with future releases -- as I
pointed out, this changed in 2.5 to 'clickFeature'. 

You're currently overriding the onSelect and onUnselect functions --
which is the right thing to be overriding, as these are API function --
and overriding downFeature can be done similarly:

mySelect = new OpenLayers.Control.SelectFeature(vectors, {onSelect: 
  serialize, onUnselect: deselect,multiple: true, downFeature:function()
  {alert('hi')}});

However, before you do htis, I'd like to understand why, so we can
figure out in what way the OpenLayers SelectFeature handler is lacking. 

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list