[OpenLayers-Users] Cannot change style selecting "Feature" by attribute

ggarcia ggarcia at ihman.com
Fri Aug 12 07:44:50 EDT 2011


Hi! Everyone from OpenLayers Users xD

The last days I was doing tests trying to access "features" using an
attribute.

Here is how I'm selecting features by attribute (this is working):
[CODE]
function map_select_element(identity) {
  var feature = [];
  feature =  map_vectorLayer.getFeaturesByAttribute("name", "Element
"+identity);
  feature[0].attributes.name = "selected";
}
[/CODE]

The problem is that I would like to change the style of the element, so at
first I tried with OpenLayers.Style:
[CODE]
  feature[0].style = new OpenLayers.Style({
    "graphicWidth": 53,
    "graphicHeight": 59,
    "externalGraphic": "img/element_selected.png",
  });
[/CODE]

There is no apparent errors but the element dissapear :S

So I also tried to select them using a "select event" but I don't know how
to launch it properly.
[CODE]
  map_vectorLayer = new OpenLayers.Layer.Vector(
    "Vector Layer",{
      styleMap: new OpenLayers.StyleMap({
        "default": defaultStyle,
        "select": selectStyle
      })
    }
  );
[/CODE]

Someone so kind, has been in a similar situation? xD

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Cannot-change-style-selecting-Feature-by-attribute-tp6680044p6680044.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list