openlayer 加载天地图为地图,同时加载arcgisserver发布的wms
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0″>
<meta name=”apple-mobile-web-app-capable” content=”yes”>
<title>OpenLayers MapQuest Demo</title>
<link rel=”stylesheet” type=”text/css” href=”theme/default/style.css”/>
<style type=”text/css”>
html, body, #map{
padding:0;
margin:0;
height:100%;
width:100%;
}
</style>
<script type=”text/javascript” src=”OpenLayers.js”></script>
<script type=”text/javascript”>
var map;
function init(){
function getBaseLayer(layername, layer){
return new OpenLayers.Layer.XYZ(
layername,
[
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”
],
{
isBaseLayer: true,
displayInLayerSwitcher:true
}
);
};
function getAnnoLayer(layername, layer, visiable){
return new OpenLayers.Layer.XYZ(
layername,
[
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”,
“http://t0.tianditu.com/DataServer?T=”+layer+”&X=${x}&Y=${y}&L=${z}”
],
{
isBaseLayer: false,
visibility:visiable,
displayInLayerSwitcher:false
}
);
};
var baseLayers = [“vec_c”,”img_c”,”ter_c”];
var vecLayer = getBaseLayer(“地图”,baseLayers[0]);
var imgLayer = getBaseLayer(“影像”,baseLayers[1]);
var terLayer = getBaseLayer(“地形”,baseLayers[2]);
var vecAnno = getAnnoLayer(“地图标注”, “cva_c”, true);
map = new OpenLayers.Map({
div: “map”,
projection: “EPSG:4326”,
layers: [vecLayer,imgLayer,terLayer],
numZoomLevels:20,
center: [103.847, 36.0473],
zoom: 4
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
var wms = new OpenLayers.Layer.WMS(
“GPS”,
“http://192.168.106.33:6080/arcgis/services/OpenlayerPoint/MapServer/WMSServer”,
{
LAYERS: “2”,
transparent:true
},
{
singleTile: false,
ratio: 1,
isBaseLayer: false,
visibility:true,
yx : {‘EPSG:4326’ : true}
}
);
map.addLayer(wms);
map.addLayers([vecAnno]);
}
</script>
</head>
<body onload=”init()”>
<div id=”map”></div>
</body>
<html>
转载自:https://blog.csdn.net/wk2133/article/details/70844637