Mapv 结合 Leaflet 地图使用

萝らか妹 提交于 2019-11-26 00:31:53

看了Mapv的源码才发现,它是支持 Leaflet 地图的,Mapv作者也是有和Leaflet地图结合的案例的,但是直接百度 “Mapv Leaflet” 却没有结果,为了补全这个空缺,所以写了这个博客

原文链接:https://github.com/huiyan-fe/mapv/blob/master/examples/leaflet

使用案例:

<!DOCTYPE html>
<html>

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

    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css">


    <style>
        html,
        body,
        #map {
            height: 100%;
            padding: 0;
            margin: 0;
        }
    </style>
</head>

<body>
    <div id="map"></div>


    <script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"></script>
    <script src="../../build/mapv.js"></script>
    <script>
        var map = L.map('map').setView([34.41583177128595, -102.17609405517578], 5);
        L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
            'subdomains': ['a', 'b', 'c', 'd', 'e']
        }).addTo(map);
        var randomCount = 300;
        var data = [];
        while (randomCount--) {
            data.push({
                geometry: {
                    type: 'Point',
                    coordinates: [-125.8 + Math.random() * 50, 30.3 + Math.random() * 20]
                },
                count: 30 * Math.random()
            });
        }
        var dataSet = new mapv.DataSet(data);
        var options = {
            fillStyle: 'rgba(255, 250, 50, 0.8)',
            globalCompositeOperation: "lighter",
            maxSize: 10,
            max: 30,
            shadowBlur: 30,
            shadowColor: 'rgba(255, 250, 50, 1)',
            draw: 'bubble'
        };

        //这一句是唯一和百度地图不同的一处
        var mapvLayer = mapv.leafletMapLayer(dataSet, options).addTo(map);
    </script>
</body>

</html>

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!