0
Node.js/express.js에서 geojson 파일을 읽으려고합니다. 나는 싶어express.js에서 geojson 파일을로드하는 방법
var o = require('output.geojson');
app.get('/points.geojson', function(req, res) {
res.json(o);
console.log(res)
});
을 express.js를 사용하여로드 (또는 적어도 JSON이 함수 내에서 렌더링) JSON.parse.But를 내가 싶어 사용하지 않는 "output.geojson"읽고있다 그러나 나는이 무엇입니까 오류 :
Users/macbook/leaflet-geojson-stream/output.geojson:1
(function (exports, require, module, __filename, __dirname) { "type":"FeatureC
^
SyntaxError: Unexpected token :
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/macbook/leaflet-geojson-stream/example/server.js:15:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
geojson 파일은 다음과 같습니다.
{
"type": "FeatureCollection",
"features": [{
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-73.8283219965448, 40.8446061654002],
[-73.828397789942, 40.844583182304],
[-73.8285477331865, 40.8448132168025],
[-73.8284744943625, 40.8448401137412],
[-73.8283219965448, 40.8446061654002]
]
]
]
},
"type": "Feature",
, {
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-73.832361912256, 40.8488019205992],
[-73.832369554769, 40.8487286684528],
[-73.8327312374341, 40.8487518102579],
[-73.8327304815978, 40.8487590590352],
[-73.8327235953166, 40.8488250624279],
[-73.832361912256, 40.8488019205992]
]
]
]
},
"type": "Feature"
}
....
....
}
geojson 파일을로드하려면 어떻게해야합니까?