码迷,mamicode.com
首页 > 其他好文 > 详细

leaflet叠加图片图层

时间:2020-02-17 14:25:53      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:oom   max   int   ocs   styles   按钮   char   属性控件   切换   

<!DOCTYPE html>
<html>
<head>

    <title>Layers Control Tutorial - Leaflet</title>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />

    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
    <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>


    <style>
        html, body {
            height: 100%;
            margin: 0;
        }
        #map {
            width: 1000px;
            height: 700px;
        }
    </style>


</head>
<body>

<div id=‘map‘></div>

<script>

    var grayscaleLayer= L.tileLayer(http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}, {id: map11,maxZoom: 16,minZoom: 4});

    var map = L.map(map, {
        minZoom: 5,
        maxZoom: 12,
        center: [39.73, -104.99],
        zoom: 10,
        zoomDelta: 0.5,//点击+-按钮的放缩刻度尺度,默认值1
        zoomSnap: 0.5,//地图能放缩的zoom的最小刻度尺度,默认值1
        fullscreenControl: false,//全屏控件,不显示
        zoomControl: false,//放大缩小控件,不显示
        attributionControl: false//右下角属性控件,不显示
    });
    map.addLayer(grayscaleLayer);


    var imageBounds = [[0, 50], [61.148, 180]];//图片的经纬度范围,西南角点,东北角点(纬度、经度)
    var imageUrl=url;//图片的地址
    var imageLayer =L.imageOverlay(imageUrl, imageBounds,{opacity:0.8});//opacity是透明度
    map.addLayer(imageLayer);

    //如果imageLayer已经创建,后续只需要切换url即可
    if(imageLayer!=null)
    {
        imageLayer.setUrl(imageUrl);
    }
</script>



</body>
</html>

 

leaflet叠加图片图层

标签:oom   max   int   ocs   styles   按钮   char   属性控件   切换   

原文地址:https://www.cnblogs.com/tiandi/p/12321334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!