openlayers天地图没有图片时会有红叉,设置背景色为透明

popup.autoSize = true;设置popup大小总不对,没找到原因,
解决办法:
将背景色设为透明:popup.setBackgroundColor(“transparent”);

使用天地图不知道为什么空白区域会出现没有图片的红叉?
暂时解决办法:
注释掉OpenLayers-2.12/OpenLayers.js里 this.onImageLoad()
[img]http://dl2.iteye.com/upload/attachment/0093/5166/1b7c5247-735f-3859-85a7-a7c14dee820b.png[/img]
红叉可以去掉了,不过底图空白区域还是会有白色,待完善

天地图:
var map;
var markers;
var option = {
controls: [new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar()
],
numZoomLevels: 19
};
map = new OpenLayers.Map(‘map’, option);
map.addControl(new OpenLayers.Control.LayerSwitcher());

var tdt1 = new OpenLayers.Layer.WMTS({
name: “中国底图(矢量)”,
url: “http://t0.tianditu.com/vec_c/wmts”, //中国底图
layer: “vec”,
style: “default”,
matrixSet: “c”,
format: “tiles”,
isBaseLayer: true
});
var tdt2 = new OpenLayers.Layer.WMTS({
name: “中国底图注记”,
url: “http://t0.tianditu.com/cva_c/wmts”, //中国底图注记
layer: “cva”,
style: “default”,
matrixSet: “c”,
format: “tiles”,
isBaseLayer: false
});
map.addLayers([tdt1, tdt2]);

map.setCenter(new OpenLayers.LonLat(115.86, 34.4), 12);
map.addControl(new OpenLayers.Control.MousePosition());
转载自:https://blog.csdn.net/diwuci123/article/details/84522919

You may also like...