data = [
{org_code: "02000001", org_name: "xx第一xx", longitude: 106.775072, dimension: 39.228335, fault_type: 0}
{org_code: "02000002", org_name: "xx第二xx", longitude: 106.376647, dimension: 39.026369, fault_type: 1}
{org_code: "02000004", org_name: "xx中xx", longitude: 106.371674, dimension: 39.000489, fault_type: 1}
{org_code: "02003001", org_name: "xx第五xx", longitude: 106.369803, dimension: 39.02657, fault_type: 2}
{org_code: "02003023", org_name: "xx人民xx", longitude: 106.721961, dimension: 39.13457, fault_type: 0}
{org_code: "02210001", org_name: "平罗xx", longitude: 106.550778, dimension: 38.914817, fault_type: 0}
{org_code: "02210002", org_name: "平罗xx中xx", longitude: 106.531575, dimension: 38.926376, fault_type: 1}
]
js:
var geoCoordMap = {}
datares.map(
function(value) {
return geoCoordMap[value.org_code] = [value.longitude,value.dimension]
}
)
结果:
geoCoordMap = {
"02000001":[106.775072, 39.228335],
"02000002":[106.376647, 39.026369],
"02000004":[106.371674, 39.000489],
"02003001":[106.369803, 39.02657],
"02003023":[106.721961, 39.13457],
"02210001":[106.550778, 38.914817],
"02210002":[106.531575, 38.926376]
};
lodash:
let geoCoordMap = {}
_.map(data, item => {
geoCoordMap[item.org_name] = [item.longitude, item.dimension]
})
console.log(geoCoordMap)