<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>图层的透明度调节</title>
<meta name="description" content="对图层进行透明度调节。setOpacity(value)">
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<div class="input-card" style="width: auto;">
<div>
<label>图层透明度:</label><span id="opa-val">-</span>
<br>
<input id="opacity" type="range" value="0.6" min="0" max="1" step="0.01" oninput="setOpacity(this.value)" onchange="setOpacity(this.value)">
</div>
</div>
<script src="https://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值&plugin=Map3D"></script>
<script>
var map = new AMap.Map('container', {
resizeEnable: true,
center: [116.40, 39.91],
features: ['road', 'bg'],
zoom: 13
});
var opacity = 0.6;
var satellite = new AMap.TileLayer.Satellite({
map: map,
opacity: opacity
});
updateOpa(opacity);
function updateOpa(v) {
document.getElementById('opa-val').innerText = v;
}
function setOpacity(val) {
updateOpa(val);
satellite.setOpacity(val);
}
</script>
</body>
</html>
订阅评论
0 评论