[OpenLayers-Users] overwriting functions

Paul Spencer pagameba at gmail.com
Tue Sep 18 08:39:55 EDT 2007


Kevin,

although this is probably not what you want to do (as Chris said  
later in this thread), the reason why this is not working for you is  
that you need to change the 'prototype' of SelectFeature.

OpenLayers.Control.SelectFeature.prototype.downFeature = function 
(feature){
alert('Overwritten!');
};

Cheers

Paul

On 17-Sep-07, at 9:22 AM, 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:
> --
> OpenLayers.Control.SelectFeature.downFeature = function(feature){
> alert('Overwritten!');
> };
> map = new OpenLayers.Map('map', {controls: []});
> mySelect = new OpenLayers.Control.SelectFeature(vectors, {onSelect:  
> serialize, onUnselect: deselect,multiple: true});
> map.addControl(mySelect);
> --
> doesn't work, second try:
> --
> map = new OpenLayers.Map('map', {controls: []});
> mySelect = new OpenLayers.Control.SelectFeature(vectors, {onSelect:  
> serialize, onUnselect: deselect,multiple: true});
> mySelect.downFeature = function(feature){
> alert('Overwritten!');
> };
> map.addControl(mySelect);
> --
>
> Doesn't work, too. I think I just don't see the beginners mistake...
>
> Thanks,
>
> Kevin.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+








More information about the Users mailing list