【发布时间】:2014-08-30 04:21:50
【问题描述】:
我是使用 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());
【问题讨论】:
-
图层的投影是否与地图相同?
-
所有图层都在同一个投影中。当格式从新的 OpenLayers.Layer.Vector 更改为新的 OpenLayers.Layer.WMS 时,它们可以显示在地图上。但是,这只会使它们成为基础地图层
标签: javascript openlayers