JavaScript - How to use Map instead of For Loop -


i want use map instead of loop in example. have csv files contains data

csv file address,type,building,geometry "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example"  var geojsonfeature;  var globaldata= data.map(function(d){return json.parse(d.geometry);}); var buildingdata= data.map(function(d){return json.parse(d.type);});   (i=0;i<globaldata.legnth;i++) { geojsonfeature = {         "type": "feature",         "properties": {             "name": buildingdata[i]         },         "geometry": {             "type": "multipolygon",             "coordinates": globaldata[i].coordinates         }     };   listgeodata.push(geojsonfeature)  } 

i wanted replace for-loop map "listgeodata" way.

this assumes listgeodata empty prior for loop.

var listgeodata = globaldata.map(function(data,i) {   return {     "type": "feature",     "properties": {       "name": buildingdata[i]     },     "geometry": {       "type": "multipolygon",       "coordinates": data.coordinates     }   }; }); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -