Skip to content

Instantly share code, notes, and snippets.

@fritzvd
Created March 26, 2014 14:06
Show Gist options
  • Select an option

  • Save fritzvd/9783888 to your computer and use it in GitHub Desktop.

Select an option

Save fritzvd/9783888 to your computer and use it in GitHub Desktop.
leaflet quasi fullscreen on ie
// This is a customisation of a real plugin
// and lives here, purely for reference
L.Control.FullScreen = L.Control.extend({
options: {
position: 'topleft'
},
onAdd: function (map) {
console.info('this is not even fired');
var containerClass = 'leaflet-control-zoom', className, container;
if(map.zoomControl) {
container = map.zoomControl._container;
className = '-fullscreen leaflet-bar-part leaflet-bar-part-bottom last';
// Update class of the zoom out button (Leaflet v0.5)
if (map.zoomControl._zoomOutButton) {
L.DomUtil.removeClass(map.zoomControl._zoomOutButton, 'leaflet-bar-part-bottom');
}
} else {
container = L.DomUtil.create('div', containerClass);
className = '-fullscreen';
}
this._createButton('Full Screen', containerClass + className, container, window.toggleFullScreen, map);
return container;
},
_createButton: function (title, className, container, fn, context) {
var link = L.DomUtil.create('a', className, container);
link.href = '#';
link.title = title;
L.DomEvent
.addListener(link, 'click', L.DomEvent.stopPropagation)
.addListener(link, 'click', L.DomEvent.preventDefault)
.addListener(link, 'click', fn, context);
return link;
},
toogleFullScreen: function () {
// this has become obsolete. See utilities.js window.toggleFullScreen
// also this is spelled incorrectly :)
},
_handleEscKey: function () {
if(!fullScreenApi.isFullScreen(this) && !this._exitFired){
this.fire('exitFullscreen');
this._exitFired = true;
}
}
});
window.toggleFullScreen = function () {
if (window.mapFullScreen) {
var fullScreenMap = document.getElementById('full-screen-map');
fullScreenMap.remove();
Lizard.mapView.fullScreenRegion.close();
var lonlatzoom = window.location.hash.split('#map/')[1].split(',');
var leafletView = new Lizard.Views.Map({
lon: lonlatzoom[0],
lat: lonlatzoom[1],
zoom: lonlatzoom[2],
workspace: Lizard.workspaceView.getCollection()
});
Lizard.mapView.leafletRegion.show(leafletView.render());
Lizard.Map.ddsc_layers = new Lizard.geo.Layers.DdscMarkerLayer({
collection: locationCollection,
map: leafletView
});
} else {
var fullScreenMap = document.getElementById('full-screen-map');
if (fullScreenMap === null) {
fullScreenMap = document.createElement('div');
fullScreenMap.id = 'full-screen-map';
var container = document.getElementById('content').parentNode;
container.parentNode.insertBefore(fullScreenMap, container);
}
fullScreenMap.style.cssText = "position: absolute; width: 100%; height:100%;";
Lizard.mapView.leafletRegion.close()
var lonlatzoom = window.location.hash.split('#map/')[1].split(',');
var leafletView = new Lizard.Views.Map({
lon: lonlatzoom[0],
lat: lonlatzoom[1],
zoom: lonlatzoom[2],
workspace: Lizard.workspaceView.getCollection(),
container: 'full-screen-map'
});
fullScreenMap.style.zIndex = "1000";
Lizard.mapView.fullScreenRegion.show(leafletView.render());
Lizard.Map.ddsc_layers = new Lizard.geo.Layers.DdscMarkerLayer({
collection: locationCollection,
map: leafletView
});
}
window.mapFullScreen = !window.mapFullScreen;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment