I have a function in php:
public static function getGeoJSON() {
// code that generates geojson from mysql
return $geojson;
}
In javascript i call this function:
var geo = JSON.parse( '<?php echo json_encode($geo) ?>' );
//this is where I want to put my generated geojson instead of a file.geojson
d3.json('point.geojson', function(geojson){
mapDraw(geojson);
});
like this I want it:
// replace static file with generated geojson
d3.json(geo, function(geojson){
mapDraw(geojson);
});
I have printed the generated geojson and pasted it into a json file and it works. but when I try to put the
var geo
as reference instead of the path it fails. Does anyone know why?
Thanks in advance.
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[xx.xxx,xx.xxx]},"properties":{"description":"bad description"}}]}