Giter VIP home page Giter VIP logo

leaflet.fullscreen's Introduction

Leaflet.fullscreen

A HTML5 fullscreen plugin for Leaflet.

Usage

To provide a button for toggling fullscreen on and off:

// Create a new map with a fullscreen button:
var map = new L.Map('map', {
    fullscreenControl: true,
    // OR
    fullscreenControl: {
        pseudoFullscreen: false // if true, fullscreen to page width and height
    }
});

// or, add to an existing map:
map.addControl(new L.Control.Fullscreen());

The plugin also adds several methods to L.Map which are always available, even if you choose not to use the fullscreen button:

map.isFullscreen() // Is the map fullscreen?
map.toggleFullscreen() // Either go fullscreen, or cancel the existing fullscreen.

// `fullscreenchange` Event that's fired when entering or exiting fullscreen.
map.on('fullscreenchange', function () {
    if (map.isFullscreen()) {
        console.log('entered fullscreen');
    } else {
        console.log('exited fullscreen');
    }
});

Localization

To change fullscreen control text:

map.addControl(new L.Control.Fullscreen({
    title: {
        'false': 'View Fullscreen',
        'true': 'Exit Fullscreen'
    }
}));

Including via CDN

Leaflet.fullscreen is available through the Mapbox Plugin CDN - just copy this include:

<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' />

Building

npm install && make

ProTip You may want to install watch so you can run watch make without needing to execute make on every change.

Supported Leaflet Versions

Leaflet 1.0 and later is supported. Earlier versions may work, but are not tested.

leaflet.fullscreen's People

Contributors

alekzonder avatar casioo avatar drakkins avatar giuly90 avatar ivansanchez avatar jeyb avatar jfirebaugh avatar leemark avatar mpschaeuble avatar tmcw avatar zuck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet.fullscreen's Issues

IE11 Native Fullscreen Popups

I've tried adding native IE11 fullscreen support to the plugin.
I know it isn't a part of the release, but I hope you guys are still willing to help.

Problems

  1. Popups are not placed directly above the markers
  2. Leaflet is not giving the popups the correct width. Results in content overflowing the popup

ie11fullscreen

I've used the following methods and events to add native IE11 fullscreen support:
msRequestFullscreen
msExitFullscreen
msFullscreenElement
MSFullscreenChange

IE11 seems to be going fullscreen, and I'm just having difficulties with the popups

map.toggleFullscreen() doesn't do anything when called

I'm trying to get a Leaflet map to enter fullscreen mode a few seconds after everything has loaded. map.toggleFullscreen(); seems to do nothing when I call it in 0.0.3. I've also tried using jQuery to "click" the fullscreen button with jQuery('.leaflet-control-fullscreen-button').trigger('click');.

I've tested this in both Firefox and Chrome and it does not work in either upon load. If I manually click the fullscreen button with the mouse, it works just fine and as expected. Any ideas why this would be the case?

Please add support for this in bower.

Currently this package is not supported through bower. I see bower.json is missing after installing via git path. This restricts the automation through bower.

Bower support

Could you add this plugin to the bower repository?

Cheers
Adam

Demo doesn't load tiles.

Tiles do not load at http://leaflet.github.io/Leaflet.fullscreen/

http://c.tiles.mapbox.com/v4/examples.map-i86l3621/4/5/6.png?access_token=pk.eyJ1IjoiZXhhbXBsZXMiLCJhIjoiOTZQTkFkcyJ9.0DKk_5HaToBWqNOJqCwB-g
Failed to load resource: the server responded with a status of 401 (Unauthorized)

Time for a fresh API key?

Tweaking "zoomToBoundsOnClick" behaviour of marker clusters

Bear with me here, this is hard to explain!

While "zoomToBoundsOnClick" is very close to what I'd like when a user clicks a cluster, it can often result in zooming too far, too fast for the user to keep their geographic bearings.

For example, if two markers are 100km apart, they'll be clustered at zoom level 2, and a click will take the user straight to zoom level 14 (or something like that) with the two markers at the edges of the zoom extent. Using the "disableClusteringAtZoom" and "maxClusterRadius" option helps for many markers cluster scenarios, but not necessarily all.

What I would like to be able to specify would be a "ZoomToBoundsOnClickAdjustment" where I could add a zoom level factor to subtract from the result of the ZoomToBounds calculation. This would allow a user to always have at least some geographic context after clicking, regardless of the initial or final zoom levels or the separation of the markers.

Thanks for your time.

Jay

fullscreenchange event was not correctly listened

In init hook, you try to listen map's 'load' event.

L.Map.addInitHook(function () {
    ...skip...
    this.on('load', function () {
        L.DomEvent.on(document, fullscreenchange, this.

However, 'load' event may fired before init hooks are invoked.

leaflet's Map.js

                 if (options.center && options.zoom !== undefined) {
                         this.setView(L.latLng(options.center), options.zoom, {reset: true});
                 }
                 ...skip...
                 this.callInitHooks();

(setView() will fire 'load')
Thus, fullscreen control will not receive fullscreenchange event if center and zoom are defined.

I'm not sure this is bug of leaflet or Leaflet.fullscreen.

Leaflet 1.0-rc1. After escaping full screen all layers invisible

Hello,
Issue only occurs with Chrome/Chromium.
I don't know if this is my bug, plugin bug or leaflet bug.
I have map with fullscreen plugin and geojson layers added.

When I escaping from fullscreen I have gray bar in the bottom of the map and all layers not visible.
After resizing web browser window everything is ok.
This is normal view:
zrzut ekranu z 2016-07-07 21-56-57

This is fullscreen:
zrzut ekranu z 2016-07-07 21-57-14

This is after escaping from fullscreen:
zrzut ekranu z 2016-07-07 21-57-21

When I resize window, everything is ok.

Can you help me with that? Maybe there is some function that I can invoke in javascript so chrome will rerender window...

Supported leaflet versions

As the release of Leaflet 1.0 is nearly final now:
Maybe you could add a note to the README which leaflet versions currently are supported by your plugin. That would help users who plan to update from Leaflet 0.7.x to 1.0. :)

fullscreen button & iframes

a user of my plugin reported that the fullscreen button does not work if the map is loaded within an iframe. Is there anything that can be done about this?
thx,
Robert

new retina fullscreen icon is not centered

thanks for the update regarding retina fullscreen icon and the support for different icon status depeding on current status (fullscreen on / off).

I just noticed, that the icon is not correctly aligned on retina displays:

retina-fullscreen-icon-not-centered

I fixed this by changing the css for retina fullscreen icon to

@media
(-webkit-min-device-pixel-ratio:2), (min-resolution:192dpi) {
.leaflet-control-fullscreen a {
background-image:url(images/[email protected]);
background-position: 2px 2px;
}
.leaflet-fullscreen-on .leaflet-control-fullscreen a {
background-position:2px -24px;
}
}

Leaflet Control Stops Working in Ember App

Initially the control will work normally. After entering new routes in the application, the control appears to stop working at some point. Basically, you can enter fullscreen, but once in fullscreen, you cannot use the fullscreen control (button) to exit. You can however hit the escape key to exit. The image on the fullscreen button remains unchanged after entering fullscreen, as if it never entered fullscreen, and the "fullscreenchange" event never fires either. I've tested the app with a separate fullscreen leaflet control (https://github.com/brunob/leaflet.fullscreen) and the control appears to work all the time, so I'm not certain that it's due to how I've set up my ember component.

screen shot 2014-10-12 at 11 59 57 am

Conflict with mapbox.geocoderControl in Safari

Showing a map on full screen disables a mapbox.geocoderControl in Safari (v9.0 in OS X 10.11).

To reproduce, see this example: http://bl.ocks.org/fitnr/raw/47d0c8d1653c88dc7ac5/. Click to make full screen, then try to use the geocoder.

This is obviously a Safari bug, but I wanted to drop it here just in case someone can find an easy fix.

Suggestion: add fallback styles for IE 8

I added this to leaflet.ie.css - otherwise on IE 8 (or smaller), the fullscreen image is on a transparent background - see image below:

mapbox-fullscreen-ie8-styles-fallback

.leaflet-control-fullscreen a { background: #eeeeee; background-image: url("images/fullscreen.png"); background-position: center center; background-repeat: no-repeat; border: #999 2px solid; }

Retina icon?

Looks like there's only a 1x icon. @jfirebaugh do you have a vector image or a 2x that we can use to make this not look blurry on a retina machine?

Leaflet.fullscreen issues with Internet Explorer 11 ?

I am using Leaflet.fullscreen in my WordPress plugin Maps Marker Pro - a user now reported that the fullscreen button does not work properly in IE11. His site is http://www.timebranding.com/ - map at the bottom. If he clicks on the fullscreen button, the map is only partially shown in fullscreen:

fullscreen-issue

I did some tests with other maps too and found, that fullscreen is working properly with Internet Explorer 8, 9 and 10 - only 11 is causing that issue.

Any hints on how to approach this issue would be very appreciated!

No response on Apple devices

The Leaflet.fullscreen works as-expected on Windows and Android devices, however it does not work on Apple devices (iPad and iPhone) across multiple browsers (e.g. Safari and Chrome).

However, using developer tools in emulation mode the button works as-expected.

Anyone else encounter this as well, or know why this may be happening?

Master branch + tags

Could you please, create a master branch ? The gh-pages is used for demo / website not to host the sources.

Also could you please create tags per release ?

Theses are common patterns to follow when you release a package so I can easily get a specific release.

Thanks.

CSS Issue

Fullscreen with 'pseudoFullscreen': false didnt work as it should in chrome (didn't test other browsers)

faulty line
.leaflet-container.leaflet-fullscreen-on {

was a space missing

should be

.leaflet-container .leaflet-fullscreen-on {

then it all works

t.addTo is not a function

Hi, I tried map.addControl(L.Control.Fullscreen);, but Firefox console gives me t.addTo is not a function. The fullscreen button is not added to the map.

I cannot use the fullscreenControl: true option because I want to add the fullscreen button only in a specific case.

Centering fullscreen icons in touch environment

When a touch enabled device is detected, leaflet controls increase slightly in size causing the fullscreen icons to be off center.

I think I have a workable solution by adding the following 2 styles at the end of the style sheet, but it seems like there should maybe be a better one out there.

.leaflet-touch .leaflet-control-fullscreen a {
background-position: 2px 2px;
}

.leaflet-touch.leaflet-fullscreen-on .leaflet-control-fullscreen a {
background-position: 2px -24px;
}

Removing control does not remove listeners

When the control is added to a map, it adds a listener to fullscreenchange. When the control is removed, this listener is not removed and when the event fires, the listener throws since this._map is null.

fullscreenElement doesn't get changed if map is refreshed

I use leaflet3.js and leaflet-fullscreen-min.js In map, I have fullscreen control button to toggle between maximize and minimize. If page reloads, everthing works fine. But if only map div reloads, fullscreenElement doesn't get updated with new div.

This reference states that - If there's more than one element in the full-screen mode element stack, then this property returns the top element.

So when map div refreshes, fullscreenElement doesn't get updated with new one. This is a bug in leaflet3.js

when map in minimized state, it displays maximize icon (This is ok)
screenshot_2017-06-08_10-52-25
So once map is maximized, icon doesn't change to minimize button
screenshot_2017-06-08_10-56-26
Problem is, fullscreenElement doesn't get changed if a page has more than one map (ie. div reloads with same map again which is not reflected in fullscreenElement).

What would be the solution for this?

fullscreen map not full size

a user of my plugin reported, that when clicking on the fullscreen button, the map doesnt go fullscreen and only displays as large the initial map.
See a demo a htttp://www.livecamcroatia.com/kamere/
I guess this might be a conflict with his theme, as on other installations, the fullscreen button works perfectly with my plugin.
Any hint is appreciated!
thx,

Robert

Keep inputs on top of the map

Good morning,
I am using the fullscreen plugin and really like it. For a specific project, i would need to keep some of my inputs (one date picker, 3 dropdown lists) on top of the full screen map.
I tried to play with the z-index but got no success.

<div class="row-fluid">
                    <div class="span12">               
                        <div class="form-inline" id="MyForm">
                            <label class="control-label">Date4 </label>                                               
                            <input class="datepicker input-small form-control" id="Nb4" placeholder="Today" value="" type="text"/>

                            <label class="control-label" style="padding-left:10px;">Title1: </label>                                  
                            <select id="Nb1" class="input-medium form-control"></select>

                            <label class="control-label" style="padding-left:10px;">Title2: </label>                                  
                            <select id="Nb2" class="input-large form-control"></select> 

                            <label class="control-label" style="padding-left:10px;">Title3: </label>                                      
                            <select id="Nb3" class="input-medium form-control"></select>                             
                        </div> 
                    </div>          
                </div>

Any directions would be really welcome

Sylvain

optimized fullscreen icon

I saved the image fullscreen.png with photoshop for web usage - this reduced its size from 7kb to 1kb:

leaflet fullscreen

Adding an interval between click and ...

hi...thanks for the useful plugin. Is there any way to add a little interval between the time the button is clicked versus the fullscreen taking effect? I know this might not be as straightforward because actions such as fullscreen can only be invoked by user interaction. So timers and stuff are out. Any pointers? This is because I need to do a few things before going fullscreen ... and if there is no delay everything appears too abrupt. Thanks once again

jslint SyntaxError: invalid property id

jslint (http://www.javascriptlint.com/online_lint.php) and yui compressor ( http://refresh-sf.com/yui/ ) raises a syntax error with the using of reserved word false/true as property id

1 L.Control.Fullscreen = L.Control.extend({
2 options: {
3 position: 'topleft',
4 title: {
5 false: 'View Fullscreen',
============^
SyntaxError: invalid property id
6 true: 'Exit Fullscreen'
7 }
8 },
9

And may be it could be better to store images in an "images" folder.

A correct yui compressor parsing and an images folder get easier the concatenation of css and js files from leaflet plugins.

issue with using using fullscreen on multiple maps

I implemented Leaflet.fullscreen in my WordPress mapping plugin www.mapsmarker.com. A user now reported that there is an issue when multiple maps are present on one page - only the first one is working correctly when clicking the fullscreen button; on all other maps, the map tiles only gets loaded partially.
His maps can be found at http://www.diekracks.org/karten/

I tried to find the issue for this but failed. Any idea, what could be causing this?
Thx for any help!
Robert

Modal window does not appear on fullscreen mode

Maybe this is not your problem. But i want to explain my problem. After chrome and firefox updates, the modal window doesn't appear on top of the page when i switched to fullscreen mode. Can any one help me?

Map disappearing on closing full-screen with multiple maps

I'm not sure how to describe the problem effectively, but let me try. I have a page with two maps on it. Both have a working full-screen button. With the first map, leaving full-screen works fine and takes me back to the page with two maps, but with the second map, it's not OK. After leaving full-screen, the first map is hidden from the page and only the second map is shown.

So I have two map divs:

<div id="tsmap_1" class="leaflet-container leaflet-fade-anim" style="width: 640px; height: 480px; max-width: 100%; position: relative;" tabindex="0"></div>
<div id="tsmap_2" class="leaflet-container leaflet-fade-anim" style="width: 640px; height: 480px; max-width: 100%; position: relative;" tabindex="0"></div>

According to Firebug, when I click the full screen button on either map, the class parameter of the first map is changed to "leaflet-container leaflet-fade-anim leaflet-fullscreen-on", but the correct map is shown in full-screen. When leaving full-screen from the first map, the 'leaflet-fullscreen-on' class is removed and all is well, but when leaving full-screen from the second map, the class is not removed, the first map-div remains invisible and only the second map (whose class parameter was never changed) is visible.

Also, when entering full-screen for the second map, the button-icon is not changed to the 'leave' icon (with the little square in the middle), like it is on the first map.

So, it seems something is wrong with the selection of the map container when manipulating the DOM, but I can't tell what's wrong by looking at the code. Not enough JavaScript skillz I'm afraid.

The behaviour is the same in FF 34 and Chrome 39 on Windows.

Invalidate map size on fullscreen toggle

On my map I'm using a GeoJSON layer and custom CSS margin to locate it on the page.

When I switch to fullscreen mode, the GeoJSON layer doesn't display shapes correctly, still taking in consideration the old CSS margin (but actually removed by CSS when the map is fullscreen).

The only fix I found is to fire a map.invalidateSize() when the fullscreenchange event is emitted.

full screen z-index issue

When I make a map fullscreen, it automatically takes z-index of a very high value, because there is CSS on the user agent level (Chrome in my case):

webkit-full-screen: 24354663;

This causes any other div on my map to be hidden. Is there a way to avoid this?

Suggestion: hide fullscreen button on Android

I checked your demo map on Android 4.2.2/Nexus with Chrome and Firefox - fullscreen mode doesnt work here.
Is there a way to hide the button if pseudo-fullscreen-mode is also not supported?
Thx,

fullscreen image not displaying - issue with leaflet 0.5.1?

First thanks for your plugin!

I tried to integrate it into my plugin here: http://pro.mapsmarker.com/?p=11
Although I followed the instructions from the readme.txt, it didnt work :-/ As you can see from the screenshot below, the fullscreen control gets added below the zoom control, but unfortunately the background-image defined in leaflet.css is not displayed:

fullscreen-bug

Could this be an issue with leaflet 0.5.1?
I´d thankful for any hint on how to solve this!
thanks,

Robert

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.