# L7 Layer

Note

The L7 layer is provided as a plugin. Load its script via vjmap.addScript({src: "js/l7.js"}).

# Getting Started

// Add the L7 library below. For L7 usage, refer to the L7 official documentation https://l7.antv.vision/zh
if (typeof L7 !== "object") {
    // If the deck environment is not available
    await vjmap.addScript({
        src: "js/l7.js"
    });

}

const waveLayer = new L7.PointLayer({ zIndex: 2, blend: 'additive' })
    .source(
        [
            { lng: 0, lat: 0, size: 10000 },
        ],
        {
            parser: {
                type: 'json',
                x: 'lng',
                y: 'lat'
            }
        }
    )
    .shape('circle')
    .color('#00F8F9')
    .size('size', v => v / 100.0)
    .animate(true)
    .style({
});

scene.on('loaded', () => {
    scene.addLayer(waveLayer);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

For detailed usage, refer to the L7 (opens new window) official documentation

# Example



#

(async () => {
    // --Light pillars and path animation--
// JavaScript code
// Create map service object with service URL and token
    let svc = new vjmap.Service(env.serviceUrl, env.accessToken)
// Open map
    let res = await svc.openMap({
        mapid: env.exampleMapId, // Map ID (ensure this ID exists; you can upload new graphics to create one)
        mapopenway: vjmap.MapOpenWay.GeomRender, // Open with geometry data rendering
        style: vjmap.openMapDarkStyle() // Use dark background style when div has dark background
    })
    if (res.error) {
        message.error(res.error)
    }
// Get map bounds
    let mapExtent = vjmap.GeoBounds.fromString(res.bounds);
// Create coordinate system
    let prj = new vjmap.GeoProjection(mapExtent);

// Create map object
    let map = new vjmap.Map({
        container: 'map', // container ID
        style: svc.rasterStyle(), // Raster tile style
        center: prj.toLngLat(mapExtent.center()), // Center point
        zoom: 2,
        pitch: 60,
        //minZoom: initZoom - 3,//Can set a minimum zoom level
        renderWorldCopies: false
    });
// Attach service object and coordinate system to map
    map.attach(svc, prj);
    map.setMaxBounds(map.toLngLat(prj.getMapExtent()));
// Enable click highlight (elements highlight when clicking on map elements)
    map.enableLayerClickHighlight(svc, e => {
        if (!e) return;
        let msg = {
            content: `type: ${e.name}, id: ${e.objectid}, layer: ${e.layerindex}`,
            key: "layerclick",
            duration: 5
        }
        e && message.info(msg);
    })

    let mousePositionControl = new vjmap.MousePositionControl({
        showZoom: true,
        showLatLng: true
    });
    map.addControl(mousePositionControl, "bottom-left");

    await map.onLoad();
    map.setRasterOpacity(svc.rasterLayerId(), 0.3);

    let c = map.getCenter()

// Add L7 library below. For L7 usage, refer to L7 official documentation https://l7.antv.vision/zh
    if (typeof L7 !== "object") {
        // If the deck environment is not available
        await vjmap.addScript({
            src: "js/l7.js"
        });

    }
// Create L7 scene below
    const scene = new vjmap.Scene(L7, map);

    const waveLayer = new L7.PointLayer({ zIndex: 2, blend: 'additive' })
        .source(
            [
                { lng: 0, lat: 0, size: 10000 },
            ],
            {
                parser: {
                    type: 'json',
                    x: 'lng',
                    y: 'lat'
                }
            }
        )
        .shape('circle')
        .color('#00F8F9')
        .size('size', v => v / 100.0)
        .animate(true)
        .style({
        });

    const barLayer = new L7.PointLayer({ zIndex: 2, depth: false })
        .source(
            [
                { lng: 0, lat: 0, size: 10000 },
            ],
            {
                parser: {
                    type: 'json',
                    x: 'lng',
                    y: 'lat'
                }
            }
        )
        .shape('cylinder')
        .color('#00F8F9')
        .size('size', v => [ 5, 5, v / 100 ])
        .active({
            color: 'red',
            mix: 0.0,
        })
        .animate(true)
        .style({
            opacityLinear: {
                enable: true, // true - false
                dir: 'up' // up - down
            },
            lightEnable: false
        });

    scene.addImage(
        'arrow',
        'https://gw.alipayobjects.com/zos/bmw-prod/ce83fc30-701f-415b-9750-4b146f4b3dd6.svg'
    );

    let data = {
        "type": "FeatureCollection",
        "name": "dl2",
        "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
        "features": [
            { "type": "Feature", "properties": { }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ -50, -30 ], [ 0, 0], [ 20, 40 ] ] ] } },
        ]}
    const layer = new L7.LineLayer({})
        .source(data)
        .size(10)
        .shape('line')
        .texture('arrow')
        .active(true)
        .color('#00F8F9')
        .animate({
            interval: 1, // Interval
            duration: 1, // Duration, delay
            trailLength: 2 // Flow line length
        })
        .style({
            opacity: 0.6,
            lineTexture: true, // Enable line texture
            iconStep: 10, // Set texture spacing
            borderWidth: 0.4, // Default 0, max 0.5
            borderColor: '#fff' // Default #ccc
        });

    layer.on('click', (e) => {
        console.log('click', e);
    });

    scene.on('loaded', () => {
        scene.addLayer(waveLayer);
        scene.addLayer(barLayer);
        scene.addLayer(layer);
    });
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156