[OpenLayers-Users] Highlight Selected Feature

Meine Toonen meinetoonen at b3partners.nl
Wed Jan 16 04:16:18 PST 2013


You have to define a select renderIntent with the wanted visuals for highlighting.
For example, at creating the vectorlayer:

var style = new OpenLayers.Style(
// the first argument is a base symbolizer
// all other symbolizers in rules will extend this one
{
    graphicWidth: 21,
    graphicHeight: 21,
    graphicYOffset: -28, // shift graphic up 28 pixels
    label: "${label}",
   symbolizer: {
            externalGraphic: "../../images/treeview/radio_rood.gif"
        }
}
}
);
var selectstyle = new OpenLayers.Style(
// the first argument is a base symbolizer
// all other symbolizers in rules will extend this one
{
    graphicWidth: 31,
    graphicHeight: 31,
    graphicYOffset: -28, // shift graphic up 28 pixels
    label: "${label}",
   symbolizer: {
            externalGraphic: "../../images/treeview/radio_rood.gif"
        }
}
}
);

this.vectorLayer = new OpenLayers.Layer.Vector("Points", {
            styleMap: new OpenLayers.StyleMap( {
                "default": style,
                "select": selectstyle
            })
        }
        );

And then (for example) use a selectfeaturecontrol for selecting the features (on 
var select = new OpenLayers.Control.SelectFeature(this.vectorLayer, {hover: true});
this.map.addControl(select);
select.activate();


Met vriendelijke groet,

Meine Toonen
B3Partners BV
Tel: 030 214 2083


Jerome A. Wendell <jawendell at digitalmapping.com> , 15-1-2013 22:24:


I have a map where I have selected a feature by attribute, and then centered and zoomed to the feature using the following:

 

                vectorlayer.events.register('loadend', vectorlayer, function () {

                                var selfeatures = vectorlayer.getFeaturesByAttribute("description","description");

                                map.setCenter(selfeatures[0].geometry.getCentroid());

                                map.zoomToExtent(selfeatures[0].geometry.getBounds());

                });

 

I am having trouble getting the feature to highlight.  My select control for the map uses a popup.  Could this be the problem?  Do I need a second control to highlight the feature?

 

Any suggestions are appreciated.

 

Thanks,

 

Jerome Wendell

 

_______________________________________________ 
Users mailing list 
Users at lists.osgeo.org 
http://lists.osgeo.org/mailman/listinfo/openlayers-users 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130116/991ceb9b/attachment-0001.html>


More information about the Users mailing list