我是 Javascript 和传单的初学者。首先我制作了geojson.js
这样的文件
var data={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 1,
"properties": {
"Name": "Germany",
"description": "",
"timestamp": "",
"begin": "",
"end": "",
"altitudeMode": "clampToGround",
"tessellate": 1,
"extrude": -1,
"visibility": -1
},
"geometry": {
"type": "Point",
"coordinates": [
51.329219337279405,
10.454119349999928
]
}
}
]
}
并像这样访问他们的坐标
points[0] = data.features[0].geometry.coordinates[0];
points[1] = data.features[0].geometry.coordinates[1];
没关系,但我想制作几个 geojson,将它们存储在同一个文件夹中并通过 url 访问它们leaflet/geojson.js
,而不是通过 http 或 ajax。像这样的东西:
var data = $.getJSON( "leaflet/geojson.js", function(json) {
points[0] = json.features[0].geometry.coordinates[0];
})
我能做到吗?怎么做?
提前致谢!