fix #17
This commit is contained in:
parent
d878501070
commit
8cc9a67215
@ -12,6 +12,7 @@ var Hashroute = {
|
||||
|
||||
map.on('zoomend', updateHash)
|
||||
map.on('moveend', updateHash)
|
||||
map.on('baselayerchange', updateHash)
|
||||
updateHash();
|
||||
},
|
||||
|
||||
|
@ -5,9 +5,11 @@ function LayerManager(layers, map){
|
||||
this.currentLayer = layers[0];
|
||||
this.layers = layers;
|
||||
|
||||
var self = this;
|
||||
|
||||
map.on('baselayerchange', function (e) {
|
||||
console.log("baselayerchange", e.layer);
|
||||
//TODO
|
||||
self.setLayerId(e.layer.layerId);
|
||||
});
|
||||
|
||||
}
|
||||
@ -17,6 +19,10 @@ LayerManager.prototype.setLayerId = function(layerId){
|
||||
this.layers.forEach(function(layer){
|
||||
if (layer.id == layerId){
|
||||
self.currentLayer = layer;
|
||||
self.listeners.forEach(function(listener){
|
||||
listener(layer);
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
var RealtimeTileLayer = L.TileLayer.extend({
|
||||
|
||||
initialize: function(wsChannel, layerId) {
|
||||
initialize: function(wsChannel, layerId, map) {
|
||||
var self = this;
|
||||
this.layerId = layerId;
|
||||
|
||||
@ -12,7 +12,7 @@ var RealtimeTileLayer = L.TileLayer.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
if (tc.zoom != self._map.getZoom()){
|
||||
if (tc.zoom != map.getZoom()){
|
||||
//ignore other zoom levels
|
||||
return;
|
||||
}
|
||||
|
@ -23,12 +23,13 @@ api.getConfig().then(function(cfg){
|
||||
|
||||
//All layers
|
||||
cfg.layers.forEach(function(layer){
|
||||
var tileLayer = new RealtimeTileLayer(wsChannel, layer.id);
|
||||
var tileLayer = new RealtimeTileLayer(wsChannel, layer.id, map);
|
||||
layers[layer.name] = tileLayer;
|
||||
});
|
||||
|
||||
//current layer
|
||||
layerMgr.getCurrentLayer().addTo(map);
|
||||
var currentLayer = layerMgr.getCurrentLayer();
|
||||
layers[currentLayer.name].addTo(map);
|
||||
|
||||
//All overlays
|
||||
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
|
||||
|
Loading…
Reference in New Issue
Block a user