zoukankan      html  css  js  c++  java
  • leaflet简单例子,绘制多边形

    var crs = L.CRS.EPSG900913;
        var map = L.map('map', {
            crs: crs,
             '100%',
            height: '100%',
            maxZoom: 17,
            editable: true,
            renderer: new L.SVG()
        }).setView([34, 108.5], 4);
    
        var options = {
            minNativeZoom: 14,
            minZoom: 2,
            maxZoom: 18
        };
    
        var google_sat = L.layerGroup([
            L.tileLayer.fallback(Configures.map_services+'/tile/google_sat/{z}/{x}/{y}', options),
            L.tileLayer.fallback(Configures.map_services+'/tile/google_name/{z}/{x}/{y}', options)
        ]);
        var osm_MapQuestOpen = L.tileLayer.fallback(Configures.map_services+'/tile/osm_MapQuestOpen/{z}/{x}/{y}', options);
        L.control.layers({'谷歌影像': google_sat,'osm_MapQuestOpen': osm_MapQuestOpen}).addTo(map);
        map.addLayer(google_sat);
    
        var drawnItems = new L.FeatureGroup();
        map.addLayer(drawnItems);
        L.drawLocal.draw.toolbar.buttons.polygon = '绘制区域';
        var drawControl = new L.Control.Draw(
            {
                position: 'topleft',
                draw:{
                    polyline:false ,
                    polygon: true,
                    circle: false,
                    rectangle:false,
                    marker: false
                },
                edit: {
                    featureGroup: drawnItems,
                    edit:false,
                    remove: false
                }
            });
        map.addControl(drawControl);
        L.drawLocal.draw=
        {
            handlers: {
                polygon: {
                    tooltip: {
                        start: '鼠标点击绘制多边形',
                        cont: '单击继续绘制',
                        end: '单击起始点或双击完成编辑'
                    }
                }
            }
        };
        map.on('draw:created', function(event) {
            //var type = event.layerType;
            var layer = event.layer;
            alert(JSON.stringify(layer.toGeoJSON()));
        });
    View Code
  • 相关阅读:
    解决win8无法成功安装Windows Phone 7 sdk的问题
    决定专心写博,学习
    时间管理的首要原则:专注力
    Windows Phone 7 开发环境的搭建
    Windows Phone 8 开发环境的搭建
    学习使用ErrorProvider 转载
    SetTimer函数
    网络工程课程笔记
    IP地址分类及特殊IP地址
    windows消息处理机制
  • 原文地址:https://www.cnblogs.com/Micang/p/6346486.html
Copyright © 2011-2022 走看看