Laze

If I rest I rust !

  博客园  :: 首页  :: 新随笔  ::  ::  :: 管理

Arcgis api for javascript学习笔记(3.2x版本)-Map图层叠加以及基本操作

1. 不设置默认底图,第一个图层作为底图,然后叠加另外一个图层

先添加图层1,第一个图层1作为默认底图,然后在图层1上叠加图层2,并设置图层2的透明度为50%。

<!DOCTYPE html>
<html>
<head>
<title>simple demo</title>
<link rel="stylesheet" href="http://localhost:8003/arcgis_js_v320_api/library/3.20/3.20/esri/css/esri.css">
<style type="text/css">
html, body { margin: 0; padding: 0; height: 100%; width: 100%; }
#viewDiv { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="viewDiv"></div>
<script src="http://localhost:8003/arcgis_js_v320_api/library/3.20/3.20/init.js"></script>
<script type="text/javascript">
require([
"esri/map",
"esri/layers/ArcGISTiledMapServiceLayer",
"dojo/domReady!"],
function (Map, ArcGISTiledMapServiceLayer) {
var map = new Map("viewDiv");
var tms1 = new ArcGISTiledMapServiceLayer("http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer"); //图层1
map.addLayer(tms1);
var tms2 = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Projected_Population_Change/MapServer", { "opacity": 0.5 }); //图层2,透明度50%
map.addLayer(tms2);
}
);
</script>
</body>
</html>

效果如下:

posted on 2017-11-29 09:24  CollinTsui  阅读(857)  评论(0)    收藏  举报