-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create fullscreen example and control
- Loading branch information
1 parent
be80bec
commit 4c5aff4
Showing
6 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
layout: example | ||
category: example | ||
title: View a fullscreen map | ||
description: Toggle between current view and fullscreen mode | ||
tags: | ||
- controls-and-overlays | ||
--- | ||
|
||
<div id='map'></div> | ||
|
||
<script> | ||
var map = new mapboxgl.Map({ | ||
container: 'map', // container id | ||
style: 'mapbox://styles/mapbox/outdoors-v9', //stylesheet location | ||
center: [11.294,43.807], // starting position | ||
zoom: 12 // starting zoom | ||
}); | ||
|
||
var fullscreen = new mapboxgl.Fullscreen({position: 'top-left' }); | ||
map.addControl(fullscreen); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
var Control = require('./control'); | ||
var browser = require('../../util/browser'); | ||
var DOM = require('../../util/dom'); | ||
var util = require('../../util/util'); | ||
var window = require('../../util/window'); | ||
|
||
module.exports = Fullscreen; | ||
|
||
function Fullscreen(options) { | ||
util.setOptions(this, options); | ||
} | ||
|
||
Fullscreen.prototype = util.inherit(Control, { | ||
options: { | ||
position: 'top-left' | ||
}, | ||
|
||
onAdd: function(map) { | ||
var className = 'mapboxgl-ctrl'; | ||
var container = this._container = DOM.create('div', className + '-group', map.getContainer()); | ||
|
||
this._fullscreenButton = DOM.create('button', (className + '-icon ' + className + '-fullscreen'), this._container); | ||
this._fullscreenButton.type = 'button'; | ||
this._fullscreenButton.addEventListener('click', this._onClickFullscreen.bind(this)); | ||
return container; | ||
}, | ||
|
||
_onClickFullscreen: function() { | ||
var mapContainer = map.getContainer(); | ||
if (mapContainer.requestFullscreen) { | ||
mapContainer.requestFullscreen(); | ||
} else if (mapContainer.mozRequestFullScreen) { | ||
mapContainer.mozRequestFullScreen(); | ||
} else if (mapContainer.webkitRequestFullscreen) { | ||
mapContainer.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); | ||
} else { | ||
} | ||
} | ||
}); |