我有一个错误,指出data.forEach不是一个函数。该代码是:对于每个循环---> For循环
function getProperGeojsonFormat(data) {
isoGeojson = {"type": "FeatureCollection", "features": []};
console.log("After getProperGeojsonFormat function")
console.log(data)
console.log("")
data.forEach(function(element, index) {
isoGeojson.features[index] = {};
isoGeojson.features[index].type = 'Feature';
isoGeojson.features[index].properties = element.properties;
isoGeojson.features[index].geometry = {};
isoGeojson.features[index].geometry.coordinates = [];
isoGeojson.features[index].geometry.type = 'MultiPolygon';
element.geometry.geometries.forEach(function(el) {
isoGeojson.features[index].geometry.coordinates.push(el.coordinates);
});
});
$rootScope.$broadcast('isochrones', {isoGeom: isoGeojson});
}
我得到的错误是:
当我控制台日志数据:
这取决于数据是否是一个数组与否。 –
a [mcve]会很棒! –
他们已经帮你 – zerkms