1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| // Ajout d'abord d'un style propre associé à ta troisième couche gpx....
var myStyleMap2 = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
OpenLayers.Util.applyDefaults({
fillColor: "#FFFF00",
fillOpacity: 1,
strokeColor: "#FF0000",
strokeWidth: 5,
graphicZIndex: "${zIndex}",
graphicName: "triangle",
pointRadius: 8,
//see context object below
label:"${getName}",
labelAlign: "rb",
labelXOffset: -20,
labelYOffset: -20,
labelBackgroundColor: "#FFFF00",
labelBorderColor: "black",
labelBorderSize: "1px",
fontColor: "black",
fontWeight: "bold",
fontSize: "12px",
fontFamily: "Courier New, monospace"
},OpenLayers.Feature.Vector.style["default"]),{
context:{
getName: function(f) {
if (f.attributes['typeName']=='wpt') {
return f.attributes['name'];
}
return '';
}
}
}),
"select": new OpenLayers.Style(
OpenLayers.Util.applyDefaults({
fillColor: "#FF9900",
fillOpacity: 0.75,
strokeColor: "#FFFF00",
strokeWidth: 4,
pointRadius: 12
},OpenLayers.Feature.Vector.style["select"])) |
Partager