OSM - Leaflet - 将折线转换为图像/图块

时间:2018-04-12 20:48:48

标签: javascript leaflet openstreetmap tile polyline

我有一张带有非常复杂的折线(大约300 k节点)的传单地图,这使得它非常重。

有没有办法将这些折线转换为图像格式(图块?),这些图像将显示在传单基本地图上并大大加快处理速度?

BR, 西蒙

function init() {
         var map = new L.map('map', {
    center: [46.634 ,2.373],
    zoom: 4
    });                       

         L.tileLayer('https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=###', {
            attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
            maxZoom: 18
         }).addTo(map);
         map.attributionControl.setPrefix(''); // Don't show the 'Powered by Leaflet' text.

         //Define an array of Latlng objects (points along the line)
var polylineOptions = {
               color: 'blue',
               weight: 3,
               opacity: 0.9
             };


    var way1626206 = [
    new L.LatLng(58.3354616,15.1455364),
    new L.LatLng(58.3360446,15.1457141),
    new L.LatLng(58.3364476,15.1458118),
    new L.LatLng(58.3368139,15.1459143),
    new L.LatLng(58.3372234,15.1459975),
    new L.LatLng(58.3380975,15.1460381),
    new L.LatLng(58.339002,15.1459897),
    new L.LatLng(58.339663,15.1457799),
    new L.LatLng(58.3402414,15.145495),
    new L.LatLng(58.3411902,15.1447415),
    new L.LatLng(58.3422411,15.1436215),
    new L.LatLng(58.3433313,15.1419505),
    new L.LatLng(58.3464673,15.136081),
    new L.LatLng(58.3508979,15.1277296),
    ];

        var polyline1626206 = new L.Polyline(way1626206, polylineOptions);
        map.addLayer(polyline1626206); 

    var way1880525 = [
    new L.LatLng(58.8387802,15.1597595),
    new L.LatLng(58.8403013,15.1603979),
    new L.LatLng(58.8438679,15.1618516),
    new L.LatLng(58.8450863,15.1623291),
    new L.LatLng(58.8457607,15.1625329),
    new L.LatLng(58.8462741,15.1626027),
    new L.LatLng(58.846732,15.1626939),
    new L.LatLng(58.8473453,15.1627368),
    new L.LatLng(58.8479307,15.1627217),
    ];

0 个答案:

没有答案