• leaflet入门(一)示例


    代码示例:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <style>
            #mapDiv {
                /*必须指定高度*/
                height: 900px;
            }
        </style>
        <!--leaflet样式文件-->
        <link rel="stylesheet" href="./js/lib/leaflet/leaflet.css" />
        <!--leaflet核心JS文件-->
    
        <script type="text/javascript" src="./js/lib/leaflet/leaflet.js"></script>
        <script type="text/javascript" src="./js/jquery-3.2.1.min.js"></script>
        <script>
    
        </script>
    
    </head>
    <body>
        <div id="mapDiv">
        </div>
    
        <!--脚本必须放在尾部-->
        <script>
            var map = L.map('mapDiv').setView([51.505, -0.09], 13);
            L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
                attribution: '&copy; <a href="http://osm.org/copyright">中科院数字与遥感研究所</a> contributors'
            }).addTo(map);
            var marker = L.marker([51.508, -0.09]).addTo(map);
            var circle = L.circle([51.508, -0.11], {
                color: 'red',
                fillColor: '#f03',
                fillOpacity: 0.5,
                radius: 500
            }).addTo(map);
            circle.bindPopup("I am a circle.");
            var polygon = L.polygon([
        [51.509, -0.08],
        [51.503, -0.06],
        [51.51, -0.047]
            ]).addTo(map);
    
            var popup = L.popup();
    
            function onMapClick(e) {
                popup
                    .setLatLng(e.latlng)
                    .setContent("You clicked the map at " + e.latlng.toString())
                    .openOn(map);
            }
    
            map.on('click', onMapClick);
    
        </script>
    
    </body>
    </html>
  • 相关阅读:
    博客园风格简单修饰(Do It Yourself)
    十大经典排序算法
    物流BOS
    算法设计
    牛客网刷题
    关于上网的问题
    Lucene&Solr
    SSM综合练习
    四十八:WAF绕过-权限控制之代码混淆及行为造轮子
    四十七:WAF绕过-漏洞发现之代理池指纹被动探针
  • 原文地址:https://www.cnblogs.com/tinaluo/p/7240712.html
Copyright © 2020-2023  润新知