AW: [OpenLayers-Users] Changing style based on feature attributes.

Arnd Wippermann arnd.wippermann at web.de
Fri Jul 8 06:16:20 EDT 2011


Hi,

Looking at the OpenLayers code I would overwrite getNodeType

OpenLayers.Renderer.SVG.prototype.getNodeType = function(geometry, style) {
        var nodeType = null;
        switch (geometry.CLASS_NAME) {
            case "OpenLayers.Geometry.Point":
                if (style.externalGraphic && style.externalGraphic!="") {
//                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    nodeType = "image";
                } else if (this.isComplexSymbol(style.graphicName)) {
                    nodeType = this.supportUse === false ? "svg" : "use";
                } else {
                    nodeType = "circle";
                }
                break;
            case "OpenLayers.Geometry.Rectangle":
                nodeType = "rect";
                break;
            case "OpenLayers.Geometry.LineString":
                nodeType = "polyline";
                break;
            case "OpenLayers.Geometry.LinearRing":
                nodeType = "polygon";
                break;
            case "OpenLayers.Geometry.Polygon":
            case "OpenLayers.Geometry.Curve":
            case "OpenLayers.Geometry.Surface":
                nodeType = "path";
                break;
            default:
                break;
        }
        return nodeType;
}; 
Similiar for VML.

What's your solution?

Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von emmexx
Gesendet: Freitag, 8. Juli 2011 11:30
An: kapuch
Cc: users at openlayers.org
Betreff: Re: AW: [OpenLayers-Users] Changing style based on feature
attributes.

Il 07/08/2011 10:16 AM, kapuch scrisse:
> Try this and you will see that this is not the way to do this.

I sent a working example to your address.

To the developers: if the example can be of any help to others can we put it
in the examples folder or in the wiki?

thank you
	maxx
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list