我曾经像这样制作 GML 向量:
layer = new OpenLayers.Layer.GML("based",
"./parser2.php",
{
isBaseLayer: true,
format: OpenLayers.Format.GeoJSON,
styleMap: new OpenLayers.StyleMap(mystyle),
units:"m",
maxResolution: 0.2,
minResolution: 0.01
})
map.addLayer(layer);
但现在已经贬值了,因为我需要使用 OpenLayers.Layer.Vector 但我无法成功读取 geoJon 文件。我试过这样:
var test = new OpenLayers.Layer.Vector("test", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
isBaseLayer: true,
url: "data.json",
styleMap: myStyles,
format: new OpenLayers.Format.JSON()
})
});
map.addLayer(test);
但不幸的是它不起作用。
你有什么线索吗?
谢谢