簡體   English   中英

傳單離線網格層

[英]Leaflet offline grid layer

我希望傳單可以脫機工作,沒有標題,只顯示一個網格作為標題。 要具有Leaflet的所有功能,請添加插件以繪制線條,固定標記,繪制多邊形,放大/縮小形狀等。

有沒有簡單的方法來顯示簡單的網格?

這是一個自定義GridLayer (已經由Leaflet作者實現了)。 您所需要做的就是復制L.GridLayer.DebugCoords ,在此通常可以加載切片圖層。

var map = L.map('map', {
    center: [0, 0],
    zoom: 0
});

L.GridLayer.DebugCoords = L.GridLayer.extend({
    createTile: function (coords, done) {
        var tile = document.createElement('div');
        //this adds tile coordinates; you may or may not want this
        tile.innerHTML = [coords.x, coords.y, coords.z].join(', ');
        tile.style.outline = '1px solid red';

        /* // you don't need this artificial timeout for your application
        setTimeout(function () {
                done(null, tile);   // Syntax is 'done(error, tile)'
        }, 500 + Math.random() * 1500);
        */

        return tile;
    }
});

L.gridLayer.debugCoords = function(opts) {
    return new L.GridLayer.DebugCoords(opts);
};

map.addLayer( L.gridLayer.debugCoords() );

獨立的工作示例: http : //leafletjs.com/examples/extending/gridcoords.html

代碼取自: http : //leafletjs.com/examples/extending/extending-2-layers.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM