在地图框js上使用图层组

时间:2014-04-24 10:52:35

标签: openlayers mapbox

我正在学习javascript并开始乱用mapbox.js示例:Layers

并在github

上完成此操作

我要做的是只需点击一下即可添加线条和标记。如何定义和使用组?

1 个答案:

答案 0 :(得分:1)

我收到了来自mapbox的fabolous员工的电子邮件,我能够更改我的代码并使用组

    //Create variables
var map = L.mapbox.map('map','lucamoiana.i2f5jfg2').setView([45.642, 8.954], 14);
var ristori = L.mapbox.featureLayer('lucamoiana.i09fgicl');
var corto = L.mapbox.tileLayer('lucamoiana.i057npjm');
var corto_ristoro = L.mapbox.featureLayer('lucamoiana.i057npjm');
var medio = L.mapbox.tileLayer('lucamoiana.i0588kkf');
var medio_ristoro = L.mapbox.featureLayer('lucamoiana.i0588kkf');
var lungo = L.mapbox.tileLayer('lucamoiana.i058i92l');
var lungo_ristoro = L.mapbox.featureLayer('lucamoiana.i058i92l');
var parcheggi = L.mapbox.featureLayer('lucamoiana.i2f34pn3');

//addLayer
addLayer(L.mapbox.featureLayer('lucamoiana.i2f34pn3'), 'Parcheggi', 1);

//addGroup
addLayer(L.layerGroup([corto, corto_ristoro]), '6 Km', 5);
addLayer(L.layerGroup([medio, corto_ristoro, medio_ristoro]), '14 Km', 4);
addLayer(L.layerGroup([lungo, corto_ristoro, lungo_ristoro]), '20 Km', 3);