[OpenLayers-Users] Selecting a feature - does not always work
Eric Lemoine
eric.c2c at gmail.com
Thu Nov 22 08:42:31 EST 2007
On Nov 22, 2007 1:01 AM, Nick Whitelegg <nick at hogweed.org> wrote:
>
> 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.
Hi Nick,
If your feature goes blue it means that the SelectFeature control did
its job. If you don't get the expected message, I think it means
there's a problem in your code. Could you provide more of your code so
that we can try helping you out?
Cheers,
--
Eric
More information about the Users
mailing list