我有一个 geoJSON 文件,其中包括:
{
"type": "FeautureCollection",
"features": [
{
"type": "Feature",
"id": "1",
"geometry": {
"type": "Point",
"coordinates": [
5.709531,
50.855802
]
}
},
{
"type": "Feature",
"id": "2",
"geometry": {
"type": "Point",
"coordinates": [
5.709426,
50.855798
]
}
}
]
}
这个 JSON 文件是在一个 php 脚本中构建的:
$ret = array();
$ret['type'] = "FeautureCollection";
$ret['features'] = array();
$f = array();
$f['type'] = 'Feature';
$f['id'] = $p['id'];
$f['geometry'] = array();
$f['geometry']['type'] = 'Point';
$f['geometry']['coordinates'] = array(floatval($p['lat']), floatval($p['lon']));
$ret['features'][] = $f;
echo json_encode($ret);
当我尝试通过 polymaps.org 框架加载它时,没有显示任何点。除了加载地图的标准内容外,我还使用此 javascript 来解析 geoJSON。
map.add(po.geoJson()
.url('geojson/c.geo.php')
.id('test')
);
CSS如下,所以点应该看起来像一个红圈:
#test {
fill: lightcoral;
fill-opacity: .5;
stroke: brown;
}
奇怪的是,当我将 geojson 文件指针更改为由 GIS 应用程序构建的文件时,它可以工作。所以我敢打赌我的 geoJSON 已损坏。但是当我通过http://jsonlint.com/运行它时,它会验证。
有谁知道这怎么可能?