Question

I'm learning javascript and started to mess around with mapbox.js example: Layers

and did this on my github

what I'm trying to do is to add line and markers with one click. How can I define, and use, a group?

Was it helpful?

Solution

I got an email from the fabolous staff at mapbox, and I was able to change my code and use groups

    //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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top