merge master without the scaled tiles commit into stable
This commit is contained in:
commit
067b673ea4
36
CHANGELOG.md
36
CHANGELOG.md
@ -3,10 +3,28 @@ Leaflet Changelog
|
||||
|
||||
(all changes without author notice are by [@mourner](https://github.com/mourner))
|
||||
|
||||
## 0.7 (master)
|
||||
## 0.7-dev (master)
|
||||
|
||||
An in-progress version being developed on the master branch.
|
||||
|
||||
* Added `TileLayer` `maxNativeZoom` option that allows displaying tile layers on zoom levels above their maximum by **upscaling tiles**. [#1802](https://github.com/Leaflet/Leaflet/issues/1802) [#1798](https://github.com/Leaflet/Leaflet/issues/1798)
|
||||
* Fixed a regression where mouse interaction had incorrect coordinates in some map positioning cases (by [@scooterw](https://github.com/scooterw)). [#1826](https://github.com/Leaflet/Leaflet/issues/1826) [#1684](https://github.com/Leaflet/Leaflet/issues/1684) [#1745](https://github.com/Leaflet/Leaflet/issues/1745) [#1](https://github.com/Leaflet/Leaflet/issues/1)
|
||||
* Fixed a regression where `layerremove` and `layeradd` were fired before the corresponding action finishes (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1846](https://github.com/Leaflet/Leaflet/issues/1846)
|
||||
* Fixed a regression that prevented the map from responding to drag on areas covered with `ImageOverlay` (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1821](https://github.com/Leaflet/Leaflet/issues/1821)
|
||||
* Fixed a regression with `worldCopyJump: true` breaking the map on small zoom levels (by [@danzel](https://github.com/danzel)). [#1831](https://github.com/Leaflet/Leaflet/issues/1831)
|
||||
* Fixed a bug where `TileLayer.Canvas` wasn't immediately redrawn when `redraw` is called (by [@tofferrosen](https://github.com/tofferrosen)). [#1797](https://github.com/Leaflet/Leaflet/issues/1797) [#1817](https://github.com/Leaflet/Leaflet/issues/1817)
|
||||
|
||||
## 0.6.2 (June 28, 2013)
|
||||
|
||||
* Fixed a bug that caused wrong tile layers stacking order when using opacity < 1 (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1804](https://github.com/Leaflet/Leaflet/issues/1804) [#1790](https://github.com/Leaflet/Leaflet/issues/1790) [#1667](https://github.com/Leaflet/Leaflet/issues/1667)
|
||||
* Fixed a regression that caused tiles selection when double-clicking absolutely positioned maps with vector layers in it in Firefox (WTF!) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1807](https://github.com/Leaflet/Leaflet/issues/1807)
|
||||
* Fixed a regression with a wrong cursor when dragging a map with vector layers, and tiles becoming selected on double click (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1800](https://github.com/Leaflet/Leaflet/issues/1800)
|
||||
* Fixed a regression that caused flickering of tiles near map border on zoom animation in Chrome.
|
||||
|
||||
## 0.6.1 (June 27, 2013)
|
||||
|
||||
* Fixed a regression with mouse wheel zooming too fast on Firefox (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1788](https://github.com/Leaflet/Leaflet/issues/1788)
|
||||
* Fixed a regression with broken zooming on maps with EPSG3395 projection. [#1796](https://github.com/Leaflet/Leaflet/issues/1796)
|
||||
* Fixed a bug where zoom buttons inherited Bootstrap link hover styles. [#1791](https://github.com/Leaflet/Leaflet/issues/1791)
|
||||
|
||||
## 0.6 (June 26, 2013)
|
||||
@ -15,6 +33,7 @@ An in-progress version being developed on the master branch.
|
||||
|
||||
* Moved polyline editing code into [Leaflet.draw](https://github.com/Leaflet/Leaflet.draw) plugin (where it fits much better along with all other editing and drawing handlers). The API remains the same.
|
||||
* Dropped support for environments that augment `Object.prototype` (luckily it's a thing of the past nowadays).
|
||||
* `Map` `invalidateSize` no longer fires `move` and `moveend` events if the map size didn't change. [#1819](https://github.com/Leaflet/Leaflet/issues/1819)
|
||||
|
||||
### Improvements
|
||||
|
||||
@ -116,22 +135,23 @@ An in-progress version being developed on the master branch.
|
||||
* Fixed a bug with `contextmenu` events on popups falling through to map (by [@snkashis](https://github.com/snkashis)). [#1730](https://github.com/Leaflet/Leaflet/issues/1730) [#1732](https://github.com/Leaflet/Leaflet/issues/1732)
|
||||
* Fixed `404` tile loading errors when browsing the map off the world bounds.
|
||||
* Fixed shifted mouse events in some cases with map inside a relatively positioned parent (by [@scooterw](https://github.com/scooterw) and [@jec006](https://github.com/jec006)). [#1670](https://github.com/Leaflet/Leaflet/issues/1670) [#1684](https://github.com/Leaflet/Leaflet/issues/1684) [#1745](https://github.com/Leaflet/Leaflet/issues/1745) [#1744](https://github.com/Leaflet/Leaflet/issues/1744)
|
||||
* Fixed a bug where tile layer z-index order sometimes broke after view reset. [#1422](https://github.com/Leaflet/Leaflet/issues/1422)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug with undesirable page scrolling in Firefox 17+ when you zoom the map by scrolling (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1789](https://github.com/Leaflet/Leaflet/issues/1789) [#1788](https://github.com/Leaflet/Leaflet/issues/1788)
|
||||
* Fixed a bug in Android where click was triggered twice on one tap (by [@jerel](https://github.com/jerel) & [@mourner](https://github.com/mourner)). [#1227](https://github.com/Leaflet/Leaflet/pull/1227) [#1263](https://github.com/Leaflet/Leaflet/issues/1263) [#1785](https://github.com/Leaflet/Leaflet/issues/1785) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
* Fixed a bug in Android where click on a collapsed layers control would immediately select one of the layers (by [@danzel](https://github.com/danzel)). [#1784](https://github.com/Leaflet/Leaflet/issues/1784) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
* Fixed a bug where `TileLayer` opacity didn't work in IE 7-8 (by [@javisantana](https://github.com/javisantana) & [@danzel](https://gi
|
||||
.com/danzel)). [#1084](https://github.com/Leaflet/Leaflet/issues/1084) [#1396](https://github.com/Leaflet/Leaflet/pull/1396) [#1371](https://github.com/Leaflet/Leaflet/issues/1371)
|
||||
* Fixed a bug where mouse coordinates where shifted in Firefox if the map was inside a positioned block on a scrolled page (by [@joschka](https://github.com/joschka)). [#1365](https://github.com/Leaflet/Leaflet/pull/1365) [#1322](https://github.com/Leaflet/Leaflet/issues/1322)
|
||||
* Fixed a bug where box zoom didn't work in some cases in Firefox 18+ (by [@fabriceds](https://github.com/fabriceds)). [#1405](https://github.com/Leaflet/Leaflet/pull/1405)
|
||||
* Fixed a bug where tile layer z-index order sometimes broke after view reset. [#1422](https://github.com/Leaflet/Leaflet/issues/1422)
|
||||
* Fixed a bug where `TileLayer` opacity didn't work in IE 7-8 (by [@javisantana](https://github.com/javisantana) & [@danzel](https://gi
|
||||
.com/danzel)). [#1084](https://github.com/Leaflet/Leaflet/issues/1084) [#1396](https://github.com/Leaflet/Leaflet/pull/1396) [#1371](https://github.com/Leaflet/Leaflet/issues/1371)
|
||||
* Fixed Leaflet not working correctly in PhantomJS (by [@rassie](https://github.com/rassie)). [#1501](https://github.com/Leaflet/Leaflet/pull/1501)
|
||||
|
||||
#### Mobile bugfixes
|
||||
|
||||
* Fixed a bug with layers control on WinPhone8/IE10 Touch (by [@danzel](https://github.com/danzel)). [#1635](https://github.com/Leaflet/Leaflet/pull/1635) [#1539](https://github.com/Leaflet/Leaflet/issues/1539)
|
||||
* Fixed a bug with click sometimes firing twice on WinPhone8/IE10 Touch (by [@danzel](https://github.com/danzel)). [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
|
||||
#### Mobil
|
||||
* Fixed a bug in Android where click was triggered twice on one tap (by [@jerel](https://github.com/jerel) & [@mourner](https://github.com/mourner)). [#1227](https://github.com/Leaflet/Leaflet/pull/1227) [#1263](https://github.com/Leaflet/Leaflet/issues/1263) [#1785](https://github.com/Leaflet/Leaflet/issues/1785) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
* Fixed a bug in Android where click on a collapsed layers control would immediately select one of the layers (by [@danzel](https://github.com/danzel)). [#1784](https://github.com/Leaflet/Leaflet/issues/1784) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
|
||||
#### API bugfixes
|
||||
|
||||
|
127
PLUGIN-GUIDE.md
Normal file
127
PLUGIN-GUIDE.md
Normal file
@ -0,0 +1,127 @@
|
||||
# Leaflet Plugin Authoring Guide
|
||||
|
||||
One of the greatest things about Leaflet is its powerful plugin ecosystem.
|
||||
The [Leaflet plugins page](http://leafletjs.com/plugins.html) lists dozens of awesome plugins, and more are being added every week.
|
||||
|
||||
This guide lists a number of best practices for publishing a Leaflet plugin that meets the quality standards of Leaflet itself.
|
||||
|
||||
1. [Presentation](#presentation)
|
||||
- [Repository](#repository)
|
||||
- [Name](#name)
|
||||
- [Demo](#demo)
|
||||
- [Readme](#readme)
|
||||
- [License](#license)
|
||||
2. [Code](#code)
|
||||
- [File Structure](#file-structure)
|
||||
- [Code Conventions](#code-conventions)
|
||||
- [Plugin API](#plugin-api)
|
||||
|
||||
## Presentation
|
||||
|
||||
### Repository
|
||||
|
||||
The best place to put your Leaflet plugin to is a separate [GitHub](http://github.com) repository.
|
||||
If you create a collection of plugins for different uses,
|
||||
don't put them in one repo —
|
||||
it's usually easier to work with small, self-contained plugins in individual repositories.
|
||||
|
||||
### Name
|
||||
|
||||
Most existing plugins follow the convention of naming plugins (and repos) like this: `Leaflet.MyPluginName`.
|
||||
You can use other forms (e.g. "leaflet-my-plugin-name"),
|
||||
just make sure to include the word "Leaflet" in the name so that it's obvious that it's a Leaflet plugin.
|
||||
|
||||
### Demo
|
||||
|
||||
The most essential thing to do when publishing a plugin is to include a demo that showcases what the plugin does —
|
||||
it's usually the first thing people will look for.
|
||||
|
||||
The easiest way to put up a demo is using [GitHub Pages](http://pages.github.com/).
|
||||
A good [starting point](https://help.github.com/articles/creating-project-pages-manually) is creating a `gh-pages` branch in your repo and adding an `index.html` page to it —
|
||||
after pushing, it'll be published as `http://<user>.github.io/<repo>`.
|
||||
|
||||
### Readme
|
||||
|
||||
The next thing you need to have is a descriptive `README.md` in the root of the repo (or a link to a website with a similar content).
|
||||
At a minimum it should contain the following items:
|
||||
|
||||
- name of the plugin
|
||||
- a simple, concise description of what it does
|
||||
- requirements
|
||||
- Leaflet version
|
||||
- other external dependencies (if any)
|
||||
- browser / device compatibility
|
||||
- links to demos
|
||||
- instructions for including the plugin
|
||||
- simple usage code example
|
||||
- API reference (methods, options, events)
|
||||
|
||||
### License
|
||||
|
||||
Every open source repository should include a license.
|
||||
If you don't know what open source license to choose for your code,
|
||||
[MIT License](http://opensource.org/licenses/MIT) and [BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause) are both good choices.
|
||||
You can either put it in the repo as a `LICENSE` file or just link to the license from the Readme.
|
||||
|
||||
## Code
|
||||
|
||||
### File Structure
|
||||
|
||||
Keep the file structure clean and simple,
|
||||
don't pile up lots of files in one place —
|
||||
make it easy for a new person to find their way in your repo.
|
||||
|
||||
A barebones repo for a simple plugin would look like this:
|
||||
|
||||
```
|
||||
my-plugin.js
|
||||
README.md
|
||||
```
|
||||
|
||||
An example of a more sophisticated plugin file structure:
|
||||
|
||||
```
|
||||
/src - JS source files
|
||||
/dist - minified plugin JS, CSS, images
|
||||
/spec - test files
|
||||
/lib - any external libraries/plugins if necessary
|
||||
/examples - HTML examples of plugin usage
|
||||
README.md
|
||||
LICENSE
|
||||
package.json
|
||||
```
|
||||
|
||||
### Code Conventions
|
||||
|
||||
Everyone's tastes are different, but it's important to be consistent with whatever conventions you choose for your plugin.
|
||||
|
||||
For a good starting point, check out [Airbnb JavaScript Guide](https://github.com/airbnb/javascript).
|
||||
Leaflet follows pretty much the same conventions
|
||||
except for using smart tabs (hard tabs for indentation, spaces for alignment)
|
||||
and putting a space after the `function` keyword.
|
||||
|
||||
### Plugin API
|
||||
|
||||
Never expose global variables in your plugin.<br>
|
||||
If you have a new class, put it directly in the `L` namespace (`L.MyPlugin`).<br>
|
||||
If you inherit one of the existing classes, make it a sub-property (`L.TileLayer.Banana`).<br>
|
||||
If you want to add new methods to existing Leaflet classes, you can do it like this: `L.Marker.include({myPlugin: …})`.
|
||||
|
||||
Function, method and property names should be in `camelCase`.<br>
|
||||
Class names should be in `CapitalizedCamelCase`.
|
||||
|
||||
If you have a lot of arguments in your function, consider accepting an options object instead
|
||||
(putting default values where possible so that users don't need specify all of them):
|
||||
|
||||
```js
|
||||
// bad
|
||||
marker.myPlugin('bla', 'foo', null, {}, 5, 0);
|
||||
|
||||
// good
|
||||
marker.myPlugin('bla', {
|
||||
optionOne: 'foo',
|
||||
optionThree: 5
|
||||
});
|
||||
```
|
||||
|
||||
And most importantly, keep it simple. Leaflet is all about *simplicity*.
|
224
debug/map/opacity.html
Normal file
224
debug/map/opacity.html
Normal file
@ -0,0 +1,224 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<style>
|
||||
.mapcontainer {
|
||||
float:left;
|
||||
position: relative;
|
||||
width: 32%;
|
||||
font-size: 12px;
|
||||
font-family: sans-serif;
|
||||
height: 340px;
|
||||
margin-bottom: 15px;
|
||||
background-color: #eee;
|
||||
margin-right: 1%;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 280px;
|
||||
bottom: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>These should all render identically.</p>
|
||||
<div class="mapcontainer">
|
||||
CASE 1: no opacity set on any layers
|
||||
<br />
|
||||
<div id="map1" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 2: opacity set to .99 on overlays but not on basemap
|
||||
<br />
|
||||
<div id="map2" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 3: opacity set on overlays but not on basemap, zIndex option set to 0 on basemap
|
||||
<br />
|
||||
<div id="map3" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 4: opacity set to .99 on overlays but set to 1 on basemap
|
||||
<br />
|
||||
<div id="map4" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 5: opacity set to .99 on all layers
|
||||
<br />
|
||||
<div id="map5" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 6: opacity set to .99 on 1st and 3rd layers and 1 on middle layer
|
||||
<br />
|
||||
<div id="map6" class="map"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var mapopts = {
|
||||
center: [35, -122],
|
||||
zoom : 5
|
||||
};
|
||||
|
||||
var map1 = L.map('map1', mapopts);
|
||||
var map2 = L.map('map2', mapopts);
|
||||
var map3 = L.map('map3', mapopts);
|
||||
var map4 = L.map('map4', mapopts);
|
||||
var map5 = L.map('map5', mapopts);
|
||||
var map6 = L.map('map6', mapopts);
|
||||
|
||||
/**********
|
||||
CASE 1: no opacity set on any layers
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm1 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941
|
||||
}).addTo(map1);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez1 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true
|
||||
}).addTo(map1);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa1 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false
|
||||
}).addTo(map1);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 2: opacity set on overlays but not on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm2 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941
|
||||
}).addTo(map2);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez2 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map2);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa2 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map2);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 3: opacity set on overlays but not on basemap, zIndex option set to 0 on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm3 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
zIndex: 0
|
||||
}).addTo(map3);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez3 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map3);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa3 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map3);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 4: opacity set on overlays but set to 1 on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm4 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 1
|
||||
}).addTo(map4);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez4 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map4);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa4 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map4);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 5: opacity set to .5 on all layers
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm5 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez5 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa5 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 6: opacity set to .5 on 1st and 3rd layers and 1 on middle layer
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm6 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 0.99
|
||||
}).addTo(map6);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez6 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 1
|
||||
}).addTo(map6);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa6 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map6);
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
149
dist/leaflet-src.js
vendored
149
dist/leaflet-src.js
vendored
@ -7,7 +7,7 @@
|
||||
var oldL = window.L,
|
||||
L = {};
|
||||
|
||||
L.version = '0.6';
|
||||
L.version = '0.6.2';
|
||||
|
||||
// define Leaflet for Node module pattern loaders, including Browserify
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
@ -1092,46 +1092,30 @@ L.DomUtil.TRANSITION_END =
|
||||
var userSelectProperty = L.DomUtil.testProp(
|
||||
['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);
|
||||
|
||||
var userDragProperty = L.DomUtil.testProp(
|
||||
['userDrag', 'WebkitUserDrag', 'OUserDrag', 'MozUserDrag', 'msUserDrag']);
|
||||
|
||||
L.extend(L.DomUtil, {
|
||||
disableTextSelection: function () {
|
||||
L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);
|
||||
if (userSelectProperty) {
|
||||
var style = document.documentElement.style;
|
||||
this._userSelect = style[userSelectProperty];
|
||||
style[userSelectProperty] = 'none';
|
||||
} else {
|
||||
L.DomEvent.on(window, 'selectstart', L.DomEvent.stop);
|
||||
}
|
||||
},
|
||||
|
||||
enableTextSelection: function () {
|
||||
L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);
|
||||
if (userSelectProperty) {
|
||||
document.documentElement.style[userSelectProperty] = this._userSelect;
|
||||
delete this._userSelect;
|
||||
} else {
|
||||
L.DomEvent.off(window, 'selectstart', L.DomEvent.stop);
|
||||
}
|
||||
},
|
||||
|
||||
disableImageDrag: function () {
|
||||
if (userDragProperty) {
|
||||
var style = document.documentElement.style;
|
||||
this._userDrag = style[userDragProperty];
|
||||
style[userDragProperty] = 'none';
|
||||
} else {
|
||||
L.DomEvent.on(window, 'dragstart', L.DomEvent.stop);
|
||||
}
|
||||
L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);
|
||||
},
|
||||
|
||||
enableImageDrag: function () {
|
||||
if (userDragProperty) {
|
||||
document.documentElement.style[userDragProperty] = this._userDrag;
|
||||
delete this._userDrag;
|
||||
} else {
|
||||
L.DomEvent.off(window, 'dragstart', L.DomEvent.stop);
|
||||
}
|
||||
L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);
|
||||
}
|
||||
});
|
||||
})();
|
||||
@ -1724,10 +1708,14 @@ L.Map = L.Class.extend({
|
||||
|
||||
if (this._loaded) {
|
||||
layer.onRemove(this);
|
||||
this.fire('layerremove', {layer: layer});
|
||||
}
|
||||
|
||||
delete this._layers[id];
|
||||
|
||||
if (this._loaded) {
|
||||
this.fire('layerremove', {layer: layer});
|
||||
}
|
||||
|
||||
if (this._zoomBoundLayers[id]) {
|
||||
delete this._zoomBoundLayers[id];
|
||||
this._updateZoomLevels();
|
||||
@ -2335,7 +2323,7 @@ L.Projection.Mercator = {
|
||||
lng = point.x * d / r,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1 - (tmp * tmp)),
|
||||
ts = Math.exp(- point.y / r2),
|
||||
ts = Math.exp(- point.y / r),
|
||||
phi = (Math.PI / 2) - 2 * Math.atan(ts),
|
||||
numIter = 15,
|
||||
tol = 1e-7,
|
||||
@ -2606,10 +2594,7 @@ L.TileLayer = L.Class.extend({
|
||||
var className = 'leaflet-tile-container leaflet-zoom-animated';
|
||||
|
||||
this._bgBuffer = L.DomUtil.create('div', className, this._container);
|
||||
this._bgBuffer.style.zIndex = 1;
|
||||
|
||||
this._tileContainer = L.DomUtil.create('div', className, this._container);
|
||||
this._tileContainer.style.zIndex = 2;
|
||||
|
||||
} else {
|
||||
this._tileContainer = this._container;
|
||||
@ -3049,6 +3034,11 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
},
|
||||
|
||||
redraw: function () {
|
||||
if (this._map) {
|
||||
this._reset({hard: true});
|
||||
this._update();
|
||||
}
|
||||
|
||||
for (var i in this._tiles) {
|
||||
this._redrawTile(this._tiles[i]);
|
||||
}
|
||||
@ -3903,7 +3893,7 @@ L.Popup = L.Class.extend({
|
||||
L.DomEvent.disableClickPropagation(wrapper);
|
||||
|
||||
this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
|
||||
L.DomEvent.on(this._contentNode, 'wheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);
|
||||
this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);
|
||||
this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);
|
||||
@ -6190,11 +6180,6 @@ L.geoJson = function (geojson, options) {
|
||||
*/
|
||||
|
||||
L.DomEvent = {
|
||||
WHEEL:
|
||||
'onwheel' in document ? 'wheel' :
|
||||
'onmousewheel' in document ? 'mousewheel' :
|
||||
'MozMousePixelScroll',
|
||||
|
||||
/* inspired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
|
||||
|
||||
@ -6215,13 +6200,13 @@ L.DomEvent = {
|
||||
this.addDoubleTapListener(obj, handler, id);
|
||||
}
|
||||
|
||||
if (type === 'wheel' || type === 'mousewheel') {
|
||||
type = L.DomEvent.WHEEL;
|
||||
}
|
||||
|
||||
if ('addEventListener' in obj) {
|
||||
|
||||
if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
if (type === 'mousewheel') {
|
||||
obj.addEventListener('DOMMouseScroll', handler, false);
|
||||
obj.addEventListener(type, handler, false);
|
||||
|
||||
} else if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
|
||||
originalHandler = handler;
|
||||
newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout');
|
||||
@ -6261,10 +6246,6 @@ L.DomEvent = {
|
||||
|
||||
if (!handler) { return this; }
|
||||
|
||||
if (type === 'wheel' || type === 'mousewheel') {
|
||||
type = L.DomEvent.WHEEL;
|
||||
}
|
||||
|
||||
if (L.Browser.msTouch && type.indexOf('touch') === 0) {
|
||||
this.removeMsTouchListener(obj, type, id);
|
||||
} else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
|
||||
@ -6272,7 +6253,11 @@ L.DomEvent = {
|
||||
|
||||
} else if ('removeEventListener' in obj) {
|
||||
|
||||
if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
if (type === 'mousewheel') {
|
||||
obj.removeEventListener('DOMMouseScroll', handler, false);
|
||||
obj.removeEventListener(type, handler, false);
|
||||
|
||||
} else if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false);
|
||||
} else {
|
||||
obj.removeEventListener(type, handler, false);
|
||||
@ -6324,26 +6309,42 @@ L.DomEvent = {
|
||||
|
||||
getMousePosition: function (e, container) {
|
||||
|
||||
var body = document.body,
|
||||
var ie7 = L.Browser.ie7,
|
||||
body = document.body,
|
||||
docEl = document.documentElement,
|
||||
x = e.pageX ? e.pageX : e.clientX + body.scrollLeft + docEl.scrollLeft,
|
||||
y = e.pageY ? e.pageY : e.clientY + body.scrollTop + docEl.scrollTop,
|
||||
pos = new L.Point(x, y);
|
||||
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
|
||||
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
|
||||
pos = new L.Point(x, y),
|
||||
rect = container.getBoundingClientRect(),
|
||||
left = rect.left - container.clientLeft,
|
||||
top = rect.top - container.clientTop;
|
||||
|
||||
return (container ? pos._subtract(L.DomUtil.getViewportOffset(container)) : pos);
|
||||
// webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
|
||||
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
|
||||
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
|
||||
left += container.scrollWidth - container.clientWidth;
|
||||
|
||||
// ie7 shows the scrollbar by default and provides clientWidth counting it, so we
|
||||
// need to add it back in if it is visible; scrollbar is on the left as we are RTL
|
||||
if (ie7 && L.DomUtil.getStyle(container, 'overflow-y') !== 'hidden' &&
|
||||
L.DomUtil.getStyle(container, 'overflow') !== 'hidden') {
|
||||
left += 17;
|
||||
}
|
||||
}
|
||||
|
||||
return pos._subtract(new L.Point(left, top));
|
||||
},
|
||||
|
||||
getWheelDelta: function (e) {
|
||||
|
||||
var delta = 0;
|
||||
|
||||
if (e.type === 'wheel') {
|
||||
delta = -e.deltaY / (e.deltaMode ? 1 : 120);
|
||||
} else if (e.type === 'mousewheel') {
|
||||
if (e.wheelDelta) {
|
||||
delta = e.wheelDelta / 120;
|
||||
} else if (e.type === 'MozMousePixelScroll') {
|
||||
delta = -e.detail;
|
||||
}
|
||||
|
||||
if (e.detail) {
|
||||
delta = -e.detail / 3;
|
||||
}
|
||||
return delta;
|
||||
},
|
||||
|
||||
@ -6466,6 +6467,7 @@ L.Draggable = L.Class.extend({
|
||||
if (L.Draggable._disabled) { return; }
|
||||
|
||||
L.DomUtil.disableImageDrag();
|
||||
L.DomUtil.disableTextSelection();
|
||||
|
||||
var first = e.touches ? e.touches[0] : e,
|
||||
el = first.target;
|
||||
@ -6505,7 +6507,6 @@ L.Draggable = L.Class.extend({
|
||||
this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomUtil.disableTextSelection();
|
||||
L.DomUtil.addClass(document.body, 'leaflet-dragging');
|
||||
}
|
||||
}
|
||||
@ -6525,7 +6526,6 @@ L.Draggable = L.Class.extend({
|
||||
|
||||
_onUp: function () {
|
||||
if (!L.Browser.touch) {
|
||||
L.DomUtil.enableTextSelection();
|
||||
L.DomUtil.removeClass(document.body, 'leaflet-dragging');
|
||||
}
|
||||
|
||||
@ -6536,6 +6536,7 @@ L.Draggable = L.Class.extend({
|
||||
}
|
||||
|
||||
L.DomUtil.enableImageDrag();
|
||||
L.DomUtil.enableTextSelection();
|
||||
|
||||
if (this._moved) {
|
||||
// ensure drag is not fired after dragend
|
||||
@ -6612,6 +6613,8 @@ L.Map.Drag = L.Handler.extend({
|
||||
if (map.options.worldCopyJump) {
|
||||
this._draggable.on('predrag', this._onPreDrag, this);
|
||||
map.on('viewreset', this._onViewReset, this);
|
||||
|
||||
this._onViewReset();
|
||||
}
|
||||
}
|
||||
this._draggable.enable();
|
||||
@ -6764,12 +6767,14 @@ L.Map.mergeOptions({
|
||||
|
||||
L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
addHooks: function () {
|
||||
L.DomEvent.on(this._map._container, 'wheel', this._onWheelScroll, this);
|
||||
L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
|
||||
L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
||||
this._delta = 0;
|
||||
},
|
||||
|
||||
removeHooks: function () {
|
||||
L.DomEvent.off(this._map._container, 'wheel', this._onWheelScroll);
|
||||
L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll);
|
||||
L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
||||
},
|
||||
|
||||
_onWheelScroll: function (e) {
|
||||
@ -8128,7 +8133,7 @@ L.Control.Layers = L.Control.extend({
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomEvent.disableClickPropagation(container);
|
||||
L.DomEvent.on(container, 'wheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
} else {
|
||||
L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
|
||||
}
|
||||
@ -8668,28 +8673,13 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
|
||||
|
||||
L.TileLayer.include({
|
||||
_animateZoom: function (e) {
|
||||
var firstFrame = false;
|
||||
|
||||
if (!this._animating) {
|
||||
this._animating = true;
|
||||
firstFrame = true;
|
||||
}
|
||||
|
||||
if (firstFrame) {
|
||||
this._prepareBgBuffer();
|
||||
}
|
||||
|
||||
var bg = this._bgBuffer;
|
||||
|
||||
if (firstFrame) {
|
||||
//prevent bg buffer from clearing right after zoom
|
||||
clearTimeout(this._clearBgBufferTimer);
|
||||
|
||||
// hack to make sure transform is updated before running animation
|
||||
L.Util.falseFn(bg.offsetWidth);
|
||||
}
|
||||
|
||||
var transform = L.DomUtil.TRANSFORM,
|
||||
var bg = this._bgBuffer,
|
||||
transform = L.DomUtil.TRANSFORM,
|
||||
initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
|
||||
scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
|
||||
|
||||
@ -8703,9 +8693,7 @@ L.TileLayer.include({
|
||||
bg = this._bgBuffer;
|
||||
|
||||
front.style.visibility = '';
|
||||
front.style.zIndex = 2;
|
||||
|
||||
bg.style.zIndex = 1;
|
||||
front.parentNode.appendChild(front); // Bring to fore
|
||||
|
||||
// force reflow
|
||||
L.Util.falseFn(bg.offsetWidth);
|
||||
@ -8749,6 +8737,9 @@ L.TileLayer.include({
|
||||
bg = this._bgBuffer = front;
|
||||
|
||||
this._stopLoadingImages(bg);
|
||||
|
||||
//prevent bg buffer from clearing right after zoom
|
||||
clearTimeout(this._clearBgBufferTimer);
|
||||
},
|
||||
|
||||
_getLoadedTilesPercentage: function (container) {
|
||||
@ -8868,7 +8859,7 @@ L.Map.include({
|
||||
|
||||
var data = {
|
||||
latlng: latlng,
|
||||
bounds: bounds,
|
||||
bounds: bounds
|
||||
};
|
||||
|
||||
for (var i in pos.coords) {
|
||||
|
4
dist/leaflet.css
vendored
4
dist/leaflet.css
vendored
@ -53,6 +53,10 @@
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-tile-pane { z-index: 2; }
|
||||
.leaflet-objects-pane { z-index: 3; }
|
||||
|
8
dist/leaflet.js
vendored
8
dist/leaflet.js
vendored
File diff suppressed because one or more lines are too long
@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "leaflet",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.2",
|
||||
"description": "JavaScript library for mobile-friendly interactive maps",
|
||||
"devDependencies": {
|
||||
"jshint": "~2.1.4",
|
||||
"mocha": "~1.10.0",
|
||||
"happen": "~0.1.2",
|
||||
"karma": "~0.8.6",
|
||||
"uglify-js": "~2.3.6",
|
||||
"jake": "~0.5.16"
|
||||
|
@ -1,93 +0,0 @@
|
||||
// https://github.com/tmcw/happen
|
||||
|
||||
!(function(context) {
|
||||
var h = {};
|
||||
|
||||
// Make inheritance bearable: clone one level of properties
|
||||
function extend(child, parent) {
|
||||
for (var property in parent) {
|
||||
if (typeof child[property] == 'undefined') {
|
||||
child[property] = parent[property];
|
||||
}
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
h.once = function(x, o) {
|
||||
var evt;
|
||||
|
||||
if (o.type.slice(0, 3) === 'key') {
|
||||
if (typeof Event === 'function') {
|
||||
evt = new Event(o.type);
|
||||
evt.keyCode = o.keyCode || 0;
|
||||
evt.charCode = o.charCode || 0;
|
||||
evt.shift = o.shift || false;
|
||||
evt.meta = o.meta || false;
|
||||
evt.ctrl = o.ctrl || false;
|
||||
evt.alt = o.alt || false;
|
||||
} else {
|
||||
evt = document.createEvent('KeyboardEvent');
|
||||
// https://developer.mozilla.org/en/DOM/event.initKeyEvent
|
||||
// https://developer.mozilla.org/en/DOM/KeyboardEvent
|
||||
evt[(evt.initKeyEvent) ? 'initKeyEvent'
|
||||
: 'initKeyboardEvent'](
|
||||
o.type, // in DOMString typeArg,
|
||||
true, // in boolean canBubbleArg,
|
||||
true, // in boolean cancelableArg,
|
||||
null, // in nsIDOMAbstractView viewArg, Specifies UIEvent.view. This value may be null.
|
||||
o.ctrl || false, // in boolean ctrlKeyArg,
|
||||
o.alt || false, // in boolean altKeyArg,
|
||||
o.shift || false, // in boolean shiftKeyArg,
|
||||
o.meta || false, // in boolean metaKeyArg,
|
||||
o.keyCode || 0, // in unsigned long keyCodeArg,
|
||||
o.charCode || 0 // in unsigned long charCodeArg);
|
||||
);
|
||||
}
|
||||
} else {
|
||||
evt = document.createEvent('MouseEvents');
|
||||
// https://developer.mozilla.org/en/DOM/event.initMouseEvent
|
||||
evt.initMouseEvent(o.type,
|
||||
true, // canBubble
|
||||
true, // cancelable
|
||||
window, // 'AbstractView'
|
||||
o.clicks || 0, // click count
|
||||
o.screenX || 0, // screenX
|
||||
o.screenY || 0, // screenY
|
||||
o.clientX || 0, // clientX
|
||||
o.clientY || 0, // clientY
|
||||
o.ctrl || 0, // ctrl
|
||||
o.alt || false, // alt
|
||||
o.shift || false, // shift
|
||||
o.meta || false, // meta
|
||||
o.button || false, // mouse button
|
||||
null // relatedTarget
|
||||
);
|
||||
}
|
||||
|
||||
x.dispatchEvent(evt);
|
||||
};
|
||||
|
||||
var shortcuts = ['click', 'mousedown', 'mouseup', 'mousemove', 'keydown', 'keyup', 'keypress'],
|
||||
s, i = 0;
|
||||
|
||||
while (s = shortcuts[i++]) {
|
||||
h[s] = (function(s) {
|
||||
return function(x, o) {
|
||||
h.once(x, extend(o || {}, { type: s }));
|
||||
};
|
||||
})(s);
|
||||
}
|
||||
|
||||
h.dblclick = function(x, o) {
|
||||
h.once(x, extend(o || {}, {
|
||||
type: 'dblclick',
|
||||
clicks: 2
|
||||
}));
|
||||
};
|
||||
|
||||
this.happen = h;
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = this.happen;
|
||||
}
|
||||
})(this);
|
@ -9,7 +9,7 @@
|
||||
<div id="mocha"></div>
|
||||
<script src="expect.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
|
||||
<script type="text/javascript" src="happen.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/happen/src/happen.js"></script>
|
||||
<script type="text/javascript" src="sinon.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
|
@ -17,7 +17,7 @@ files = [].concat([
|
||||
"expect.js"
|
||||
], libSources, [
|
||||
"after.js",
|
||||
"happen.js",
|
||||
"../node_modules/happen/src/happen.js",
|
||||
"suites/SpecHelper.js",
|
||||
"suites/**/*.js"
|
||||
]);
|
||||
|
@ -184,6 +184,16 @@ describe("Map", function () {
|
||||
expect(spy.called).not.to.be.ok();
|
||||
});
|
||||
|
||||
it("adds the layer before firing layeradd", function (done) {
|
||||
var layer = { onAdd: sinon.spy(), onRemove: sinon.spy() };
|
||||
map.on('layeradd', function() {
|
||||
expect(map.hasLayer(layer)).to.be.ok();
|
||||
done();
|
||||
});
|
||||
map.setView([0, 0], 0);
|
||||
map.addLayer(layer);
|
||||
});
|
||||
|
||||
describe("When the first layer is added to a map", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
var spy = sinon.spy();
|
||||
@ -270,6 +280,17 @@ describe("Map", function () {
|
||||
expect(spy.called).not.to.be.ok();
|
||||
});
|
||||
|
||||
it("removes the layer before firing layerremove", function (done) {
|
||||
var layer = { onAdd: sinon.spy(), onRemove: sinon.spy() };
|
||||
map.on('layerremove', function() {
|
||||
expect(map.hasLayer(layer)).not.to.be.ok();
|
||||
done();
|
||||
});
|
||||
map.setView([0, 0], 0);
|
||||
map.addLayer(layer);
|
||||
map.removeLayer(layer);
|
||||
});
|
||||
|
||||
describe("when the last tile layer on a map is removed", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
map.whenReady(function(){
|
||||
|
@ -2,7 +2,7 @@
|
||||
var oldL = window.L,
|
||||
L = {};
|
||||
|
||||
L.version = '0.6';
|
||||
L.version = '0.6.2';
|
||||
|
||||
// define Leaflet for Node module pattern loaders, including Browserify
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
|
@ -70,7 +70,7 @@ L.Control.Layers = L.Control.extend({
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomEvent.disableClickPropagation(container);
|
||||
L.DomEvent.on(container, 'wheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
} else {
|
||||
L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
|
||||
}
|
||||
|
@ -3,11 +3,6 @@
|
||||
*/
|
||||
|
||||
L.DomEvent = {
|
||||
WHEEL:
|
||||
'onwheel' in document ? 'wheel' :
|
||||
'onmousewheel' in document ? 'mousewheel' :
|
||||
'MozMousePixelScroll',
|
||||
|
||||
/* inspired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
|
||||
|
||||
@ -28,13 +23,13 @@ L.DomEvent = {
|
||||
this.addDoubleTapListener(obj, handler, id);
|
||||
}
|
||||
|
||||
if (type === 'wheel' || type === 'mousewheel') {
|
||||
type = L.DomEvent.WHEEL;
|
||||
}
|
||||
|
||||
if ('addEventListener' in obj) {
|
||||
|
||||
if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
if (type === 'mousewheel') {
|
||||
obj.addEventListener('DOMMouseScroll', handler, false);
|
||||
obj.addEventListener(type, handler, false);
|
||||
|
||||
} else if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
|
||||
originalHandler = handler;
|
||||
newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout');
|
||||
@ -74,10 +69,6 @@ L.DomEvent = {
|
||||
|
||||
if (!handler) { return this; }
|
||||
|
||||
if (type === 'wheel' || type === 'mousewheel') {
|
||||
type = L.DomEvent.WHEEL;
|
||||
}
|
||||
|
||||
if (L.Browser.msTouch && type.indexOf('touch') === 0) {
|
||||
this.removeMsTouchListener(obj, type, id);
|
||||
} else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
|
||||
@ -85,7 +76,11 @@ L.DomEvent = {
|
||||
|
||||
} else if ('removeEventListener' in obj) {
|
||||
|
||||
if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
if (type === 'mousewheel') {
|
||||
obj.removeEventListener('DOMMouseScroll', handler, false);
|
||||
obj.removeEventListener(type, handler, false);
|
||||
|
||||
} else if ((type === 'mouseenter') || (type === 'mouseleave')) {
|
||||
obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false);
|
||||
} else {
|
||||
obj.removeEventListener(type, handler, false);
|
||||
@ -137,26 +132,42 @@ L.DomEvent = {
|
||||
|
||||
getMousePosition: function (e, container) {
|
||||
|
||||
var body = document.body,
|
||||
var ie7 = L.Browser.ie7,
|
||||
body = document.body,
|
||||
docEl = document.documentElement,
|
||||
x = e.pageX ? e.pageX : e.clientX + body.scrollLeft + docEl.scrollLeft,
|
||||
y = e.pageY ? e.pageY : e.clientY + body.scrollTop + docEl.scrollTop,
|
||||
pos = new L.Point(x, y);
|
||||
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
|
||||
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
|
||||
pos = new L.Point(x, y),
|
||||
rect = container.getBoundingClientRect(),
|
||||
left = rect.left - container.clientLeft,
|
||||
top = rect.top - container.clientTop;
|
||||
|
||||
return (container ? pos._subtract(L.DomUtil.getViewportOffset(container)) : pos);
|
||||
// webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
|
||||
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
|
||||
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
|
||||
left += container.scrollWidth - container.clientWidth;
|
||||
|
||||
// ie7 shows the scrollbar by default and provides clientWidth counting it, so we
|
||||
// need to add it back in if it is visible; scrollbar is on the left as we are RTL
|
||||
if (ie7 && L.DomUtil.getStyle(container, 'overflow-y') !== 'hidden' &&
|
||||
L.DomUtil.getStyle(container, 'overflow') !== 'hidden') {
|
||||
left += 17;
|
||||
}
|
||||
}
|
||||
|
||||
return pos._subtract(new L.Point(left, top));
|
||||
},
|
||||
|
||||
getWheelDelta: function (e) {
|
||||
|
||||
var delta = 0;
|
||||
|
||||
if (e.type === 'wheel') {
|
||||
delta = -e.deltaY / (e.deltaMode ? 1 : 120);
|
||||
} else if (e.type === 'mousewheel') {
|
||||
if (e.wheelDelta) {
|
||||
delta = e.wheelDelta / 120;
|
||||
} else if (e.type === 'MozMousePixelScroll') {
|
||||
delta = -e.detail;
|
||||
}
|
||||
|
||||
if (e.detail) {
|
||||
delta = -e.detail / 3;
|
||||
}
|
||||
return delta;
|
||||
},
|
||||
|
||||
|
@ -241,46 +241,30 @@ L.DomUtil.TRANSITION_END =
|
||||
var userSelectProperty = L.DomUtil.testProp(
|
||||
['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);
|
||||
|
||||
var userDragProperty = L.DomUtil.testProp(
|
||||
['userDrag', 'WebkitUserDrag', 'OUserDrag', 'MozUserDrag', 'msUserDrag']);
|
||||
|
||||
L.extend(L.DomUtil, {
|
||||
disableTextSelection: function () {
|
||||
L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);
|
||||
if (userSelectProperty) {
|
||||
var style = document.documentElement.style;
|
||||
this._userSelect = style[userSelectProperty];
|
||||
style[userSelectProperty] = 'none';
|
||||
} else {
|
||||
L.DomEvent.on(window, 'selectstart', L.DomEvent.stop);
|
||||
}
|
||||
},
|
||||
|
||||
enableTextSelection: function () {
|
||||
L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);
|
||||
if (userSelectProperty) {
|
||||
document.documentElement.style[userSelectProperty] = this._userSelect;
|
||||
delete this._userSelect;
|
||||
} else {
|
||||
L.DomEvent.off(window, 'selectstart', L.DomEvent.stop);
|
||||
}
|
||||
},
|
||||
|
||||
disableImageDrag: function () {
|
||||
if (userDragProperty) {
|
||||
var style = document.documentElement.style;
|
||||
this._userDrag = style[userDragProperty];
|
||||
style[userDragProperty] = 'none';
|
||||
} else {
|
||||
L.DomEvent.on(window, 'dragstart', L.DomEvent.stop);
|
||||
}
|
||||
L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);
|
||||
},
|
||||
|
||||
enableImageDrag: function () {
|
||||
if (userDragProperty) {
|
||||
document.documentElement.style[userDragProperty] = this._userDrag;
|
||||
delete this._userDrag;
|
||||
} else {
|
||||
L.DomEvent.off(window, 'dragstart', L.DomEvent.stop);
|
||||
}
|
||||
L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
@ -54,6 +54,7 @@ L.Draggable = L.Class.extend({
|
||||
if (L.Draggable._disabled) { return; }
|
||||
|
||||
L.DomUtil.disableImageDrag();
|
||||
L.DomUtil.disableTextSelection();
|
||||
|
||||
var first = e.touches ? e.touches[0] : e,
|
||||
el = first.target;
|
||||
@ -93,7 +94,6 @@ L.Draggable = L.Class.extend({
|
||||
this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomUtil.disableTextSelection();
|
||||
L.DomUtil.addClass(document.body, 'leaflet-dragging');
|
||||
}
|
||||
}
|
||||
@ -113,7 +113,6 @@ L.Draggable = L.Class.extend({
|
||||
|
||||
_onUp: function () {
|
||||
if (!L.Browser.touch) {
|
||||
L.DomUtil.enableTextSelection();
|
||||
L.DomUtil.removeClass(document.body, 'leaflet-dragging');
|
||||
}
|
||||
|
||||
@ -124,6 +123,7 @@ L.Draggable = L.Class.extend({
|
||||
}
|
||||
|
||||
L.DomUtil.enableImageDrag();
|
||||
L.DomUtil.enableTextSelection();
|
||||
|
||||
if (this._moved) {
|
||||
// ensure drag is not fired after dragend
|
||||
|
@ -36,7 +36,7 @@ L.Projection.Mercator = {
|
||||
lng = point.x * d / r,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1 - (tmp * tmp)),
|
||||
ts = Math.exp(- point.y / r2),
|
||||
ts = Math.exp(- point.y / r),
|
||||
phi = (Math.PI / 2) - 2 * Math.atan(ts),
|
||||
numIter = 15,
|
||||
tol = 1e-7,
|
||||
|
@ -152,7 +152,7 @@ L.Popup = L.Class.extend({
|
||||
L.DomEvent.disableClickPropagation(wrapper);
|
||||
|
||||
this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
|
||||
L.DomEvent.on(this._contentNode, 'wheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);
|
||||
this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);
|
||||
this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);
|
||||
|
@ -4,28 +4,13 @@
|
||||
|
||||
L.TileLayer.include({
|
||||
_animateZoom: function (e) {
|
||||
var firstFrame = false;
|
||||
|
||||
if (!this._animating) {
|
||||
this._animating = true;
|
||||
firstFrame = true;
|
||||
}
|
||||
|
||||
if (firstFrame) {
|
||||
this._prepareBgBuffer();
|
||||
}
|
||||
|
||||
var bg = this._bgBuffer;
|
||||
|
||||
if (firstFrame) {
|
||||
//prevent bg buffer from clearing right after zoom
|
||||
clearTimeout(this._clearBgBufferTimer);
|
||||
|
||||
// hack to make sure transform is updated before running animation
|
||||
L.Util.falseFn(bg.offsetWidth);
|
||||
}
|
||||
|
||||
var transform = L.DomUtil.TRANSFORM,
|
||||
var bg = this._bgBuffer,
|
||||
transform = L.DomUtil.TRANSFORM,
|
||||
initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
|
||||
scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
|
||||
|
||||
@ -39,9 +24,7 @@ L.TileLayer.include({
|
||||
bg = this._bgBuffer;
|
||||
|
||||
front.style.visibility = '';
|
||||
front.style.zIndex = 2;
|
||||
|
||||
bg.style.zIndex = 1;
|
||||
front.parentNode.appendChild(front); // Bring to fore
|
||||
|
||||
// force reflow
|
||||
L.Util.falseFn(bg.offsetWidth);
|
||||
@ -85,6 +68,9 @@ L.TileLayer.include({
|
||||
bg = this._bgBuffer = front;
|
||||
|
||||
this._stopLoadingImages(bg);
|
||||
|
||||
//prevent bg buffer from clearing right after zoom
|
||||
clearTimeout(this._clearBgBufferTimer);
|
||||
},
|
||||
|
||||
_getLoadedTilesPercentage: function (container) {
|
||||
|
@ -13,6 +13,11 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
},
|
||||
|
||||
redraw: function () {
|
||||
if (this._map) {
|
||||
this._reset({hard: true});
|
||||
this._update();
|
||||
}
|
||||
|
||||
for (var i in this._tiles) {
|
||||
this._redrawTile(this._tiles[i]);
|
||||
}
|
||||
|
@ -233,10 +233,7 @@ L.TileLayer = L.Class.extend({
|
||||
var className = 'leaflet-tile-container leaflet-zoom-animated';
|
||||
|
||||
this._bgBuffer = L.DomUtil.create('div', className, this._container);
|
||||
this._bgBuffer.style.zIndex = 1;
|
||||
|
||||
this._tileContainer = L.DomUtil.create('div', className, this._container);
|
||||
this._tileContainer.style.zIndex = 2;
|
||||
|
||||
} else {
|
||||
this._tileContainer = this._container;
|
||||
|
@ -209,10 +209,14 @@ L.Map = L.Class.extend({
|
||||
|
||||
if (this._loaded) {
|
||||
layer.onRemove(this);
|
||||
this.fire('layerremove', {layer: layer});
|
||||
}
|
||||
|
||||
delete this._layers[id];
|
||||
|
||||
if (this._loaded) {
|
||||
this.fire('layerremove', {layer: layer});
|
||||
}
|
||||
|
||||
if (this._zoomBoundLayers[id]) {
|
||||
delete this._zoomBoundLayers[id];
|
||||
this._updateZoomLevels();
|
||||
|
@ -83,7 +83,7 @@ L.Map.include({
|
||||
|
||||
var data = {
|
||||
latlng: latlng,
|
||||
bounds: bounds,
|
||||
bounds: bounds
|
||||
};
|
||||
|
||||
for (var i in pos.coords) {
|
||||
|
@ -31,6 +31,8 @@ L.Map.Drag = L.Handler.extend({
|
||||
if (map.options.worldCopyJump) {
|
||||
this._draggable.on('predrag', this._onPreDrag, this);
|
||||
map.on('viewreset', this._onViewReset, this);
|
||||
|
||||
this._onViewReset();
|
||||
}
|
||||
}
|
||||
this._draggable.enable();
|
||||
|
@ -8,12 +8,14 @@ L.Map.mergeOptions({
|
||||
|
||||
L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
addHooks: function () {
|
||||
L.DomEvent.on(this._map._container, 'wheel', this._onWheelScroll, this);
|
||||
L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
|
||||
L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
||||
this._delta = 0;
|
||||
},
|
||||
|
||||
removeHooks: function () {
|
||||
L.DomEvent.off(this._map._container, 'wheel', this._onWheelScroll);
|
||||
L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll);
|
||||
L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
|
||||
},
|
||||
|
||||
_onWheelScroll: function (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user