[OpenLayers-Users] Selecting a feature - does not always work

Nick Whitelegg nick at hogweed.org
Wed Nov 21 19:01:59 EST 2007


Hello everyone,

Another problem relating to the 'osmajax' editor 
(http://www.free-map.org.uk/freemap/javascript/osmajax-0.5/index.php - see my 
last post). Selecting a feature does not always work - the feature always 
goes blue but sometimes  the status message at the top does not read "you 
selected a feature with ID xxxx". Tests in my code reveal that the variable 
"selectedFeature" is not always set. My code to respond to a mouse click on a 
feature:

  this.selectUp = function (f)
    {
        if(f instanceof OpenLayers.Feature.OSM)
        {
            var item = f.osmitem;
            var msg;
            if(item.type != 'unknown')
                msg = 'You selected a ' + item.type;
            else
                msg = 'You selected an item of unknown type ';
            if(item.tags['name'])
                msg += ' ('+item.tags['name']+')';
            msg += ' with an ID of ' + item.osmid;
            self.statusMsg(msg);
            self.selectedFeature = f;
        }
    }

Any ideas what might be wrong here? Using openlayers 2.4.
The behaviour appears to occur randomly.

Thanks,
Nick



More information about the Users mailing list