zhongrj
2025-11-24 276323dce9613867abb3f58a4cc2abbfb2fd0dea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PluginsAPI.Map.willAddControls([
        'contours/build/Contours.js',
        'contours/build/Contours.css'
    ], function(args, Contours){
    var tasks = [];
    var ids = {};
    
    for (var i = 0; i < args.tiles.length; i++){
        var task = args.tiles[i].meta.task;
        if (!ids[task.id]){
            tasks.push(task);
            ids[task.id] = true;
        }
    }
 
    // TODO: add support for map view where multiple tasks are available?
    if (tasks.length === 1){
        args.map.addControl(new Contours({map: args.map, tasks: tasks}));
    }
});