[OpenLayers-Users] dynamic update of a legend with geoext

Gaëtan Palka palka.gaetan at gmail.com
Tue May 28 06:06:39 PDT 2013


Hello everybody,

I am building a dynamic webmapping. I am able to update layer and symboloy
of my map with openlayers but I am not able to update the legende that go
with.

My script to update map and legend through a choose in a list :

function changeBySelect(layerToRedraw) {
if (layerToRedraw == "alea"){
var layerNumber = 0;
}
if (layerToRedraw == "bati"){
var layerNumber = 1;
}
if (layerToRedraw == "routes"){
var layerNumber = 2;
}
if (layerToRedraw == "croisements"){
var layerNumber = 3;
}
if (layerToRedraw == "ZRO"){
var layerNumber = 4;
}
if (mappanel.map.getZoom() == 10){
var layerScale = 0;
}
if (mappanel.map.getZoom() == 11){
var layerScale = 1;
}
if (mappanel.map.getZoom() == 13){
var layerScale = 2;
}
if (mappanel.map.getZoom() == 14){
var layerScale = 3;
}
var param_index = "choix_"+layerToRedraw;
var index = document.getElementById(param_index).selectedIndex;
var coordonnee_zoom_02 = coordonnee_zoom[0][2];
var coordonnee_zoom_12 = coordonnee_zoom[1][2];
var coordonnee_zoom_22 = coordonnee_zoom[2][2];
var coordonnee_zoom_32 = coordonnee_zoom[3][2];
var vectorName = liste_layer[layerNumber][layerScale][index][0];
var vectorUrl = liste_layer[layerNumber][layerScale][index][1];
var styleName = liste_layer[layerNumber][layerScale][index][0];
var styleRule = liste_layer[layerNumber][layerScale][index][2];
vector = new OpenLayers.Layer.Vector(vectorName, {
isBaseLayer: false,
strategies:[new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: vectorUrl,
format:new OpenLayers.Format.GML()
}),
styleMap: new OpenLayers.StyleMap({
default: new OpenLayers.Style2({
name: styleName,
rules: styleRule
})
})
});
if (index == 0) {
mappanel.map.removeLayer(vector);
} else {
mappanel.map.addLayer(vector)
}
};

liste_layer is a javascript list of list of list ... containing the values.

Thank you for you help.

Gaëtan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130528/12afd089/attachment.html>


More information about the Users mailing list