I want to get the features from my layer. So I'm requesting WMSGetFeatureInfo method after a successful request for GetFeatureInfo on my layer. The returned object is structured like this:
I can read values like BEVDICHTE with var bevdichte = features.BEVDICHTE
and so on.
But when I want to get the value of the_geom with var the_geom = features.the_geom
it returns an object. Yes it is nested so this is intended but my question is how to get the value ol.geom.MultiPoint
from the_geom
?
EDIT:
Unfortunately var target = features.the_geom['actualEventTarget_'];
will just return another 'actualEventTarget_'
object. This is because the the_geom object is nested into infinity. I attached another screenshot to describe my problem. There are many more nested eventTargets following. Yet I was not able to get the property ol.geom.MultiPolygon.
答案 0 :(得分:0)
To access a nested array, just use brackets: '[ ]'
var nestedArray = [[1,2], [3,4]];
var nestedArrayValue = nestedArray[0][0];
// --> returns 1
With your example:
var target = features.the_geom['actualEventTarget_']
By the way, from the looks of it var the_geom = features.the_geom
doesn't seem like an array. It has keys, mapped to a value, are you sure this is an array, not an object?