openlayers - 在开放层中显示多个层2
问题描述
我正在使用开放层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
它会在几秒钟内消失,只显示一层
解决方案
如果你想看到顶层下面的基础层,顶层需要一些不透明度,你也可以尝试让WMS的白色背景透明,例如
wms = new OpenLayers.Layer.WMS("iran",
"http://localhost:8080/geoserver/wms/",
{LAYERS:'python:iran_location', transparent: true},
{opacity: 0.5, isBaseLayer:false});
推荐阅读
- sql - 在事务问题中删除/创建触发器 - 触发器会在之后运行吗
- r - R`object not found`错误dplyr select当变量存在时
- scala - 有没有办法在 Scala 中使用两个并行迭代器创建一个 for 循环?
- c - 在内核模块中获取 NFS 客户端 IP 地址
- c# - IBM Watson Unity SDK,IamAuthenticator 对象无法成功认证
- aws-glue - 如何使用不同的步骤和配置创建 AWS 胶水工作流(不使用控制台)?
- java - 在 Android Studio 项目中使用 htmlunit 时,没有 Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier 类型的静态字段实例
- django - 如何隐藏已在 Django Admin 的复选框中选择的项目
- ios - 为什么第一个 EditText 视图不能正常工作,但它下面的视图却可以?
- octave - Octave 5.2.0 GUI:突然找不到 strcat(和其他命令)(以前起作用)