I'm trying to toggle between geojson layers that were loaded using the filelayerload javascript. Right now I'm basically stuck on how to append the geojson layers to one variable once they have been loaded using filelayerload. My thought is by appending them to one variable ('overlayMaps' variable in the code below), I can just use L.controls.layer to set up the toggling. Here's my code so far:
//Main map layer: var mainmap =L.tileLayer( 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { attribution: '© '+mapLink+'. Tiles courtesy of '+mapquestLink+mapquestPic, maxZoom: 19, subdomains: '1234', }).addTo(map); var baseMaps = { "Base Layer": mainmap }; var overlayMaps = { }; L.Control.FileLayerLoad.LABEL = ''; //Loads external geojson file: var fileload = new L.Control.fileLayerLoad({ fileSizeLimit: 5000, fitBounds: true, //MOVE THE CENTER OF THE SCREEN layerOptions: { onEachFeature: function(feature, layer) { layer.bindPopup( "Name: " + feature.properties.Name); } } }).addTo(map); L.control.layers(baseMaps,overlayMaps).addTo(map);
أكثر...
//Main map layer: var mainmap =L.tileLayer( 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { attribution: '© '+mapLink+'. Tiles courtesy of '+mapquestLink+mapquestPic, maxZoom: 19, subdomains: '1234', }).addTo(map); var baseMaps = { "Base Layer": mainmap }; var overlayMaps = { }; L.Control.FileLayerLoad.LABEL = ''; //Loads external geojson file: var fileload = new L.Control.fileLayerLoad({ fileSizeLimit: 5000, fitBounds: true, //MOVE THE CENTER OF THE SCREEN layerOptions: { onEachFeature: function(feature, layer) { layer.bindPopup( "Name: " + feature.properties.Name); } } }).addTo(map); L.control.layers(baseMaps,overlayMaps).addTo(map);
أكثر...