在打开的图层中显示多个图层2

时间:2020-12-29 18:55:13

标签: openlayers

我使用的是开放层2

这是我的代码

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>webgis</title>
    <script type="text/javascript" src="OpenLayers.js"></script>
    <style>
div {
  height: 641px;
}
</style>
  </head>
  <body>
<div id="map" style="">
    <script type="text/javascript">
    map = new OpenLayers.Map("map",{projection:new OpenLayers.Projection("EPSG:900913")})
    osmLayer=new OpenLayers.Layer.OSM("OSM")
    map.addLayer(osmLayer)
    map.setCenter([0,0],1)
    controls=[new OpenLayers.Control.OverviewMap(),
    new OpenLayers.Control.MousePosition(),
    new OpenLayers.Control.LayerSwitcher()]
    map.addControls(controls)
    wms=new OpenLayers.Layer.WMS("iran",
    "http://localhost:8080/geoserver/wms/",
    {LAYERS:'python:iran_location'},
    {isBaseLayer:false});
    map.addLayer(wms)
    </script>
</div>
  </body>
</html>

所以当我打开浏览器时

首先显示openstreetmap

它会在几秒钟内消失,只显示一层

enter image description here

1 个答案:

答案 0 :(得分:1)

如果你想看到顶层下面的底层,顶层需要一些不透明度,你也可以尝试使WMS的白色背景透明,例如

wms = new OpenLayers.Layer.WMS("iran",
"http://localhost:8080/geoserver/wms/",
{LAYERS:'python:iran_location', transparent: true},
{opacity: 0.5, isBaseLayer:false});
相关问题