leaflet叠加图片图层

Posted tiandi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leaflet叠加图片图层相关的知识,希望对你有一定的参考价值。

<!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叠加图片图层的主要内容,如果未能解决你的问题,请参考以下文章

基于Leaflet的VideoOverlay视频图层叠加实战

基于Leaflet的VideoOverlay视频图层叠加实战

leaflet结合geoserver利用WFS服务实现图层删除功能(附源码下载)

leaflet结合geoserver利用WFS服务实现图层新增功能(附源码下载)

如何在Leaflet ImageOverlay中使用base64字符串而不是URL

css怎么将文字叠加在图片上