Hi,
your first approach should work. Your second approach couldn't work as you
only declares the default style.
Below the code I use to set a styleMap:
var myDefStyleProp = {
pointRadius: 6,
cursor : 'pointer',
strokeColor: '#00FF00',
fillColor : '#AAFF00',
fillOpacity: 0.75,
strokeWidth: 1
}
var mySelStyleProp = {
pointRadius: 6,
cursor : 'pointer',
strokeColor: '#0000FF',
fillColor : '#00AAFF',
fillOpacity: 0.5,
strokeWidth: 4
}
/*Version 1
var defStyle = OpenLayers.Util.applyDefaults( myDefStyleProp,
OpenLayers.Feature.Vector.style["default"] );
var selStyle = OpenLayers.Util.applyDefaults( mySelStyleProp,
OpenLayers.Feature.Vector.style["select"] );
*/
//Version 2
var defStyle = OpenLayers.Util.applyDefaults( new
OpenLayers.Style(myDefStyleProp), OpenLayers.Feature.Vector.style["default"]
);
var selStyle = OpenLayers.Util.applyDefaults( new
OpenLayers.Style(mySelStyleProp), OpenLayers.Feature.Vector.style["select"]
);
var myStyleMap = new OpenLayers.StyleMap( {
'default' : defStyle,
'select' : selStyle
})
_aktLayer.styleMap = myStyleMap;
_aktLayer.redraw();
Arnd
_____
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Mario Nuñez
Jimenez
Gesendet: Donnerstag, 27. Januar 2011 12:07
An: [email protected]
Betreff: [OpenLayers-Users] FW: vector layer, styles
_____
From: Mario Nuñez Jimenez
Sent: miércoles, 26 de enero de 2011 18:48
To: '[email protected]'
Subject: vector layer, styles
I have been taking a look in openlayers website but something is still wrong
because it does not work:
myStyleMap = new OpenLayers.StyleMap( {
'default' : {
strokeColor : '#007D69',
strokeWidth : 2,
cursor : 'pointer'
},
'select' : {
strokeWidth : 6,
strokeColor : '#aaffaa'
}
});
layer = new OpenLayers.Layer.Vector(
metadata.title, {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: getProtocol(metadata),
styleMap: myStyleMap
}
);
I need to apply a style to my layer but I need to add some particular
characteristics as default and some others as select, I say that because
I also tried this:
myMapStyle = new OpenLayers.StyleMap(
OpenLayers.Util.applyDefaults(
{
pointRadius: 6,
cursor: 'pointer',
strokeColor: '#000000',
fillColor: #FFAA00,
opacity: 4,
strokeWidth: 1
},
OpenLayers.Feature.Vector.style["default"]
)
);
};
layer = new OpenLayers.Layer.Vector(
metadata.title, {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: getProtocol(metadata),
styleMap: myStyleMap
}
);
But in result only default or selected is applied, so I dont know how
to do this way to apply both.
Any tip?
Thank you for your help.
Mario
------------------------------------------------------------------
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive
this e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin
group liability cannot be triggered for the message content. Although
the sender endeavours to maintain a computer virus-free network,
the sender does not warrant that this transmission is virus-free and
will not be liable for any damages resulting from any virus transmitted.
Este mensaje y los ficheros adjuntos pueden contener informacion
confidencial
destinada solamente a la(s) persona(s) mencionadas anteriormente
pueden estar protegidos por secreto profesional.
Si usted recibe este correo electronico por error, gracias por informar
inmediatamente al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
Origin
no se hace responsable por su contenido. Su contenido no constituye ningun
compromiso para el grupo Atos Origin, salvo ratificacion escrita por ambas
partes.
Aunque se esfuerza al maximo por mantener su red libre de virus, el emisor
no puede garantizar nada al respecto y no sera responsable de cualesquiera
danos que puedan resultar de una transmision de virus.
------------------------------------------------------------------
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users