我是使用HTML创建地图的新手,我一直在尝试添加两个矢量层(地点,点)到基础地图(道路),但我看不到地图上的矢量层。图层应以矢量叠加的形式显示在底图上。层显示在层切换器中,但不显示在屏幕上。我认为问题出在调用向量层的方式上。要显示矢量层的解决方案是什么?谢谢
var map = new OpenLayers.Map("map-id");
var roads= new OpenLayers.Layer.WMS(
"roads",
"http://localhost:8080/geoserver/wms",
{layers: "roads"});
var points= new OpenLayers.Layer.Vector(
"points",
"http://localhost:8080/geoserver/wms",
{layers: "points"});
var places= new OpenLayers.Layer.Vector(
"places",
"http://localhost:8080/geoserver/wms",
{layers: "places"});
map.addLayer(roads);
map.addLayer(points);
map.addLayer(places);
map.addControl(new OpenLayers.Control.LayerSwitcher());发布于 2012-04-16 12:42:53
您正在尝试通过WMS协议显示矢量数据。为此,您应该使用OpenLayers.Layer.WMS实例而不是OpenLayers.Layer.Vector。要将WMS图层显示为覆盖,请使用isBaseLayer选项:
map = new OpenLayers.Map('map');
var places = new OpenLayers.Layer.WMS('places',
"http://localhost:8080/geoserver/wms",
{layers: "places", transparent: true},
{isBaseLayer: false, opacity: 1, singleTile: true, visibility: true}
);
map.addLayers([places]);https://stackoverflow.com/questions/10162694
复制相似问题