Tema: Valores null
Ver Mensaje Individual
  #8 (permalink)  
Antiguo 15/06/2011, 13:23
Tetide
 
Fecha de Ingreso: octubre-2010
Ubicación: Costa Brava
Mensajes: 58
Antigüedad: 13 años, 6 meses
Puntos: 2
Respuesta: Valores null

este es el codigo, previamente he puesto los datos de presupuesto en "dades_indicador"

IncRadi=5;

ranges = dades_indicador.rangs;
colors = dades_indicador.colors;
var context = {
getColor: function(feature) {
for (var i = 1; i < ranges.length; i++){
if (dades_indicador[feature.attributes.id] < ranges[i]){
return colors[i];
}}

if (dades_indicador[feature.attributes.id] >= ranges[ranges.length -1]){
return colors[ranges.length]}
},

radius: function(feature) {
for (var i = 0; i < ranges.length; i++){
if (feature.attributes.value < ranges[i]){
return IncRadi*(i+1);
}
}

if (feature.attributes.value >= ranges[ranges.length -1]){
return IncRadi*(i+1);
}
}
};
var template = {
fillColor: "${getColor}", // using context.getColor(feature)
//pointRadius: "${radius}",
fillOpacity: ".85",
strokeColor:"black",
strokeWidth:1};
var style = new OpenLayers.Style(template, {context: context});
var styleMap = new OpenLayers.StyleMap({'default': style});//, select: {fillColor: "333333"}, hover: {fillColor: "333333"}});