1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| function DisplayStat(){
//var fields = flds;
var data = {
table: str,
fields: fields,
};
$.ajax({ url:"get_map_prod.php",
data: data,
success: function(data){
alert("a");
//if (data) {
//var production=data.production;
var dataArray = data.split(", ;");
dataArray.pop();
dataArray.forEach(function(d){
d = d.split(", ");
var feature = {
"type": "Feature",
"properties": {}, //properties object container
"geometry": JSON.parse(d[fields.length]) //parse geometry
};
alert ("c");
for (var i=0; i<fields.length; i++){
feature.properties[fields[i]] = d[i];
};
geojson.features.push(feature);
}
);
alert("b");
hangry2();
}
});
}
function hangry2(){
console.log(geojson);
var statistique = new ol.style.Style({
fill: new ol.style.Fill({
color: [0,0,0,1]
}),
stroke: new ol.style.Stroke({
color: [240,215,255,1],
width: 1
})
});
vector1 = new ol.layer.Vector({
title: 'Mes statistiques',
source: new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojson),
//url: 'ilot.geojson',
format: new ol.format.GeoJSON(),
}),style: statistique
});
map.addLayer(vector1);
} |
Partager