-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathYandex.addon.Panorama.js
42 lines (39 loc) · 1.68 KB
/
Yandex.addon.Panorama.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Here is just one of possible ways to integrate
// panoramas player with leaflet map, avoiding controls conflicts.
// It's function is to take player out of map and put it into separate element.
// @option panorama: Boolean or String = undefined
// If true then activates panorama manager using custom handler.
// Set option value to 'enableLookup' in order to enable panorama layer on load.
// Otherwise it's possible to do it later (programmatacally, or with `typeSelector` control).
L.Yandex.addInitHook(function () {
var defaults = this._controlOptionsDefault;
if (!this.options.panorama || !defaults) { return; }
this._controlOptionsDefault = L.extend({}, defaults, {
typeSelector: L.extend({}, defaults.typeSelector, {panoramasItemMode: 'on'})
});
});
L.Yandex.addInitHook('on', 'load', function () {
if (!this.options.panorama) { return; }
this._yandex.getPanoramaManager().done(function (manager) {
manager._playerOptions = {
hotkeysEnabled: true,
controls: ['closeControl','panoramaName','zoomControl']
};
if (this.options.panorama === 'enableLookup') { manager.enableLookup(); }
manager.events.add('openplayer',function () {
var leafletKeys = this._map.keyboard;
if (leafletKeys) { leafletKeys.disable(); }
var player = manager.getPlayer();
player._engine._toggleFullscreen();
player.events.add('fullscreenexit', function () {
setTimeout(manager.closePlayer.bind(manager));
});
if (this._isOverlay) { this._yandex.setType('yandex#map'); }
player.events.add('destroy', function () {
if (this._isOverlay) { this._yandex.setType(this._mapType()); }
this._resyncView();
if (leafletKeys) { leafletKeys.enable(); }
},this);
},this);
},this);
});