javascript - how to access dates stored inside the an indicator object? -
i have map application, , in interface, there combo box contains 5 indicators(hdi, life expectancy, ..,..,..). checked 'data' of each indicator using firebug 1.9.2, , found that, inside 'data' of each indicator name of indicator listed , inside there list of dates (1960.....up 2010) of these dates contains data according corresponding indicator , of these dates contains no data "".
what want is, check dates of each indicator , if date contains data or value, want store date otherwise nothing date.
please see snap shots post maybe give clearer perception want do.
also please see how tried achieve goal, unfortunately result not want:
function getyearsbyindicator(layername, indicator) { var matchinglayers; var vectorlayer; var yearstore; // vector layer matchinglayers = map.getlayersbyname(layername); if (matchinglayers.length == 1) { vectorlayer = matchinglayers[0]; } else { console.log("getthematicstylemap: warning, layer " + layername + " not found!"); return; } (var i=0;i < vectorlayer.features.length;i++) { if (vectorlayer.features[i]['data'][indicator]) { // extract keys here! } } //build store containing extracted keys //return store return yearstore; }

since object, guess can access by:
$data->{propertyname} edit: confused, guess using javascript instead of php (which 1 of tags). when using javascript, can access values accessing arrays, variable["property"]["subproperty"] etc
edit2: can check using
if(data["hdi"][1980] != "") { //date not empty } edit3: iterate on content using:
for(var key in data["hdi"]) { //key 1980 etc if(data["hdi"][key] != "") { //date not empty } }
Comments
Post a Comment