<div dir="ltr">Hi,<div><br></div><div style>thanks everyone for helping, but I've finally given up because all the workarounds felt like using a screwdriver to hammer a nail, as to paraphrase James here <a href="http://spatiallyadjusted.com/2013/01/30/gis-for-those-who-hate-gis/">http://spatiallyadjusted.com/2013/01/30/gis-for-those-who-hate-gis/</a>.</div>
<div style><br></div><div style>Just to let you know, I've played a bit with leaflet and I could do that easily. Maybe I was not using the right tool for my needs for my 'stylish' needs (Dont get me wrong, I'm not blaming OpenLayers which is an awesome piece of software for other classes of problems, but unfortunately not suited for my custom 'stylish' needs )</div>
<div style> </div><div style>Thanks all</div><div style>Regards</div><div style>Yves</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/2/8 Sergeant_york <span dir="ltr"><<a href="mailto:electronicpanda@gmail.com" target="_blank">electronicpanda@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I tryed context functions to change the offsets of the points (by dividing<br>
bikes and docks to 2 features) but unfortunately after bike's style applied<br>
then when docks style gets applied bike's style also changes. Might be a bug<br>
because of me, I could came to this position lastly, maybe you can see the<br>
error here, couldn't have time to recheck:<br>
<br>
//Stations layer<br>
var stations = []; // my data of stations i want in a vector layer<br>
var station1 = {<br>
position:new OpenLayers.Geometry.Point(-5000000,0),<br>
data: {<br>
bikes: 8,<br>
docks: 20<br>
}<br>
}<br>
var station2 = {<br>
position:new OpenLayers.Geometry.Point(500000,4000000),<br>
data: {<br>
bikes: 2,<br>
docks: 10<br>
}<br>
}<br>
stations.push(station1);<br>
stations.push(station2);<br>
var resultVectors=[];<br>
var tempData=[];<br>
for(var i=0;i<stations.length;i++){<br>
//here we create new point features for each type<br>
//for bike points<br>
tempData.bikes=stations[i].data.bikes;<br>
resultVectors.push(new OpenLayers.Feature.Vector(stations[i].position,<br>
tempData));<br>
tempData=[];<br>
tempData.docks=stations[i].data.docks<br>
resultVectors.push(new OpenLayers.Feature.Vector(stations[i].position,<br>
tempData));<br>
tempData=[];<br>
}<br>
//how to define a custom style to display BOTH labels of stations datas<br>
(bikes and docks) one on top, one on bottom of the green circle centered to<br>
the station position?<br>
var context = {<br>
label : function(station){<br>
// docks or bikes , how ?<br>
if(typeof station.data.bikes!='undefined')<br>
return "bikes:"+station.data.bikes ;<br>
else if(typeof station.data.docks!='undefined')<br>
return "docs:"+station.data.docks;<br>
} ,<br>
yOffset : function(station){<br>
<br>
// - for docks, + for bikes , how ?<br>
if(typeof station.data.bikes!='undefined')<br>
return 100;<br>
else if(typeof station.data.docks!='undefined')<br>
return 0;<br>
},<br>
grap : function(station){<br>
// - for docks, + for bikes , how ?<br>
if(typeof station.data.bikes!='undefined')<br>
return<br>
'<a href="http://www.inflatable-watertoy.com/photo/pm818499-lovely_durable_pvc_inflatable_beach_balls_with_smiling_face_to_play_in_the_water_pool.jpg" target="_blank">http://www.inflatable-watertoy.com/photo/pm818499-lovely_durable_pvc_inflatable_beach_balls_with_smiling_face_to_play_in_the_water_pool.jpg</a>'<br>
;<br>
else if(typeof station.data.docks!='undefined')<br>
return<br>
'<a href="http://www.gettyicons.com/free-icons/123/onebit-3/png/48/sad_face_48.png" target="_blank">http://www.gettyicons.com/free-icons/123/onebit-3/png/48/sad_face_48.png</a>';<br>
<div class="im"> }<br>
}<br>
<br>
var style = new OpenLayers.Style({<br>
</div> pointRadius : 15,<br>
fillColor: '#32cd32',<br>
label: '${label}',<br>
graphicYOffset: "${yOffset}",<br>
externalGraphic: "${grap}"<br>
},{<br>
context:{<br>
label : function(station){<br>
// docks or bikes , how ?<br>
if(typeof station.data.bikes!='undefined')<br>
return "bikes:"+station.data.bikes ;<br>
else if(typeof station.data.docks!='undefined')<br>
return "docs:"+station.data.docks;<br>
} ,<br>
yOffset : function(station){<br>
<br>
// - for docks, + for bikes , how ?<br>
if(typeof station.data.bikes!='undefined')<br>
return 100;<br>
else if(typeof station.data.docks!='undefined')<br>
return 0;<br>
},<br>
grap : function(station){<br>
if(typeof station.data.bikes!='undefined')<br>
return<br>
'<a href="http://www.inflatable-watertoy.com/photo/pm818499-lovely_durable_pvc_inflatable_beach_balls_with_smiling_face_to_play_in_the_water_pool.jpg" target="_blank">http://www.inflatable-watertoy.com/photo/pm818499-lovely_durable_pvc_inflatable_beach_balls_with_smiling_face_to_play_in_the_water_pool.jpg</a>'<br>
;<br>
else if(typeof station.data.docks!='undefined')<br>
return<br>
'<a href="http://www.gettyicons.com/free-icons/123/onebit-3/png/48/sad_face_48.png" target="_blank">http://www.gettyicons.com/free-icons/123/onebit-3/png/48/sad_face_48.png</a>';<br>
}<br>
<br>
<br>
}<br>
});<br>
<br>
var stationsLayer = new OpenLayers.Layer.Vector('Stations' , {styleMap :new<br>
OpenLayers.StyleMap(style)} );<br>
//stationsLayer.addFeatures(stations);<br>
stationsLayer.addFeatures(resultVectors);<br>
var map = new OpenLayers.Map({<br>
div: "map",<br>
center : [0,0],<br>
zoom:2,<br>
layers: [new OpenLayers.Layer.OSM(),stationsLayer ],<br>
controls:[new OpenLayers.Control.Navigation(),new<br>
OpenLayers.Control.LayerSwitcher()]<br>
});<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Vector-layer-and-multiple-symbolizers-tp5032127p5032993.html" target="_blank">http://osgeo-org.1560.n6.nabble.com/Vector-layer-and-multiple-symbolizers-tp5032127p5032993.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</div></div></blockquote></div><br></div>