高德地图 JS API示例-三方标准图层- ›XYZ栅格图层

高德地图 JS API示例-三方标准图层- ›XYZ栅格图层

使用TileLayer.getTileUrl自定义栅格图。

<!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>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
    <style>
        html,
        body,
        #container {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
<div class="input-card" style="width: auto;">
    <div class="input-item">
        <button class="btn" onclick="addXYZTileLayer()">叠加XYZ图层</button>
    </div>
    <div class="input-item">
        <button class="btn" onclick="map.remove(xyzTileLayer)">移除XYZ图层</button>
    </div>
</div>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
<script>
    var map = new AMap.Map('container', {
        resizeEnable: true,
        layers: [new AMap.TileLayer.Satellite()]
    });

    var xyzTileLayer = new AMap.TileLayer({
        // 图块取图地址
        getTileUrl: 'https://wprd0{1,2,3,4}.is.autonavi.com/appmaptile?x=[x]&y=[y]&z=[z]&size=1&scl=1&style=8&ltype=11',
        zIndex: 100
    });

    // 添加图层
    function addXYZTileLayer() {
        map.add(xyzTileLayer);
    }
</script>
</body>
</html>
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x