Merge tag 'v0.5' into stable
Version 0.5 * tag 'v0.5': (319 commits) fix FF minus key, close #869, update changelog and build fix whitespace, update build update zoom control styles, extract general toolbar classes, fix #1209 minor cleanup update changelog more update changelog update changelog update build Robust array type check for cross-frame support Fix jshint unhappiness (Thanks @Guiswa) fixed the whitespace and also removed the quotes in object keys Another pass on marker-icon, better grid fitting. update changelog Oops, revert accidental commit add Popup zoomAnimation option, fix #999 fix a bug with FeatureGroup bindPopup not accepting options Update README.md Remove click handler with onRemove udpate copyright to be more precise fix TileLayer.brintToFront/Back on IE6-8, close #1168 ...
2
.gitignore
vendored
@ -5,3 +5,5 @@ tmp/**/*
|
||||
.idea/**/*
|
||||
*.iml
|
||||
*.sublime-*
|
||||
_site
|
||||
dist/*.js
|
||||
|
428
CHANGELOG.md
@ -7,17 +7,153 @@ Leaflet Changelog
|
||||
|
||||
An in-progress version being developed on the master branch.
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Be sure to read through these changes to avoid any issues when upgrading from older versions:
|
||||
|
||||
* Removed default `LatLng` wrapping/clamping of coordinates (`-180, -90` to `180, 90`), wrapping moved to an explicit method (`LatLng` `wrap`).
|
||||
* Disabled `Map` `worldCopyJump` option by default (jumping back to the original world copy when panning out of it). Enable it explicitly if you need it.
|
||||
* Changed styles for the zoom control (you may need to update your custom styles for it).
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
##### Interaction
|
||||
|
||||
* Added touch zoom, pan and double tap support for **IE10 touch devices and Metro apps** (by [@danzel](https://github.com/danzel) and [@veproza](https://github.com/veproza) with help from [@oliverheilig](https://github.com/oliverheilig)). [#1076](https://github.com/Leaflet/Leaflet/pull/1076) [#871](https://github.com/Leaflet/Leaflet/issues/871)
|
||||
* **Improved panning inertia** to be much more natural and smooth.
|
||||
* **Improved dragging cursors** in Chrome, Safari and Firefox (now grabbing hand cursors are used).
|
||||
* Improved zoom animation curve for a better feel overall.
|
||||
* Improved scroll wheel zoom to be more responsive.
|
||||
* Improved panning animation performance in IE6-8.
|
||||
|
||||
##### Controls
|
||||
|
||||
* **Improved zoom control design** to look better, more neutral and in line with other controls, making it easier to customize and fit different website designs. Replaced +/- images with text.
|
||||
* Improved zoom control to zoom by 3 levels if you hold shift while clicking on a button.
|
||||
* Improved zoom control buttons to become visually disabled when min/max zoom is reached. [#917](https://github.com/Leaflet/Leaflet/issues/917)
|
||||
* Improved scale control styles.
|
||||
* Improved fallback control styles for IE6-8.
|
||||
|
||||
##### Other
|
||||
|
||||
* Added **retina support for markers** (through `Icon` `iconRetinaUrl` and `shadowRetinaUrl` options) (by [@danzel](https://github.com/danzel)). [#1048](https://github.com/Leaflet/Leaflet/issues/1048) [#1174](https://github.com/Leaflet/Leaflet/pull/1174)
|
||||
* Added retina-sized default marker icon in addition to standard one (along with its SVG source and with some subtle design improvements) (by [@danzel](https://github.com/danzel)). [#1048](https://github.com/Leaflet/Leaflet/issues/1048) [#1174](https://github.com/Leaflet/Leaflet/pull/1174)
|
||||
* Improved vectors updating/removing performance on Canvas backend (by [@danzel](https://github.com/danzel)). [#961](https://github.com/Leaflet/Leaflet/pull/961)
|
||||
* Cut total images size from 10KB to 3.2KB with [Yahoo Smush.it](http://www.smushit.com/ysmush.it/). Thanks to Peter Rounce for suggestion.
|
||||
|
||||
#### API improvements
|
||||
|
||||
* Replaced `L.Transition` with a much better and simpler `L.PosAnimation`.
|
||||
* Added `Class` `addInitHook` method for **adding constructor hooks to any classes** (great extension point for plugin authors). [#1123](https://github.com/Leaflet/Leaflet/issues/1123)
|
||||
* Added `Map` `whenReady` method (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1063](https://github.com/Leaflet/Leaflet/pull/1063)
|
||||
* Added optional `delta` argument to `Map` `zoomIn` and `zoomOut` (1 by default).
|
||||
* Added `isValid` method to `LatLngBounds` and `Bounds` (by [@domoritz](https://github.com/domoritz)). [#972](https://github.com/Leaflet/Leaflet/pull/972)
|
||||
* Added `Point` `equals` method.
|
||||
* Added `Bounds` `getSize` method.
|
||||
* Improved markers and vectors click event so that it propagates to map if no one is listening to it (by [@danzel](https://github.com/danzel)). [#834](https://github.com/Leaflet/Leaflet/issues/834) [#1033](https://github.com/Leaflet/Leaflet/pull/1033)
|
||||
* Added `Path` `unbindPopup` and `closePopup` methods.
|
||||
* Added `Path` `add` and `remove` event.
|
||||
* Added `Marker` `riseOnHover` and `riseOffset` options (for bringing markers to front on hover, disabled by default) (by [jacobtoye](https://github.com/jacobtoye)). [#914](https://github.com/Leaflet/Leaflet/pull/914) [#920](https://github.com/Leaflet/Leaflet/issues/920)
|
||||
* Added `Marker` `move` and `remove` events.
|
||||
* Added `Marker` `contextmenu` event. [#223](https://github.com/Leaflet/Leaflet/issues/223)
|
||||
* Added `Popup` `zoomAnimation` option (useful to disable when displaying flash content inside popups [#999](https://github.com/Leaflet/Leaflet/issues/999)).
|
||||
* Added `FeatureGroup` `layeradd` and `layerremove` events (by [@jacobtoye](https://github.com/jacobtoye)). [#1122](https://github.com/Leaflet/Leaflet/issues/1122)
|
||||
* Added `Control.Layers` `baselayerchange` event (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1064](https://github.com/Leaflet/Leaflet/pull/1064)
|
||||
* Improved `Control.Layers` to support HTML in layer names (by [@aparshin](https://github.com/aparshin)). [#1055](https://github.com/Leaflet/Leaflet/pull/1055) [#1099](https://github.com/Leaflet/Leaflet/issues/1099)
|
||||
* Added `CRS.Simple` to the list of built-in CRS and improved it to be more usable out of the box (it has different default scaling and transformation now), see `debug/map/simple-proj.html` for an example.
|
||||
* Removed `Browser` `ua`, `gecko`, `opera` properties (no longer needed).
|
||||
* Added `L.extend`, `L.bind`, `L.stamp`, `L.setOptions` shortcuts for corresponding `L.Util` methods.
|
||||
* Disabled clearing of map container contents on map initialization (as a result of fixing [#278](https://github.com/Leaflet/Leaflet/issues/278)).
|
||||
* Added `L.Util.isArray` function (by [@oslek](https://github.com/oslek)). [#1279](https://github.com/Leaflet/Leaflet/pull/1279)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed broken tiles and zooming in RTL layouts (by [@danzel](https://github.com/danzel)). [#1099](https://github.com/Leaflet/Leaflet/pull/1099) [#1095](https://github.com/Leaflet/Leaflet/issues/1095)
|
||||
* Fixed a bug with pan animation where it jumped to its end position if you tried to drag the map.
|
||||
* Fixed a bug where shift-clicking on a map would zoom it to the max zoom level.
|
||||
* Fixed a glitch with zooming in while panning animation is running.
|
||||
* Fixed a glitch with dragging the map while zoom animation is running.
|
||||
* Fixed a bug where slight touchpad scrolling or one-wheel scrolling wouln't always perform zooming. [#1039](https://github.com/Leaflet/Leaflet/issues/1039)
|
||||
* Fixed a bug where `panBy` wouldn't round the offset values (so it was possible to make the map blurry with it). [#1085](https://github.com/Leaflet/Leaflet/issues/1085)
|
||||
* Fixed a bug where you couldn't scroll the layers control with a mouse wheel.
|
||||
* Fixed a regression where WMS tiles wouldn't wrap on date lines. [#970](https://github.com/Leaflet/Leaflet/issues/970)
|
||||
* Fixed a bug where mouse interaction was affected by map container border width (by [@mohlendo](https://github.com/mohlendo)). [#1204](https://github.com/Leaflet/Leaflet/issues/1205) [#1205](https://github.com/Leaflet/Leaflet/pull/1205)
|
||||
* Fixed a bug with weird vector zoom animation when using Canvas for rendering (by [@danzel](https://github.com/danzel)). [#1187](https://github.com/Leaflet/Leaflet/issues/1187) [#1188](https://github.com/Leaflet/Leaflet/pull/1188)
|
||||
* Fixed a bug where max bounds limitation didn't work when navigating the map with a keyboard (by [@snkashis](https://github.com/snkashis)). [#989](https://github.com/Leaflet/Leaflet/issues/989) [#1221](https://github.com/Leaflet/Leaflet/pull/1221)
|
||||
|
||||
#### API bugfixes
|
||||
|
||||
* Fixed a bug where `TileLayer` `bringToBack` didn't work properly in some cases (by [@danzel](https://github.com/danzel)). [#963](https://github.com/Leaflet/Leaflet/pull/963) [#959](https://github.com/Leaflet/Leaflet/issues/959)
|
||||
* Fixed a bug where removing a tile layer while dragging would throw an error (by [@danzel](https://github.com/danzel)). [#965](https://github.com/Leaflet/Leaflet/issues/965) [#968](https://github.com/Leaflet/Leaflet/pull/968)
|
||||
* Fixed a bug where middle marker wasn't removed after deleting 2 end nodes from a polyline (by [@Svad](https://github.com/Svad)). [#1022](https://github.com/Leaflet/Leaflet/issues/1022) [#1023](https://github.com/Leaflet/Leaflet/pull/1023)
|
||||
* Fixed a bug where `Map` `load` event happened too late (after `moveend`, etc.) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1027](https://github.com/Leaflet/Leaflet/pull/1027)
|
||||
* Fixed `Circle` `getBounds` to return correct bounds and work without adding the circle to a map. [#1068](https://github.com/Leaflet/Leaflet/issues/1068)
|
||||
* Fixed a bug where removing `Popup` on `viewreset` throwed an error (by [fnicollet](https://github.com/fnicollet) and [@danzel](https://github.com/danzel)). [#1098](https://github.com/Leaflet/Leaflet/pull/1098) [#1094](https://github.com/Leaflet/Leaflet/issues/1094)
|
||||
* Fixed a bug where `TileLayer.Canvas` `drawTile` didn't receive tile zoom level in arguments.
|
||||
* Fixed a bug where `GeoJSON` `resetStyle` would not fully reset a layer to its default style. [#1112](https://github.com/Leaflet/Leaflet/issues/1112)
|
||||
* Fixed a bug that caused infinite recursion when using `latLngBounds` factory with coordinates as string values. [#933](https://github.com/Leaflet/Leaflet/issues/933)
|
||||
* Fixed chaining on `Marker` `setIcon`, `setZIndexOffset`, `update` methods. [#1176](https://github.com/Leaflet/Leaflet/issues/1176)
|
||||
* Fixed a bug with mouse interaction when the map container contained children with position other than absolute. [#278](https://github.com/Leaflet/Leaflet/issues/278)
|
||||
* Fixed a bug with fill/stroke opacity conflicts when using Canvas for rendering (by [@danzel](https://github.com/danzel)). [#1186](https://github.com/Leaflet/Leaflet/issues/1186) [#1889](https://github.com/Leaflet/Leaflet/pull/1189)
|
||||
* Fixed a bug where `FeatureGroup` `bindPopup` didn't take options into account.
|
||||
* Fixed a bug where Canvas-based vector layers didn't cleanup click event on removal properly (by [@snkashis](https://github.com/snkashis)). [#1006](https://github.com/Leaflet/Leaflet/issues/1006) [#1273](https://github.com/Leaflet/Leaflet/pull/1273)
|
||||
* Fixed a bug where `CircleMarker` `setStyle` didn't take `radius` into account (by [@fdlk](https://github.com/fdlk)). [#1012](https://github.com/Leaflet/Leaflet/issues/1012) [#1013](https://github.com/Leaflet/Leaflet/pull/1013)
|
||||
* Fixed a bug where null GeoJSON geometries would throw an error instead of skipping (by [@brianherbert](https://github.com/brianherbert)). [#1240](https://github.com/Leaflet/Leaflet/pull/1240)
|
||||
* Fixed a bug where Canvas-based vector layers passed incorrect `layer` event property on click (by [@snkashis](https://github.com/snkashis)). [#1215](https://github.com/Leaflet/Leaflet/issues/1215) [#1243](https://github.com/Leaflet/Leaflet/pull/1243)
|
||||
* Fixed a bug where `TileLayer.WMS` didn't work correctly if the base URL contained query parameters (by [@snkashis](https://github.com/snkashis)). [#973](https://github.com/Leaflet/Leaflet/issues/973) [#1231](https://github.com/Leaflet/Leaflet/pull/1231)
|
||||
* Fixed a bug where removing a polyline in editing state wouldn't clean up the editing handles (by [@mehmeta](https://github.com/mehmeta)). [#1233](https://github.com/Leaflet/Leaflet/pull/1233)
|
||||
* Fixed a bug where removing a vector layer with a bound popup wouldn't clean up its click event properly (by [@yohanboniface](https://github.com/yohanboniface)). [#1229](https://github.com/Leaflet/Leaflet/pull/1229)
|
||||
* Fixed a bug where `GeoJSON` features with `GeometryCollection` didn't pass properties to `pointToLayer` function (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#1097](https://github.com/Leaflet/Leaflet/pull/1097)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug with map **freezing after zoom on Android 4.1**. [#1182](https://github.com/Leaflet/Leaflet/issues/1182)
|
||||
* Fixed a bug where "Not implemented" error sometimes appeared in IE6-8 (by [@bryguy](https://github.com/bryguy) and [@lookfirst](https://github.com/lookfirst)). [#892](https://github.com/Leaflet/Leaflet/issues/892) [#893](https://github.com/Leaflet/Leaflet/pull/893)
|
||||
* Fixed compatibility with SmoothWheel extension for Firefox (by [@waldir](https://github.com/waldir)). [#1011](https://github.com/Leaflet/Leaflet/pull/1011)
|
||||
* Fixed a bug with popup layout in IE6-7 (by [@danzel](https://github.com/danzel)). [#1117](https://github.com/Leaflet/Leaflet/issues/1117)
|
||||
* Fixed a bug with incorrect box zoom opacity in IE6-7 (by [@jacobtoye](https://github.com/jacobtoye)). [#1072](https://githubcom/Leaflet/Leaflet/pull/1072)
|
||||
* Fixed a bug with box zoom throwing a JS error in IE6-7 (by [@danzel](https://github.com/danzel)). [#1071](https://github.com/Leaflet/Leaflet/pull/1071)
|
||||
* Fixed a bug where `TileLayer` `bringToFront/Back()` throwed an error in IE6-8. [#1168](https://github.com/Leaflet/Leaflet/issues/1168)
|
||||
* Fixed array type checking in the code to be more consistent in a cross-frame environment (by [@oslek](https://github.com/oslek)). [#1279](https://github.com/Leaflet/Leaflet/pull/1279)
|
||||
* Fixed a bug with `-` key not working in Firefox 15+ (thanks to [@mattesCZ](https://github.com/mattesCZ)). [#869](https://github.com/Leaflet/Leaflet/issues/869)
|
||||
|
||||
## 0.4.5 (October 25, 2012)
|
||||
|
||||
* Fixed a bug with **wonky zoom animation in IE10** (by [@danzel](https://github.com/danzel)). [#1007](https://github.com/Leaflet/Leaflet/pull/1007)
|
||||
* Fixed a bug with **wonky zoom animation in Chrome 23+** (by [@danzel](https://github.com/danzel)). [#1060](https://github.com/Leaflet/Leaflet/pull/1060) [#1056](https://github.com/Leaflet/Leaflet/issues/1056)
|
||||
|
||||
## 0.4.4 (August 7, 2012)
|
||||
|
||||
### Improvements
|
||||
|
||||
* Improved `GeoJSON` `setStyle` to also accept function (like the corresponding option).
|
||||
* Added `GeoJSON` `resetStyle(layer)`, useful for resetting hover state.
|
||||
* Added `feature` property to layers created with `GeoJSON` (containing the GeoJSON feature data).
|
||||
* Added `FeatureGroup` `bringToFront` and `bringToBack` methods (so that they would work for multipolys).
|
||||
* Added optional `animate` argument to `Map` `invalidateSize` (by [@ajbeaven](https://github.com/ajbeaven)). [#857](https://github.com/Leaflet/Leaflet/pull/857)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fixed a bug where tiles sometimes disappeared on initial map load on Android 2/3 (by [@danzel](https://github.com/danzel)). [#868](https://github.com/Leaflet/Leaflet/pull/868)
|
||||
* Fixed a bug where map would occasionally flicker near the border on zoom or pan on Chrome.
|
||||
* Fixed a bug where `Path` `bringToFront` and `bringToBack` didn't return `this`.
|
||||
* Removed zoom out on Win/Meta key binding (since it interferes with global keyboard shortcuts). [#869](https://github.com/Leaflet/Leaflet/issues/869)
|
||||
|
||||
## 0.4.2 (August 1, 2012)
|
||||
|
||||
* Fixed a bug where layers control radio buttons would not work correctly in IE7 (by [@danzel](https://github.com/danzel)). [#862](https://github.com/CloudMade/Leaflet/pull/862)
|
||||
* Fixed a bug where `FeatureGroup` `removeLayer` would unbind popups of removed layers even if the popups were not put by the group (affected [Leaflet.markercluster](https://github.com/danzel/Leaflet.markercluster) plugin) (by [@danzel](https://github.com/danzel)). [#861](https://github.com/CloudMade/Leaflet/pull/861)
|
||||
* Fixed a bug where layers control radio buttons would not work correctly in IE7 (by [@danzel](https://github.com/danzel)). [#862](https://github.com/Leaflet/Leaflet/pull/862)
|
||||
* Fixed a bug where `FeatureGroup` `removeLayer` would unbind popups of removed layers even if the popups were not put by the group (affected [Leaflet.markercluster](https://github.com/danzel/Leaflet.markercluster) plugin) (by [@danzel](https://github.com/danzel)). [#861](https://github.com/Leaflet/Leaflet/pull/861)
|
||||
|
||||
## 0.4.1 (July 31, 2012)
|
||||
|
||||
* Fixed a bug that caused marker shadows appear as opaque black in IE6-8. [#850](https://github.com/CloudMade/Leaflet/issues/850)
|
||||
* Fixed a bug with incorrect calculation of scale by the scale control. [#852](https://github.com/CloudMade/Leaflet/issues/852)
|
||||
* Fixed broken L.tileLayer.wms class factory (by [@mattcurrie](https://github.com/mattcurrie)). [#856](https://github.com/CloudMade/Leaflet/issues/856)
|
||||
* Improved retina detection for `TileLayer` `detectRetina` option (by [@sxua](https://github.com/sxua)). [#854](https://github.com/CloudMade/Leaflet/issues/854)
|
||||
* Fixed a bug that caused marker shadows appear as opaque black in IE6-8. [#850](https://github.com/Leaflet/Leaflet/issues/850)
|
||||
* Fixed a bug with incorrect calculation of scale by the scale control. [#852](https://github.com/Leaflet/Leaflet/issues/852)
|
||||
* Fixed broken L.tileLayer.wms class factory (by [@mattcurrie](https://github.com/mattcurrie)). [#856](https://github.com/Leaflet/Leaflet/issues/856)
|
||||
* Improved retina detection for `TileLayer` `detectRetina` option (by [@sxua](https://github.com/sxua)). [#854](https://github.com/Leaflet/Leaflet/issues/854)
|
||||
|
||||
## 0.4 (July 30, 2012)
|
||||
|
||||
@ -32,26 +168,26 @@ Leaflet 0.4 contains several API improvements that allow simpler, jQuery-like sy
|
||||
### Notable new features
|
||||
|
||||
* Added configurable **panning inertia** - after a quick pan, the map slows down in the same direction.
|
||||
* Added **keyboard navigation** for panning/zooming with keyboard arrows and +/- keys (by [@ericmmartinez](https://github.com/ericmmartinez)). [#663](https://github.com/CloudMade/Leaflet/pull/663) [#646](https://github.com/CloudMade/Leaflet/issues/646)
|
||||
* Added smooth **zoom animation of markers, vector layers, image overlays and popups** (by [@danzel](https://github.com/danzel)). [#740](https://github.com/CloudMade/Leaflet/pull/740) [#758](https://github.com/CloudMade/Leaflet/issues/758)
|
||||
* Added **Android 4+ pinch-zoom** support (by [@danzel](https://github.com/danzel)). [#774](https://github.com/CloudMade/Leaflet/pull/774)
|
||||
* Added **polyline and polygon editing**. [#174](https://github.com/CloudMade/Leaflet/issues/174)
|
||||
* Added **keyboard navigation** for panning/zooming with keyboard arrows and +/- keys (by [@ericmmartinez](https://github.com/ericmmartinez)). [#663](https://github.com/Leaflet/Leaflet/pull/663) [#646](https://github.com/Leaflet/Leaflet/issues/646)
|
||||
* Added smooth **zoom animation of markers, vector layers, image overlays and popups** (by [@danzel](https://github.com/danzel)). [#740](https://github.com/Leaflet/Leaflet/pull/740) [#758](https://github.com/Leaflet/Leaflet/issues/758)
|
||||
* Added **Android 4+ pinch-zoom** support (by [@danzel](https://github.com/danzel)). [#774](https://github.com/Leaflet/Leaflet/pull/774)
|
||||
* Added **polyline and polygon editing**. [#174](https://github.com/Leaflet/Leaflet/issues/174)
|
||||
* Added an unobtrusive **scale control**.
|
||||
* Added **DivIcon** class that easily allows you to create lightweight div-based markers.
|
||||
* Added **Rectangle** vector layer (by [@JasonSanford](https://github.com/JasonSanford)). [#504](https://github.com/CloudMade/Leaflet/pull/504)
|
||||
* Added **Rectangle** vector layer (by [@JasonSanford](https://github.com/JasonSanford)). [#504](https://github.com/Leaflet/Leaflet/pull/504)
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
* Improved zooming so that you don't get a blank map when you zoom in or out twice quickly (by [@danzel](https://github.com/danzel)). [#7](https://github.com/CloudMade/Leaflet/issues/7) [#729](https://github.com/CloudMade/Leaflet/pull/729)
|
||||
* Drag-panning now works even when there are markers in the starting point (helps on maps with lots of markers). [#506](https://github.com/CloudMade/Leaflet/issues/506)
|
||||
* Improved zooming so that you don't get a blank map when you zoom in or out twice quickly (by [@danzel](https://github.com/danzel)). [#7](https://github.com/Leaflet/Leaflet/issues/7) [#729](https://github.com/Leaflet/Leaflet/pull/729)
|
||||
* Drag-panning now works even when there are markers in the starting point (helps on maps with lots of markers). [#506](https://github.com/Leaflet/Leaflet/issues/506)
|
||||
* Improved panning performance even more (there are no wasted frames now).
|
||||
* Improved pinch-zoom performance in mobile Chrome and Firefox.
|
||||
* Improved map performance on window resize.
|
||||
* Replaced box-shadow with border on controls for mobile devices to improve performance.
|
||||
* Slightly improved default popup styling.
|
||||
* Added `TileLayer` `detectRetina` option (`false` by default) that makes tiles show in a higher resolution on iOS retina displays (by [@Mithgol](https://github.com/Mithgol)). [#586](https://github.com/CloudMade/Leaflet/pull/586)
|
||||
* Added `TileLayer` `detectRetina` option (`false` by default) that makes tiles show in a higher resolution on iOS retina displays (by [@Mithgol](https://github.com/Mithgol)). [#586](https://github.com/Leaflet/Leaflet/pull/586)
|
||||
|
||||
#### GeoJSON API changes
|
||||
|
||||
@ -89,100 +225,100 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
|
||||
#### Other API improvements
|
||||
|
||||
* Improved `on` and `off` methods to also accept `(eventHash[, context])`, as well as multiple space-separated events (by [@Guiswa](https://github.com/Guiswa)). [#770](https://github.com/CloudMade/Leaflet/pull/770)
|
||||
* Improved `off` to remove all listeners of the event if no function was specified (by [@Guiswa](https://github.com/Guiswa)). [#770](https://github.com/CloudMade/Leaflet/pull/770) [#691](https://github.com/CloudMade/Leaflet/issues/691)
|
||||
* Added `TileLayer` `setZIndex` method for controlling the order of tile layers (thanks to [@mattcurrie](https://github.com/mattcurrie)). [#837](https://github.com/CloudMade/Leaflet/pull/837)
|
||||
* Improved `on` and `off` methods to also accept `(eventHash[, context])`, as well as multiple space-separated events (by [@Guiswa](https://github.com/Guiswa)). [#770](https://github.com/Leaflet/Leaflet/pull/770)
|
||||
* Improved `off` to remove all listeners of the event if no function was specified (by [@Guiswa](https://github.com/Guiswa)). [#770](https://github.com/Leaflet/Leaflet/pull/770) [#691](https://github.com/Leaflet/Leaflet/issues/691)
|
||||
* Added `TileLayer` `setZIndex` method for controlling the order of tile layers (thanks to [@mattcurrie](https://github.com/mattcurrie)). [#837](https://github.com/Leaflet/Leaflet/pull/837)
|
||||
* Added `Control.Layers` `autoZIndex` option (on by default) to preserve the order of tile layers when switching.
|
||||
* Added `TileLayer` `redraw` method for re-requesting tiles (by [@greeninfo](https://github.com/greeninfo)). [#719](https://github.com/CloudMade/Leaflet/issues/719)
|
||||
* Added `TileLayer` `redraw` method for re-requesting tiles (by [@greeninfo](https://github.com/greeninfo)). [#719](https://github.com/Leaflet/Leaflet/issues/719)
|
||||
* Added `TileLayer` `setUrl` method for dynamically changing the tile URL template.
|
||||
* Added `bringToFront` and `bringToBack` methods to `TileLayer`, `ImageOverlay` and vector layers. [#185](https://github.com/CloudMade/Leaflet/issues/185) [#505](https://github.com/CloudMade/Leaflet/issues/505)
|
||||
* Added `TileLayer` `loading` event that fires when its tiles start to load (thanks to [@lapinos03](https://github.com/lapinos03)). [#177](https://github.com/CloudMade/Leaflet/issues/177)
|
||||
* Added `TileLayer.WMS` `setParams` method for setting WMS parameters at runtime (by [@greeninfo](https://github.com/greeninfo)). [#719](https://github.com/CloudMade/Leaflet/issues/719)
|
||||
* Added `TileLayer.WMS` subdomain support (`{s}` in the url) (by [@greeninfo](https://github.com/greeninfo)). [#735](https://github.com/CloudMade/Leaflet/issues/735)
|
||||
* Added `originalEvent` property to `MouseEvent` (by [@k4](https://github.com/k4)). [#521](https://github.com/CloudMade/Leaflet/pull/521)
|
||||
* Added `containerPoint` property to `MouseEvent`. [#413](https://github.com/CloudMade/Leaflet/issues/413)
|
||||
* Added `contextmenu` event to vector layers (by [@ErrorProne](https://github.com/ErrorProne)). [#500](https://github.com/CloudMade/Leaflet/pull/500)
|
||||
* Added `bringToFront` and `bringToBack` methods to `TileLayer`, `ImageOverlay` and vector layers. [#185](https://github.com/Leaflet/Leaflet/issues/185) [#505](https://github.com/Leaflet/Leaflet/issues/505)
|
||||
* Added `TileLayer` `loading` event that fires when its tiles start to load (thanks to [@lapinos03](https://github.com/lapinos03)). [#177](https://github.com/Leaflet/Leaflet/issues/177)
|
||||
* Added `TileLayer.WMS` `setParams` method for setting WMS parameters at runtime (by [@greeninfo](https://github.com/greeninfo)). [#719](https://github.com/Leaflet/Leaflet/issues/719)
|
||||
* Added `TileLayer.WMS` subdomain support (`{s}` in the url) (by [@greeninfo](https://github.com/greeninfo)). [#735](https://github.com/Leaflet/Leaflet/issues/735)
|
||||
* Added `originalEvent` property to `MouseEvent` (by [@k4](https://github.com/k4)). [#521](https://github.com/Leaflet/Leaflet/pull/521)
|
||||
* Added `containerPoint` property to `MouseEvent`. [#413](https://github.com/Leaflet/Leaflet/issues/413)
|
||||
* Added `contextmenu` event to vector layers (by [@ErrorProne](https://github.com/ErrorProne)). [#500](https://github.com/Leaflet/Leaflet/pull/500)
|
||||
* Added `LayerGroup` `eachLayer` method for iterating over its members.
|
||||
* Added `FeatureGroup` `mousemove` and `contextmenu` events (by [@jacobtoye](https://github.com/jacobtoye)). [#816](https://github.com/CloudMade/Leaflet/pull/816)
|
||||
* Added `FeatureGroup` `mousemove` and `contextmenu` events (by [@jacobtoye](https://github.com/jacobtoye)). [#816](https://github.com/Leaflet/Leaflet/pull/816)
|
||||
* Added chaining to `DomEvent` methods.
|
||||
* Added `on` and `off` aliases for `DomEvent` `addListener` and `removeListener` methods.
|
||||
* Added `L_NO_TOUCH` global variable switch (set it before Leaflet inclusion) which disables touch detection, helpful for desktop apps built using QT. [#572](https://github.com/CloudMade/Leaflet/issues/572)
|
||||
* Added `dashArray` option to vector layers for making dashed strokes (by [jacobtoye](https://github.com/jacobtoye)). [#821](https://github.com/CloudMade/Leaflet/pull/821) [#165](https://github.com/CloudMade/Leaflet/issues/165)
|
||||
* Added `Circle` `getBounds` method. [#440](https://github.com/CloudMade/Leaflet/issues/440)
|
||||
* Added `Circle` `getLatLng` and `getRadius` methods (by [@Guiswa](https://github.com/Guiswa)). [#655](https://github.com/CloudMade/Leaflet/pull/655)
|
||||
* Added `openPopup` method to all vector layers. [#246](https://github.com/CloudMade/Leaflet/issues/246)
|
||||
* Added `L_NO_TOUCH` global variable switch (set it before Leaflet inclusion) which disables touch detection, helpful for desktop apps built using QT. [#572](https://github.com/Leaflet/Leaflet/issues/572)
|
||||
* Added `dashArray` option to vector layers for making dashed strokes (by [jacobtoye](https://github.com/jacobtoye)). [#821](https://github.com/Leaflet/Leaflet/pull/821) [#165](https://github.com/Leaflet/Leaflet/issues/165)
|
||||
* Added `Circle` `getBounds` method. [#440](https://github.com/Leaflet/Leaflet/issues/440)
|
||||
* Added `Circle` `getLatLng` and `getRadius` methods (by [@Guiswa](https://github.com/Guiswa)). [#655](https://github.com/Leaflet/Leaflet/pull/655)
|
||||
* Added `openPopup` method to all vector layers. [#246](https://github.com/Leaflet/Leaflet/issues/246)
|
||||
* Added public `redraw` method to vector layers (useful if you manipulate their `LatLng` points directly).
|
||||
* Added `Marker` `opacity` option and `setOpacity` method.
|
||||
* Added `Marker` `update` method. [#392](https://github.com/CloudMade/Leaflet/issues/392)
|
||||
* Improved `Marker` `openPopup` not to raise an error if it doesn't have a popup. [#507](https://github.com/CloudMade/Leaflet/issues/507)
|
||||
* Added `ImageOverlay` `opacity` option and `setOpacity` method. [#438](https://github.com/CloudMade/Leaflet/issues/438)
|
||||
* Added `Marker` `update` method. [#392](https://github.com/Leaflet/Leaflet/issues/392)
|
||||
* Improved `Marker` `openPopup` not to raise an error if it doesn't have a popup. [#507](https://github.com/Leaflet/Leaflet/issues/507)
|
||||
* Added `ImageOverlay` `opacity` option and `setOpacity` method. [#438](https://github.com/Leaflet/Leaflet/issues/438)
|
||||
* Added `Popup` `maxHeight` option that makes content inside the popup scrolled if it doesn't fit the specified max height.
|
||||
* Added `Popup` `openOn(map)` method (similar to `Map` `openPopup`).
|
||||
* Added `Map` `getContainer` method (by [@Guiswa](https://github.com/Guiswa)). [#654](https://github.com/CloudMade/Leaflet/pull/654)
|
||||
* Added `Map` `containerPointToLatLng` and `latLngToContainerPoint` methods. [#474](https://github.com/CloudMade/Leaflet/issues/474)
|
||||
* Added `Map` `getContainer` method (by [@Guiswa](https://github.com/Guiswa)). [#654](https://github.com/Leaflet/Leaflet/pull/654)
|
||||
* Added `Map` `containerPointToLatLng` and `latLngToContainerPoint` methods. [#474](https://github.com/Leaflet/Leaflet/issues/474)
|
||||
* Added `Map` `addHandler` method.
|
||||
* Added `Map` `mouseup` and `autopanstart` events.
|
||||
* Added `LatLngBounds` `pad` method that returns bounds extended by a percentage (by [@jacobtoye](https://github.com/jacobtoye)). [#492](https://github.com/CloudMade/Leaflet/pull/492)
|
||||
* Added `LatLngBounds` `pad` method that returns bounds extended by a percentage (by [@jacobtoye](https://github.com/jacobtoye)). [#492](https://github.com/Leaflet/Leaflet/pull/492)
|
||||
* Moved dragging cursor styles from JS code to CSS.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed a bug where the map was zooming incorrectly inside a `position: fixed` container (by [@chx007](https://github.com/chx007)). [#602](https://github.com/CloudMade/Leaflet/pull/602)
|
||||
* Fixed a bug where scaled tiles weren't cleared up after zoom in some cases (by [@cfis](https://github.com/cfis)) [#683](https://github.com/CloudMade/Leaflet/pull/683)
|
||||
* Fixed a bug where map wouldn't drag over a polygon with a `mousedown` listener. [#834](https://github.com/CloudMade/Leaflet/issues/834)
|
||||
* Fixed a bug where the map was zooming incorrectly inside a `position: fixed` container (by [@chx007](https://github.com/chx007)). [#602](https://github.com/Leaflet/Leaflet/pull/602)
|
||||
* Fixed a bug where scaled tiles weren't cleared up after zoom in some cases (by [@cfis](https://github.com/cfis)) [#683](https://github.com/Leaflet/Leaflet/pull/683)
|
||||
* Fixed a bug where map wouldn't drag over a polygon with a `mousedown` listener. [#834](https://github.com/Leaflet/Leaflet/issues/834)
|
||||
|
||||
#### API bugfixes
|
||||
|
||||
* Fixed a regression where removeLayer would not remove corresponding attribution. [#488](https://github.com/CloudMade/Leaflet/issues/488)
|
||||
* Fixed a bug where popup close button wouldn't work on manually added popups. [#423](https://github.com/CloudMade/Leaflet/issues/423)
|
||||
* Fixed a bug where marker click event would stop working if you dragged it and then disabled dragging. [#434](https://github.com/CloudMade/Leaflet/issues/434)
|
||||
* Fixed a regression where removeLayer would not remove corresponding attribution. [#488](https://github.com/Leaflet/Leaflet/issues/488)
|
||||
* Fixed a bug where popup close button wouldn't work on manually added popups. [#423](https://github.com/Leaflet/Leaflet/issues/423)
|
||||
* Fixed a bug where marker click event would stop working if you dragged it and then disabled dragging. [#434](https://github.com/Leaflet/Leaflet/issues/434)
|
||||
* Fixed a bug where `TileLayer` `setOpacity` wouldn't work when setting it back to 1.
|
||||
* Fixed a bug where vector layer `setStyle({stroke: false})` wouldn't remove stroke and the same for fill. [#441](https://github.com/CloudMade/Leaflet/issues/441)
|
||||
* Fixed a bug where vector layer `setStyle({stroke: false})` wouldn't remove stroke and the same for fill. [#441](https://github.com/Leaflet/Leaflet/issues/441)
|
||||
* Fixed a bug where `Marker` `bindPopup` method wouldn't take `offset` option into account.
|
||||
* Fixed a bug where `TileLayer` `load` event wasn't fired if some tile didn't load (by [@lapinos03](https://github.com/lapinos03) and [@cfis](https://github.com/cfis)) [#682](https://github.com/CloudMade/Leaflet/pull/682)
|
||||
* Fixed error when removing `GeoJSON` layer. [#685](https://github.com/CloudMade/Leaflet/issues/685)
|
||||
* Fixed error when calling `GeoJSON` `clearLayer` (by [@runderwood](https://github.com/runderwood)). [#617](https://github.com/CloudMade/Leaflet/pull/617)
|
||||
* Fixed a bug where `Control` `setPosition` wasn't always working correctly (by [@ericmmartinez](https://github.com/ericmmartinez)). [#657](https://github.com/CloudMade/Leaflet/pull/657)
|
||||
* Fixed a bug with `Util.bind` sometimes losing arguments (by [@johtso](https://github.com/johtso)). [#588](https://github.com/CloudMade/Leaflet/pull/588)
|
||||
* Fixed a bug where `drag` event was sometimes fired after `dragend`. [#555](https://github.com/CloudMade/Leaflet/issues/555)
|
||||
* Fixed a bug where `TileLayer` `load` event was firing only once (by [@lapinos03](https://github.com/lapinos03) and [shintonik](https://github.com/shintonik)). [#742](https://github.com/CloudMade/Leaflet/pull/742) [#177](https://github.com/CloudMade/Leaflet/issues/177)
|
||||
* Fixed a bug where `FeatureGroup` popup events where not cleaned up after removing a layer from it (by [@danzel](https://github.com/danzel)). [#775](https://github.com/CloudMade/Leaflet/pull/775)
|
||||
* Fixed a bug where `DomUtil.removeClass` didn't remove trailing spaces (by [@jieter](https://github.com/jieter)). [#784](https://github.com/CloudMade/Leaflet/pull/784)
|
||||
* Fixed a bug where `TileLayer` `load` event wasn't fired if some tile didn't load (by [@lapinos03](https://github.com/lapinos03) and [@cfis](https://github.com/cfis)) [#682](https://github.com/Leaflet/Leaflet/pull/682)
|
||||
* Fixed error when removing `GeoJSON` layer. [#685](https://github.com/Leaflet/Leaflet/issues/685)
|
||||
* Fixed error when calling `GeoJSON` `clearLayer` (by [@runderwood](https://github.com/runderwood)). [#617](https://github.com/Leaflet/Leaflet/pull/617)
|
||||
* Fixed a bug where `Control` `setPosition` wasn't always working correctly (by [@ericmmartinez](https://github.com/ericmmartinez)). [#657](https://github.com/Leaflet/Leaflet/pull/657)
|
||||
* Fixed a bug with `Util.bind` sometimes losing arguments (by [@johtso](https://github.com/johtso)). [#588](https://github.com/Leaflet/Leaflet/pull/588)
|
||||
* Fixed a bug where `drag` event was sometimes fired after `dragend`. [#555](https://github.com/Leaflet/Leaflet/issues/555)
|
||||
* Fixed a bug where `TileLayer` `load` event was firing only once (by [@lapinos03](https://github.com/lapinos03) and [shintonik](https://github.com/shintonik)). [#742](https://github.com/Leaflet/Leaflet/pull/742) [#177](https://github.com/Leaflet/Leaflet/issues/177)
|
||||
* Fixed a bug where `FeatureGroup` popup events where not cleaned up after removing a layer from it (by [@danzel](https://github.com/danzel)). [#775](https://github.com/Leaflet/Leaflet/pull/775)
|
||||
* Fixed a bug where `DomUtil.removeClass` didn't remove trailing spaces (by [@jieter](https://github.com/jieter)). [#784](https://github.com/Leaflet/Leaflet/pull/784)
|
||||
* Fixed a bug where marker popup didn't take popup offset into account.
|
||||
* Fixed a bug that led to an error when polyline was removed inside a `moveend` listener.
|
||||
* Fixed a bug where `LayerGroup` `addLayer` wouldn't check if a layer has already been added (by [@danzel](https://github.com/danzel)). [798](https://github.com/CloudMade/Leaflet/pull/798)
|
||||
* Fixed a bug where `LayerGroup` `addLayer` wouldn't check if a layer has already been added (by [@danzel](https://github.com/danzel)). [798](https://github.com/Leaflet/Leaflet/pull/798)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed broken zooming on IE10 beta (by [@danzel](https://github.com/danzel)). [#650](https://github.com/CloudMade/Leaflet/issues/650) [#751](https://github.com/CloudMade/Leaflet/pull/751)
|
||||
* Fixed a bug that broke Leaflet for websites that had XHTML content-type header set (by [lars-sh](https://github.com/lars-sh)). [#801](https://github.com/CloudMade/Leaflet/pull/801)
|
||||
* Fixed a bug that caused popups to be empty in IE when passing a DOM node as the content (by [@nrenner](https://github.com/nrenner)). [#472](https://github.com/CloudMade/Leaflet/pull/472)
|
||||
* Fixed broken zooming on IE10 beta (by [@danzel](https://github.com/danzel)). [#650](https://github.com/Leaflet/Leaflet/issues/650) [#751](https://github.com/Leaflet/Leaflet/pull/751)
|
||||
* Fixed a bug that broke Leaflet for websites that had XHTML content-type header set (by [lars-sh](https://github.com/lars-sh)). [#801](https://github.com/Leaflet/Leaflet/pull/801)
|
||||
* Fixed a bug that caused popups to be empty in IE when passing a DOM node as the content (by [@nrenner](https://github.com/nrenner)). [#472](https://github.com/Leaflet/Leaflet/pull/472)
|
||||
* Fixed inability to use scrolled content inside popup due to mouse wheel propagation.
|
||||
* Fixed a bug that caused jumping/stuttering of panning animation in some cases.
|
||||
* Fixed a bug where popup size was calculated incorrectly in IE.
|
||||
* Fixed a bug where cursor would flicker when dragging a marker.
|
||||
* Fixed a bug where clickable paths on IE9 didn't have a hand cursor (by [naehrstoff](https://github.com/naehrstoff)). [#671](https://github.com/CloudMade/Leaflet/pull/671)
|
||||
* Fixed a bug in IE with disappearing icons when changing opacity (by [@tagliala](https://github.com/tagliala) and [DamonOehlman](https://github.com/DamonOehlman)). [#667](https://github.com/CloudMade/Leaflet/pull/667) [#600](https://github.com/CloudMade/Leaflet/pull/600)
|
||||
* Fixed a bug with setting opacity on IE10 (by [@danzel](https://github.com/danzel)). [796](https://github.com/CloudMade/Leaflet/pull/796)
|
||||
* Fixed a bug where `Control.Layers` didn't work on IE7. [#652](https://github.com/CloudMade/Leaflet/issues/652)
|
||||
* Fixed a bug that could cause false `mousemove` events on click in Chrome (by [@stsydow](https://github.com/stsydow)). [#757](https://github.com/CloudMade/Leaflet/pull/757)
|
||||
* Fixed a bug in IE6-8 where adding fill or stroke on vector layers after initialization with `setStyle` would break the map. [#641](https://github.com/CloudMade/Leaflet/issues/641)
|
||||
* Fixed a bug with setOpacity in IE where it would not work correctly if used more than once on the same element (by [@ajbeaven](https://github.com/ajbeaven)). [#827](https://github.com/CloudMade/Leaflet/pull/827)
|
||||
* Fixed a bug in Chrome where transparent control corners sometimes couldn't be clicked through (by [@danzel](https://github.com/danzel)). [#836](https://github.com/CloudMade/Leaflet/pull/836) [#575](https://github.com/CloudMade/Leaflet/issues/575)
|
||||
* Fixed a bug where clickable paths on IE9 didn't have a hand cursor (by [naehrstoff](https://github.com/naehrstoff)). [#671](https://github.com/Leaflet/Leaflet/pull/671)
|
||||
* Fixed a bug in IE with disappearing icons when changing opacity (by [@tagliala](https://github.com/tagliala) and [DamonOehlman](https://github.com/DamonOehlman)). [#667](https://github.com/Leaflet/Leaflet/pull/667) [#600](https://github.com/Leaflet/Leaflet/pull/600)
|
||||
* Fixed a bug with setting opacity on IE10 (by [@danzel](https://github.com/danzel)). [796](https://github.com/Leaflet/Leaflet/pull/796)
|
||||
* Fixed a bug where `Control.Layers` didn't work on IE7. [#652](https://github.com/Leaflet/Leaflet/issues/652)
|
||||
* Fixed a bug that could cause false `mousemove` events on click in Chrome (by [@stsydow](https://github.com/stsydow)). [#757](https://github.com/Leaflet/Leaflet/pull/757)
|
||||
* Fixed a bug in IE6-8 where adding fill or stroke on vector layers after initialization with `setStyle` would break the map. [#641](https://github.com/Leaflet/Leaflet/issues/641)
|
||||
* Fixed a bug with setOpacity in IE where it would not work correctly if used more than once on the same element (by [@ajbeaven](https://github.com/ajbeaven)). [#827](https://github.com/Leaflet/Leaflet/pull/827)
|
||||
* Fixed a bug in Chrome where transparent control corners sometimes couldn't be clicked through (by [@danzel](https://github.com/danzel)). [#836](https://github.com/Leaflet/Leaflet/pull/836) [#575](https://github.com/Leaflet/Leaflet/issues/575)
|
||||
|
||||
#### Mobile browser bugfixes
|
||||
|
||||
* Fixed a bug that sometimes caused map to disappear completely after zoom on iOS (by [@fr1n63](https://github.com/fr1n63)). [#580](https://github.com/CloudMade/Leaflet/issues/580) [#777](https://github.com/CloudMade/Leaflet/pull/777)
|
||||
* Fixed a bug that often caused vector layers to flicker on drag end on iOS (by [@krawaller](https://github.com/krawaller)). [#18](https://github.com/CloudMade/Leaflet/issues/18)
|
||||
* Fixed a bug with false map click events on pinch-zoom and zoom/layers controls click. [#485](https://github.com/CloudMade/Leaflet/issues/485)
|
||||
* Fixed a bug that sometimes caused map to disappear completely after zoom on iOS (by [@fr1n63](https://github.com/fr1n63)). [#580](https://github.com/Leaflet/Leaflet/issues/580) [#777](https://github.com/Leaflet/Leaflet/pull/777)
|
||||
* Fixed a bug that often caused vector layers to flicker on drag end on iOS (by [@krawaller](https://github.com/krawaller)). [#18](https://github.com/Leaflet/Leaflet/issues/18)
|
||||
* Fixed a bug with false map click events on pinch-zoom and zoom/layers controls click. [#485](https://github.com/Leaflet/Leaflet/issues/485)
|
||||
* Fixed a bug where touching the map with two or more fingers simultaneously would raise an error.
|
||||
* Fixed a bug where zoom control wasn't always visible on Android 3. [#335](https://github.com/CloudMade/Leaflet/issues/335)
|
||||
* Fixed a bug where opening the layers control would propagate a click to the map (by [@jacobtoye](https://github.com/jacobtoye)). [#638](https://github.com/CloudMade/Leaflet/pull/638)
|
||||
* Fixed a bug where `ImageOverlay` wouldn't stretch properly on zoom on Android 2. [#651](https://github.com/CloudMade/Leaflet/issues/651)
|
||||
* Fixed a bug where `clearLayers` for vector layers on a Canvas backend (e.g. on Android 2) would take unreasonable amount of time. [#785](https://github.com/CloudMade/Leaflet/issues/785)
|
||||
* Fixed a bug where `setLatLngs` and similar methods on vector layers on a Canvas backend would not update the layers immediately. [#732](https://github.com/CloudMade/Leaflet/issues/732)
|
||||
* Fixed a bug where zoom control wasn't always visible on Android 3. [#335](https://github.com/Leaflet/Leaflet/issues/335)
|
||||
* Fixed a bug where opening the layers control would propagate a click to the map (by [@jacobtoye](https://github.com/jacobtoye)). [#638](https://github.com/Leaflet/Leaflet/pull/638)
|
||||
* Fixed a bug where `ImageOverlay` wouldn't stretch properly on zoom on Android 2. [#651](https://github.com/Leaflet/Leaflet/issues/651)
|
||||
* Fixed a bug where `clearLayers` for vector layers on a Canvas backend (e.g. on Android 2) would take unreasonable amount of time. [#785](https://github.com/Leaflet/Leaflet/issues/785)
|
||||
* Fixed a bug where `setLatLngs` and similar methods on vector layers on a Canvas backend would not update the layers immediately. [#732](https://github.com/Leaflet/Leaflet/issues/732)
|
||||
|
||||
## 0.3.1 (February 14, 2012)
|
||||
|
||||
@ -195,15 +331,15 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
|
||||
* Added **Canvas backend** for vector layers (polylines, polygons, circles). This enables vector support on Android < 3, and it can also be optionally preferred over SVG for a performance gain in some cases. Thanks to [@florianf](https://github.com/florianf) for a big part of this work.
|
||||
* Added **layers control** (`Control.Layers`) for convenient layer switching.
|
||||
* Added ability to set **max bounds** within which users can pan/zoom. [#93](https://github.com/CloudMade/Leaflet/issues/93)
|
||||
* Added ability to set **max bounds** within which users can pan/zoom. [#93](https://github.com/Leaflet/Leaflet/issues/93)
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
* Map now preserves its center after resize.
|
||||
* When panning to another copy of the world (that's infinite horizontally), map overlays now jump to corresponding positions. [#273](https://github.com/CloudMade/Leaflet/issues/273)
|
||||
* Limited maximum zoom change on a single mouse wheel movement (so you won't zoom across the whole zoom range in one scroll). [#149](https://github.com/CloudMade/Leaflet/issues/149)
|
||||
* When panning to another copy of the world (that's infinite horizontally), map overlays now jump to corresponding positions. [#273](https://github.com/Leaflet/Leaflet/issues/273)
|
||||
* Limited maximum zoom change on a single mouse wheel movement (so you won't zoom across the whole zoom range in one scroll). [#149](https://github.com/Leaflet/Leaflet/issues/149)
|
||||
* Significantly improved line simplification performance (noticeable when rendering polylines/polygons with tens of thousands of points)
|
||||
* Improved circles performance by not drawing them if they're off the clip region.
|
||||
* Improved stability of zoom animation (less flickering of tiles).
|
||||
@ -211,37 +347,37 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
#### API improvements
|
||||
|
||||
* Added ability to add a tile layer below all others (`map.addLayer(layer, true)`) (useful for switching base tile layers).
|
||||
* Added `Map` `zoomstart` event (thanks to [@Fabiz](https://github.com/Fabiz)). [#377](https://github.com/CloudMade/Leaflet/pull/377)
|
||||
* Improved `Map` `locate` method, added ability to watch location continuously and more options. [#212](https://github.com/CloudMade/Leaflet/issues/212)
|
||||
* Added `Map` `zoomstart` event (thanks to [@Fabiz](https://github.com/Fabiz)). [#377](https://github.com/Leaflet/Leaflet/pull/377)
|
||||
* Improved `Map` `locate` method, added ability to watch location continuously and more options. [#212](https://github.com/Leaflet/Leaflet/issues/212)
|
||||
* Added second argument `inside` to `Map` `getBoundsZoom` method that allows you to get appropriate zoom for the view to fit *inside* the given bounds.
|
||||
* Added `hasLayer` method to `Map`.
|
||||
* Added `Marker` `zIndexOffset` option to be able to set certain markers below/above others. [#65](https://github.com/CloudMade/Leaflet/issues/65)
|
||||
* Added `Marker` `zIndexOffset` option to be able to set certain markers below/above others. [#65](https://github.com/Leaflet/Leaflet/issues/65)
|
||||
* Added `urlParams` third optional argument to `TileLayer` constructor for convenience: an object with properties that will be evaluated in the URL template.
|
||||
* Added `TileLayer` `continuousWorld` option to disable tile coordinates checking/wrapping.
|
||||
* Added `TileLayer` `tileunload` event fired when tile gets removed after panning (by [@CodeJosch](https://github.com/CodeJosch)). [#256](https://github.com/CloudMade/Leaflet/pull/256)
|
||||
* Added `TileLayer` `tileunload` event fired when tile gets removed after panning (by [@CodeJosch](https://github.com/CodeJosch)). [#256](https://github.com/Leaflet/Leaflet/pull/256)
|
||||
* Added `TileLayer` `zoomOffset` option useful for non-256px tiles (by [@msaspence](https://github.com/msaspence)).
|
||||
* Added `TileLayer` `zoomReverse` option to reverse zoom numbering (by [@Majiir](https://github.com/Majiir)). [#406](https://github.com/CloudMade/Leaflet/pull/406)
|
||||
* Added `TileLayer.Canvas` `redraw` method (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#459](https://github.com/CloudMade/Leaflet/pull/459)
|
||||
* Added `Polyline` `closestLayerPoint` method that's can be useful for interaction features (by [@anru](https://github.com/anru)). [#186](https://github.com/CloudMade/Leaflet/pull/186)
|
||||
* Added `setLatLngs` method to `MultiPolyline` and `MultiPolygon` (by [@anru](https://github.com/anru)). [#194](https://github.com/CloudMade/Leaflet/pull/194)
|
||||
* Added `getBounds` method to `Polyline` and `Polygon` (by [@JasonSanford](https://github.com/JasonSanford)). [#253](https://github.com/CloudMade/Leaflet/pull/253)
|
||||
* Added `getBounds` method to `FeatureGroup` (by [@JasonSanford](https://github.com/JasonSanford)). [#557](https://github.com/CloudMade/Leaflet/pull/557)
|
||||
* Added `FeatureGroup` `setStyle` method (also inherited by `MultiPolyline` and `MultiPolygon`). [#353](https://github.com/CloudMade/Leaflet/issues/353)
|
||||
* Added `TileLayer` `zoomReverse` option to reverse zoom numbering (by [@Majiir](https://github.com/Majiir)). [#406](https://github.com/Leaflet/Leaflet/pull/406)
|
||||
* Added `TileLayer.Canvas` `redraw` method (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#459](https://github.com/Leaflet/Leaflet/pull/459)
|
||||
* Added `Polyline` `closestLayerPoint` method that's can be useful for interaction features (by [@anru](https://github.com/anru)). [#186](https://github.com/Leaflet/Leaflet/pull/186)
|
||||
* Added `setLatLngs` method to `MultiPolyline` and `MultiPolygon` (by [@anru](https://github.com/anru)). [#194](https://github.com/Leaflet/Leaflet/pull/194)
|
||||
* Added `getBounds` method to `Polyline` and `Polygon` (by [@JasonSanford](https://github.com/JasonSanford)). [#253](https://github.com/Leaflet/Leaflet/pull/253)
|
||||
* Added `getBounds` method to `FeatureGroup` (by [@JasonSanford](https://github.com/JasonSanford)). [#557](https://github.com/Leaflet/Leaflet/pull/557)
|
||||
* Added `FeatureGroup` `setStyle` method (also inherited by `MultiPolyline` and `MultiPolygon`). [#353](https://github.com/Leaflet/Leaflet/issues/353)
|
||||
* Added `FeatureGroup` `invoke` method to call a particular method on all layers of the group with the given arguments.
|
||||
* Added `ImageOverlay` `load` event. [#213](https://github.com/CloudMade/Leaflet/issues/213)
|
||||
* Added `minWidth` option to `Popup` (by [@marphi](https://github.com/marphi)). [#214](https://github.com/CloudMade/Leaflet/pull/214)
|
||||
* Improved `LatLng` constructor to be more tolerant (and throw descriptive error if latitude or longitude can't be interpreted as a number). [#136](https://github.com/CloudMade/Leaflet/issues/136)
|
||||
* Added `LatLng` `distanceTo` method (great circle distance) (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#462](https://github.com/CloudMade/Leaflet/pull/462)
|
||||
* Added `LatLngBounds` `toBBoxString` method for convenience (by [@JasonSanford](https://github.com/JasonSanford)). [#263](https://github.com/CloudMade/Leaflet/pull/263)
|
||||
* Added `LatLngBounds` `intersects(otherBounds)` method (thanks to [@pagameba](https://github.com/pagameba)). [#350](https://github.com/CloudMade/Leaflet/pull/350)
|
||||
* Made `LatLngBounds` `extend` method to accept other `LatLngBounds` in addition to `LatLng` (by [@JasonSanford](https://github.com/JasonSanford)). [#553](https://github.com/CloudMade/Leaflet/pull/553)
|
||||
* Added `Bounds` `intersects(otherBounds)` method. [#461](https://github.com/CloudMade/Leaflet/issues/461)
|
||||
* Added `ImageOverlay` `load` event. [#213](https://github.com/Leaflet/Leaflet/issues/213)
|
||||
* Added `minWidth` option to `Popup` (by [@marphi](https://github.com/marphi)). [#214](https://github.com/Leaflet/Leaflet/pull/214)
|
||||
* Improved `LatLng` constructor to be more tolerant (and throw descriptive error if latitude or longitude can't be interpreted as a number). [#136](https://github.com/Leaflet/Leaflet/issues/136)
|
||||
* Added `LatLng` `distanceTo` method (great circle distance) (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#462](https://github.com/Leaflet/Leaflet/pull/462)
|
||||
* Added `LatLngBounds` `toBBoxString` method for convenience (by [@JasonSanford](https://github.com/JasonSanford)). [#263](https://github.com/Leaflet/Leaflet/pull/263)
|
||||
* Added `LatLngBounds` `intersects(otherBounds)` method (thanks to [@pagameba](https://github.com/pagameba)). [#350](https://github.com/Leaflet/Leaflet/pull/350)
|
||||
* Made `LatLngBounds` `extend` method to accept other `LatLngBounds` in addition to `LatLng` (by [@JasonSanford](https://github.com/JasonSanford)). [#553](https://github.com/Leaflet/Leaflet/pull/553)
|
||||
* Added `Bounds` `intersects(otherBounds)` method. [#461](https://github.com/Leaflet/Leaflet/issues/461)
|
||||
* Added `L.Util.template` method for simple string template evaluation.
|
||||
* Added `DomUtil.removeClass` method (by [@anru](https://github.com/anru)).
|
||||
* Improved browser-specific code to rely more on feature detection rather than user agent string.
|
||||
* Improved superclass access mechanism to work with inheritance chains of 3 or more classes; now you should use `Klass.superclass` instead of `this.superclass` (by [@anru](https://github.com/anru)). [#179](https://github.com/CloudMade/Leaflet/pull/179)
|
||||
* Added `Map` `boxzoomstart` and `boxzoomend` events (by [@zedd45](https://github.com/zedd45)). [#554](https://github.com/CloudMade/Leaflet/pull/554)
|
||||
* Added `Popup` `contentupdate` event (by [@mehmeta](https://github.com/mehmeta)). [#548](https://github.com/CloudMade/Leaflet/pull/548)
|
||||
* Improved superclass access mechanism to work with inheritance chains of 3 or more classes; now you should use `Klass.superclass` instead of `this.superclass` (by [@anru](https://github.com/anru)). [#179](https://github.com/Leaflet/Leaflet/pull/179)
|
||||
* Added `Map` `boxzoomstart` and `boxzoomend` events (by [@zedd45](https://github.com/zedd45)). [#554](https://github.com/Leaflet/Leaflet/pull/554)
|
||||
* Added `Popup` `contentupdate` event (by [@mehmeta](https://github.com/mehmeta)). [#548](https://github.com/Leaflet/Leaflet/pull/548)
|
||||
|
||||
#### Breaking API changes
|
||||
|
||||
@ -257,54 +393,54 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exagerration into account). [#331](https://github.com/CloudMade/Leaflet/issues/331)
|
||||
* Fixed a bug where `Map` `getBounds` would work incorrectly on a date line cross. [#295](https://github.com/CloudMade/Leaflet/issues/295)
|
||||
* Fixed a bug where polygons and polylines sometimes rendered incorrectly on some zoom levels. [#381](https://github.com/CloudMade/Leaflet/issues/381)
|
||||
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exagerration into account). [#331](https://github.com/Leaflet/Leaflet/issues/331)
|
||||
* Fixed a bug where `Map` `getBounds` would work incorrectly on a date line cross. [#295](https://github.com/Leaflet/Leaflet/issues/295)
|
||||
* Fixed a bug where polygons and polylines sometimes rendered incorrectly on some zoom levels. [#381](https://github.com/Leaflet/Leaflet/issues/381)
|
||||
* Fixed a bug where fast mouse wheel zoom worked incorrectly when approaching min/max zoom values.
|
||||
* Fixed a bug where `GeoJSON` `pointToLayer` option wouldn't work in a `GeometryCollection`. [#391](https://github.com/CloudMade/Leaflet/issues/391)
|
||||
* Fixed a bug with incorrect rendering of GeoJSON on a date line cross. [#354](https://github.com/CloudMade/Leaflet/issues/354)
|
||||
* Fixed a bug where map panning would stuck forever after releasing the mouse over an iframe or a flash object (thanks to [@sten82](https://github.com/sten82)). [#297](https://github.com/CloudMade/Leaflet/pull/297) [#64](https://github.com/CloudMade/Leaflet/issues/64)
|
||||
* Fixed a bug where mouse wheel zoom worked incorrectly if map is inside scrolled container (partially by [@chrillo](https://github.com/chrillo)). [#206](https://github.com/CloudMade/Leaflet/issues/206)
|
||||
* Fixed a bug where it was possible to add the same listener twice. [#281](https://github.com/CloudMade/Leaflet/issues/281)
|
||||
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exaggeration into account). [#331](https://github.com/CloudMade/Leaflet/issues/331)
|
||||
* Fixed a bug where `Marker` `setIcon` was not working properly (by [@marphi](https://github.com/marphi)). [#218](https://github.com/CloudMade/Leaflet/pull/218) [#311](https://github.com/CloudMade/Leaflet/issues/311)
|
||||
* Fixed a bug where `Marker` `setLatLng` was not working if it's set before adding the marker to a map. [#222](https://github.com/CloudMade/Leaflet/issues/222)
|
||||
* Fixed a bug where marker popup would not move on `Marker` `setLatLng` (by [@tjarratt](https://github.com/tjarratt)). [#272](https://github.com/CloudMade/Leaflet/pull/272)
|
||||
* Fixed a bug where `GeoJSON` `pointToLayer` option wouldn't work in a `GeometryCollection`. [#391](https://github.com/Leaflet/Leaflet/issues/391)
|
||||
* Fixed a bug with incorrect rendering of GeoJSON on a date line cross. [#354](https://github.com/Leaflet/Leaflet/issues/354)
|
||||
* Fixed a bug where map panning would stuck forever after releasing the mouse over an iframe or a flash object (thanks to [@sten82](https://github.com/sten82)). [#297](https://github.com/Leaflet/Leaflet/pull/297) [#64](https://github.com/Leaflet/Leaflet/issues/64)
|
||||
* Fixed a bug where mouse wheel zoom worked incorrectly if map is inside scrolled container (partially by [@chrillo](https://github.com/chrillo)). [#206](https://github.com/Leaflet/Leaflet/issues/206)
|
||||
* Fixed a bug where it was possible to add the same listener twice. [#281](https://github.com/Leaflet/Leaflet/issues/281)
|
||||
* Fixed a bug where `Circle` was rendered with incorrect radius (didn't take projection exaggeration into account). [#331](https://github.com/Leaflet/Leaflet/issues/331)
|
||||
* Fixed a bug where `Marker` `setIcon` was not working properly (by [@marphi](https://github.com/marphi)). [#218](https://github.com/Leaflet/Leaflet/pull/218) [#311](https://github.com/Leaflet/Leaflet/issues/311)
|
||||
* Fixed a bug where `Marker` `setLatLng` was not working if it's set before adding the marker to a map. [#222](https://github.com/Leaflet/Leaflet/issues/222)
|
||||
* Fixed a bug where marker popup would not move on `Marker` `setLatLng` (by [@tjarratt](https://github.com/tjarratt)). [#272](https://github.com/Leaflet/Leaflet/pull/272)
|
||||
* Fixed a bug where static properties of a child class would not override the parent ones.
|
||||
* Fixed broken popup `closePopup` option (by [@jgerigmeyer](https://github.com/jgerigmeyer)).
|
||||
* Fixed a bug that caused en error when dragging marker with icon without shadow (by [@anru](https://github.com/anru)). [#178](https://github.com/CloudMade/Leaflet/issues/178)
|
||||
* Fixed a typo in `Bounds` `contains` method (by [@anru](https://github.com/anru)). [#180](https://github.com/CloudMade/Leaflet/pull/180)
|
||||
* Fixed a bug that caused en error when dragging marker with icon without shadow (by [@anru](https://github.com/anru)). [#178](https://github.com/Leaflet/Leaflet/issues/178)
|
||||
* Fixed a typo in `Bounds` `contains` method (by [@anru](https://github.com/anru)). [#180](https://github.com/Leaflet/Leaflet/pull/180)
|
||||
* Fixed a bug where creating an empty `Polygon` with `new L.Polygon()` would raise an error.
|
||||
* Fixed a bug where drag event fired before the actual movement of layer (by [@anru](https://github.com/anru)). [#197](https://github.com/CloudMade/Leaflet/pull/197)
|
||||
* Fixed a bug where map click caused an error if dragging is initially disabled. [#196](https://github.com/CloudMade/Leaflet/issues/196)
|
||||
* Fixed a bug where drag event fired before the actual movement of layer (by [@anru](https://github.com/anru)). [#197](https://github.com/Leaflet/Leaflet/pull/197)
|
||||
* Fixed a bug where map click caused an error if dragging is initially disabled. [#196](https://github.com/Leaflet/Leaflet/issues/196)
|
||||
* Fixed a bug where map `movestart` event would fire after zoom animation.
|
||||
* Fixed a bug where attribution prefix would not update on `setPrefix`. [#195](https://github.com/CloudMade/Leaflet/issues/195)
|
||||
* Fixed a bug where attribution prefix would not update on `setPrefix`. [#195](https://github.com/Leaflet/Leaflet/issues/195)
|
||||
* Fixed a bug where `TileLayer` `load` event wouldn't fire in some edge cases (by [@dravnic](https://github.com/dravnic)).
|
||||
* Fixed a bug related to clearing background tiles after zooming (by [@neno-giscloud](https://github.com/neno-giscloud) & [@dravnic](https://github.com/dravnic)).
|
||||
* Fixed a bug that sometimes caused map flickering after zoom animation.
|
||||
* Fixed a bug related to cleaning up after removing tile layers (by [@dravnic](https://github.com/dravnic)). [#276](https://github.com/CloudMade/Leaflet/pull/276)
|
||||
* Fixed a bug that made selecting text in the attribution control impossible. [#279](https://github.com/CloudMade/Leaflet/issues/279)
|
||||
* Fixed a bug when initializing a map in a non-empty div. [#278](https://github.com/CloudMade/Leaflet/issues/278)
|
||||
* Fixed a bug related to cleaning up after removing tile layers (by [@dravnic](https://github.com/dravnic)). [#276](https://github.com/Leaflet/Leaflet/pull/276)
|
||||
* Fixed a bug that made selecting text in the attribution control impossible. [#279](https://github.com/Leaflet/Leaflet/issues/279)
|
||||
* Fixed a bug when initializing a map in a non-empty div. [#278](https://github.com/Leaflet/Leaflet/issues/278)
|
||||
* Fixed a bug where `movestart` didn't fire on panning animation.
|
||||
* Fixed a bug in Elliptical Mercator formula that affeted `EPSG:3395` CRS (by [@Savvkin](https://github.com/Savvkin)). [#358](https://github.com/CloudMade/Leaflet/pull/358)
|
||||
* Fixed a bug in Elliptical Mercator formula that affeted `EPSG:3395` CRS (by [@Savvkin](https://github.com/Savvkin)). [#358](https://github.com/Leaflet/Leaflet/pull/358)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed occasional crashes on Mac Safari (thanks to [@lapinos03](https://github.com/lapinos03)). [#191](https://github.com/CloudMade/Leaflet/issues/191)
|
||||
* Fixed a bug where resizing the map would sometimes make it blurry on WebKit (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#453](https://github.com/CloudMade/Leaflet/pull/453)
|
||||
* Fixed a bug that raised error in IE6-8 when clicking on popup close button. [#235](https://github.com/CloudMade/Leaflet/issues/235)
|
||||
* Fixed a bug with Safari not redrawing UI immediately after closing a popup. [#296](https://github.com/CloudMade/Leaflet/issues/296)
|
||||
* Fixed a bug that caused performance drop and high CPU usage when calling `setView` or `panTo` to the current center. [#231](https://github.com/CloudMade/Leaflet/issues/231)
|
||||
* Fixed occasional crashes on Mac Safari (thanks to [@lapinos03](https://github.com/lapinos03)). [#191](https://github.com/Leaflet/Leaflet/issues/191)
|
||||
* Fixed a bug where resizing the map would sometimes make it blurry on WebKit (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#453](https://github.com/Leaflet/Leaflet/pull/453)
|
||||
* Fixed a bug that raised error in IE6-8 when clicking on popup close button. [#235](https://github.com/Leaflet/Leaflet/issues/235)
|
||||
* Fixed a bug with Safari not redrawing UI immediately after closing a popup. [#296](https://github.com/Leaflet/Leaflet/issues/296)
|
||||
* Fixed a bug that caused performance drop and high CPU usage when calling `setView` or `panTo` to the current center. [#231](https://github.com/Leaflet/Leaflet/issues/231)
|
||||
* Fixed a bug that caused map overlays to appear blurry in some cases under WebKit browsers.
|
||||
* Fixed a bug that was causing errors in some Webkit/Linux builds (requestAnimationFrame-related), thanks to Chris Martens.
|
||||
|
||||
#### Mobile browser bugfixes
|
||||
|
||||
* Fixed a bug that caused an error when clicking vector layers under iOS. [#204](https://github.com/CloudMade/Leaflet/issues/204)
|
||||
* Fixed crash on Android 3+ when panning or zooming (by [@florian](https://github.com/florianf)). [#137](https://github.com/CloudMade/Leaflet/issues/137)
|
||||
* Fixed a bug on Android 2/3 that sometimes caused the map to disappear after zooming. [#69](https://github.com/CloudMade/Leaflet/issues/69)
|
||||
* Fixed a bug that caused an error when clicking vector layers under iOS. [#204](https://github.com/Leaflet/Leaflet/issues/204)
|
||||
* Fixed crash on Android 3+ when panning or zooming (by [@florian](https://github.com/florianf)). [#137](https://github.com/Leaflet/Leaflet/issues/137)
|
||||
* Fixed a bug on Android 2/3 that sometimes caused the map to disappear after zooming. [#69](https://github.com/Leaflet/Leaflet/issues/69)
|
||||
* Fixed a bug on Android 3 that caused tiles to shift position on a big map.
|
||||
* Fixed a bug that caused the map to pan when touch-panning inside a popup. [#452](https://github.com/CloudMade/Leaflet/issues/452)
|
||||
* Fixed a bug that caused the map to pan when touch-panning inside a popup. [#452](https://github.com/Leaflet/Leaflet/issues/452)
|
||||
* Fixed a bug that caused click delays on zoom control.
|
||||
|
||||
|
||||
@ -324,14 +460,14 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
* Improved panning performance in Chrome and FF considerably with the help of `requestAnimationFrame`. [#130](https://github.com/CloudMade/Leaflet/issues/130)
|
||||
* Improved click responsiveness in mobile WebKit (now it happens without delay). [#26](https://github.com/CloudMade/Leaflet/issues/26)
|
||||
* Improved panning performance in Chrome and FF considerably with the help of `requestAnimationFrame`. [#130](https://github.com/Leaflet/Leaflet/issues/130)
|
||||
* Improved click responsiveness in mobile WebKit (now it happens without delay). [#26](https://github.com/Leaflet/Leaflet/issues/26)
|
||||
* Added tap tolerance (so click happens even if you moved your finger slighly when tapping).
|
||||
* Improved geolocation error handling: better error messages, explicit timeout, set world view on locateAndSetView failure. [#61](https://github.com/CloudMade/Leaflet/issues/61)
|
||||
* Improved geolocation error handling: better error messages, explicit timeout, set world view on locateAndSetView failure. [#61](https://github.com/Leaflet/Leaflet/issues/61)
|
||||
|
||||
#### API improvements
|
||||
|
||||
* Added **MultiPolyline** and **MultiPolygon** layers. [#77](https://github.com/CloudMade/Leaflet/issues/77)
|
||||
* Added **MultiPolyline** and **MultiPolygon** layers. [#77](https://github.com/Leaflet/Leaflet/issues/77)
|
||||
* Added **LayerGroup** and **FeatureGroup** layers for grouping other layers.
|
||||
* Added **TileLayer.Canvas** for easy creation of canvas-based tile layers.
|
||||
* Changed `Circle` to be zoom-dependent (with radius in meters); circle of a permanent size is now called `CircleMarker`.
|
||||
@ -353,40 +489,40 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
|
||||
* Added `Makefile` for building `leaflet.js` on non-Windows machines (by [@tmcw](https://github.com/tmcw)).
|
||||
* Improved `debug/leaflet-include.js` script to allow using it outside of `debug` folder (by [@antonj](https://github.com/antonj)).
|
||||
* Improved `L` definition to be compatible with CommonJS. [#122](https://github.com/CloudMade/Leaflet/issues/122)
|
||||
* Improved `L` definition to be compatible with CommonJS. [#122](https://github.com/Leaflet/Leaflet/issues/122)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed a bug where zooming is broken if the map contains a polygon and you zoom to an area where it's not visible. [#47](https://github.com/CloudMade/Leaflet/issues/47)
|
||||
* Fixed a bug where zooming is broken if the map contains a polygon and you zoom to an area where it's not visible. [#47](https://github.com/Leaflet/Leaflet/issues/47)
|
||||
* Fixed a bug where closed polylines would not appear on the map.
|
||||
* Fixed a bug where marker that was added, removed and then added again would not appear on the map. [#66](https://github.com/CloudMade/Leaflet/issues/66)
|
||||
* Fixed a bug where marker that was added, removed and then added again would not appear on the map. [#66](https://github.com/Leaflet/Leaflet/issues/66)
|
||||
* Fixed a bug where tile layer that was added, removed and then added again would not appear on the map.
|
||||
* Fixed a bug where some tiles would not load when panning across the date line. [#97](https://github.com/CloudMade/Leaflet/issues/97)
|
||||
* Fixed a bug where map div with `position: absolute` is reset to `relative`. [#100](https://github.com/CloudMade/Leaflet/issues/100)
|
||||
* Fixed a bug where some tiles would not load when panning across the date line. [#97](https://github.com/Leaflet/Leaflet/issues/97)
|
||||
* Fixed a bug where map div with `position: absolute` is reset to `relative`. [#100](https://github.com/Leaflet/Leaflet/issues/100)
|
||||
* Fixed a bug that caused an error when trying to add a marker without shadow in its icon.
|
||||
* Fixed a bug where popup content would not update on `setContent` call. [#94](https://github.com/CloudMade/Leaflet/issues/94)
|
||||
* Fixed a bug where popup content would not update on `setContent` call. [#94](https://github.com/Leaflet/Leaflet/issues/94)
|
||||
* Fixed a bug where double click zoom wouldn't work if popup is opened on map click
|
||||
* Fixed a bug with click propagation on popup close button. [#99](https://github.com/CloudMade/Leaflet/issues/99)
|
||||
* Fixed a bug with click propagation on popup close button. [#99](https://github.com/Leaflet/Leaflet/issues/99)
|
||||
* Fixed inability to remove ImageOverlay layer.
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug where paths would not appear in IE8.
|
||||
* Fixed a bug where there were occasional slowdowns before zoom animation in WebKit. [#123](https://github.com/CloudMade/Leaflet/issues/123)
|
||||
* Fixed a bug where there were occasional slowdowns before zoom animation in WebKit. [#123](https://github.com/Leaflet/Leaflet/issues/123)
|
||||
* Fixed incorrect zoom animation & popup styling in Opera 11.11.
|
||||
* Fixed popup fade animation in Firefox and Opera.
|
||||
* Fixed a bug where map isn't displayed in Firefox when there's an `img { max-width: 100% }` rule.
|
||||
|
||||
#### Mobile browsers bugfixes
|
||||
|
||||
* Fixed a bug that prevented panning on some Android 2.1 (and possibly older) devices. [#84](https://github.com/CloudMade/Leaflet/issues/84)
|
||||
* Disabled zoom animation on Android by default because it's buggy on some devices (will be enabled back when it's stable enough). [#32](https://github.com/CloudMade/Leaflet/issues/32)
|
||||
* Fixed a bug where map would occasionally break while multi-touch-zooming on iOS. [#32](https://github.com/CloudMade/Leaflet/issues/32)
|
||||
* Fixed a bug that prevented panning/clicking on Android 3 tablets. [#121](https://github.com/CloudMade/Leaflet/issues/121)
|
||||
* Fixed a bug that prevented panning/clicking on Opera Mobile. [#138](https://github.com/CloudMade/Leaflet/issues/138)
|
||||
* Fixed potentional memory leak on WebKit when removing tiles, thanks to [@Scalar4eg](https://github.com/Scalar4eg). [#107](https://github.com/CloudMade/Leaflet/issues/107)
|
||||
* Fixed a bug that prevented panning on some Android 2.1 (and possibly older) devices. [#84](https://github.com/Leaflet/Leaflet/issues/84)
|
||||
* Disabled zoom animation on Android by default because it's buggy on some devices (will be enabled back when it's stable enough). [#32](https://github.com/Leaflet/Leaflet/issues/32)
|
||||
* Fixed a bug where map would occasionally break while multi-touch-zooming on iOS. [#32](https://github.com/Leaflet/Leaflet/issues/32)
|
||||
* Fixed a bug that prevented panning/clicking on Android 3 tablets. [#121](https://github.com/Leaflet/Leaflet/issues/121)
|
||||
* Fixed a bug that prevented panning/clicking on Opera Mobile. [#138](https://github.com/Leaflet/Leaflet/issues/138)
|
||||
* Fixed potentional memory leak on WebKit when removing tiles, thanks to [@Scalar4eg](https://github.com/Scalar4eg). [#107](https://github.com/Leaflet/Leaflet/issues/107)
|
||||
|
||||
## 0.1 (2011-05-13)
|
||||
|
||||
|
124
CONTRIBUTING.md
Normal file
@ -0,0 +1,124 @@
|
||||
Contributing to Leaflet
|
||||
=======================
|
||||
|
||||
1. [Getting Involved](#getting-involved)
|
||||
2. [Reporting Bugs](#reporting-bugs)
|
||||
3. [Contributing Code](#contributing-code)
|
||||
4. [Improving Documentation](#improving-documentation)
|
||||
|
||||
## Getting Involved
|
||||
|
||||
Third-party patches are absolutely essential on our quest to create the best mapping library that will ever exist.
|
||||
However, they're not the only way to get involved with the development of Leaflet.
|
||||
You can help the project tremendously by discovering and [reporting bugs](#reporting-bugs),
|
||||
[improving documentation](#improving-documentation),
|
||||
helping others on the [Leaflet forum](https://groups.google.com/forum/#!forum/leaflet-js)
|
||||
and [GitHub issues](https://github.com/Leaflet/Leaflet/issues),
|
||||
showing your support for your favorite feature suggestions on [Leaflet UserVoice page](http://leaflet.uservoice.com),
|
||||
tweeting to [@LeafletJS](http://twitter.com/LeafletJS)
|
||||
and spreading the word about Leaflet among your colleagues and friends.
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
Before reporting a bug on the project's [issues page](https://github.com/Leaflet/Leaflet/issues),
|
||||
first make sure that your issue is caused by Leaflet, not your application code
|
||||
(e.g. passing incorrect arguments to methods, etc.).
|
||||
Second, search the already reported issues for similar cases,
|
||||
and if it's already reported, just add any additional details in the comments.
|
||||
|
||||
After you made sure that you've found a new Leaflet bug,
|
||||
here are some tips for creating a helpful report that will make fixing it much easier and quicker:
|
||||
|
||||
* Write a **descriptive, specific title**. Bad: *Problem with polylines*. Good: *Doing X in IE9 causes Z*.
|
||||
* Include **browser, OS and Leaflet version** info in the description.
|
||||
* Create a **simple test case** that demonstrates the bug (e.g. using [JSFiddle](http://jsfiddle.net/)).
|
||||
* Check whether the bug can be reproduced in **other browsers**.
|
||||
* Check if the bug occurs in the stable version, master, or both.
|
||||
* *Bonus tip:* if the bug only appears in the master version but the stable version is fine,
|
||||
use `git bisect` to find the exact commit that introduced the bug.
|
||||
|
||||
## Contributing Code
|
||||
|
||||
### Considerations for Accepting Patches
|
||||
|
||||
While we happily accept patches, we're also commited to keeping Leaflet simple, lightweight and blazingly fast.
|
||||
So bugfixes, performance optimizations and small improvements that don't add a lot of code
|
||||
are much more likely to get accepted quickly.
|
||||
|
||||
Before sending a pull request with a new feature, first check if it's been discussed before already
|
||||
(either on [GitHub issues](https://github.com/Leaflet/Leaflet/issues)
|
||||
or [Leaflet UserVoice](http://leaflet.uservoice.com/)),
|
||||
and then ask yourself two questions:
|
||||
|
||||
1. Are you sure that this new feature is important enough to justify its presense in the Leaflet core?
|
||||
Or will it look better as a plugin in a separate repository?
|
||||
2. Is it written in a simple, concise way that doesn't add bulk to the codebase?
|
||||
|
||||
If your feature or API improvement did get merged into master,
|
||||
please consider submitting another pull request with the corresponding [documentation update](#improving-documentation).
|
||||
|
||||
### Setting up the Build System
|
||||
|
||||
To set up the Leaflet build system, install [Node](http://nodejs.org/),
|
||||
then run the following commands in the project root (with superuser permissions):
|
||||
|
||||
```
|
||||
npm install -g jake
|
||||
npm install jshint
|
||||
npm install uglify-js
|
||||
```
|
||||
|
||||
You can build minified Leaflet by running `jake` (it will be built from source in the `dist` folder).
|
||||
|
||||
### Making Changes to Leaflet Source
|
||||
|
||||
If you're not yet familiar with the way GitHub works (forking, pull requests, etc.),
|
||||
be sure to check out the awesome [article about forking](https://help.github.com/articles/fork-a-repo)
|
||||
on the GitHub Help website — it will get you started quickly.
|
||||
|
||||
You should always write each batch of changes (feature, bugfix, etc.) in **its own topic branch**.
|
||||
Please do not commit to the `master` branch, or your unrelated changes will go into the same pull request.
|
||||
|
||||
You should also follow the code style and whitespace conventions of the original codebase.
|
||||
|
||||
Before commiting your changes, run `jake lint` to catch any JS errors in the code and fix them.
|
||||
If you add any new files to the Leaflet source, make sure to also add them to `build/deps.js`
|
||||
so that the build system knows about them.
|
||||
|
||||
But please **do not commit the built files** (`leaflet.js` and `leaflet-src.js`) along with your changes,
|
||||
otherwise there may be problems merging the pull request.
|
||||
These files are only commited in the `master` branch of the main Leaflet repository.
|
||||
|
||||
Happy coding!
|
||||
|
||||
## Improving Documentation
|
||||
|
||||
The code of the live Leaflet website that contains all documentation and examples is located in the `gh-pages` branch
|
||||
and is automatically generated from a set of HTML and Markdown files by [Jekyll](https://github.com/mojombo/jekyll).
|
||||
|
||||
The easiest way to make little improvements such as fixing typos without even leaving the browser
|
||||
is by editing one of the files with the online GitHub editor:
|
||||
browse the [gh-pages branch](https://github.com/Leaflet/Leaflet/tree/gh-pages),
|
||||
choose a certain file for editing (e.g. `reference.html` for API reference),
|
||||
click the Edit button, make changes and follow instructions from there.
|
||||
Once it gets merged, the changes will immediately appear on the website.
|
||||
|
||||
If you need to make edits in a local repository to see how it looks in the process, do the following:
|
||||
|
||||
1. [Install Ruby](http://www.ruby-lang.org/en/) if don't have it yet.
|
||||
2. Run `gem install jekyll`.
|
||||
3. Run `jekyll --auto` inside the `Leaflet` folder.
|
||||
4. Open the website from the `_site` folder.
|
||||
|
||||
Now any file changes will be reflected on the generated pages automatically.
|
||||
After commiting the changes, just send a pull request.
|
||||
|
||||
If you need to update documentation according to a new feature that only appeared in the master version (not stable one),
|
||||
you need to make changes to `gh-pages-master` branch instead of `gh-pages`.
|
||||
It will get merged into the latter when released as stable.
|
||||
|
||||
## Thank You
|
||||
|
||||
Not only are we grateful for any contributions, — helping Leaflet and its community actually makes you AWESOME.
|
||||
Join [this approved list of awesome people](https://github.com/Leaflet/Leaflet/graphs/contributors)
|
||||
and help us push the limits of what's possible with online maps!
|
76
Jakefile.js
@ -1,67 +1,23 @@
|
||||
var build = require('./build/build.js'),
|
||||
lint = require('./build/hint.js');
|
||||
/*
|
||||
Leaflet building and linting scripts.
|
||||
|
||||
var COPYRIGHT = '/*\n Copyright (c) 2010-2012, CloudMade, Vladimir Agafonkin\n' +
|
||||
' Leaflet is an open-source JavaScript library for mobile-friendly interactive maps.\n' +
|
||||
' http://leaflet.cloudmade.com\n*/\n';
|
||||
To use, install Node, then run the following commands in the project root:
|
||||
|
||||
npm install -g jake
|
||||
npm install uglify-js
|
||||
npm install jshint
|
||||
|
||||
To check the code and build Leaflet from source, run "jake"
|
||||
|
||||
For a custom build, open build/build.html in the browser and follow the instructions.
|
||||
*/
|
||||
|
||||
var build = require('./build/build.js');
|
||||
|
||||
desc('Check Leaflet source for errors with JSHint');
|
||||
task('lint', function () {
|
||||
|
||||
var files = build.getFiles();
|
||||
|
||||
console.log('Checking for JS errors...');
|
||||
|
||||
var errorsFound = lint.jshint(files);
|
||||
|
||||
if (errorsFound > 0) {
|
||||
console.log(errorsFound + ' error(s) found.\n');
|
||||
fail();
|
||||
} else {
|
||||
console.log('\tCheck passed');
|
||||
}
|
||||
});
|
||||
task('lint', build.lint);
|
||||
|
||||
desc('Combine and compress Leaflet source files');
|
||||
task('build', ['lint'], function (compsBase32, buildName) {
|
||||
|
||||
var files = build.getFiles(compsBase32);
|
||||
|
||||
console.log('Concatenating ' + files.length + ' files...');
|
||||
|
||||
var content = build.combineFiles(files),
|
||||
newSrc = COPYRIGHT + content,
|
||||
|
||||
pathPart = 'dist/leaflet' + (buildName ? '-' + buildName : ''),
|
||||
srcPath = pathPart + '-src.js',
|
||||
|
||||
oldSrc = build.load(srcPath),
|
||||
srcDelta = build.getSizeDelta(newSrc, oldSrc);
|
||||
|
||||
console.log('\tUncompressed size: ' + newSrc.length + ' bytes (' + srcDelta + ')');
|
||||
|
||||
if (newSrc === oldSrc) {
|
||||
console.log('\tNo changes');
|
||||
} else {
|
||||
build.save(srcPath, newSrc);
|
||||
console.log('\tSaved to ' + srcPath);
|
||||
}
|
||||
|
||||
console.log('Compressing...');
|
||||
|
||||
var path = pathPart + '.js',
|
||||
oldCompressed = build.load(path),
|
||||
newCompressed = COPYRIGHT + build.uglify(content),
|
||||
delta = build.getSizeDelta(newCompressed, oldCompressed);
|
||||
|
||||
console.log('\tCompressed size: ' + newCompressed.length + ' bytes (' + delta + ')');
|
||||
|
||||
if (newCompressed === oldCompressed) {
|
||||
console.log('\tNo changes');
|
||||
} else {
|
||||
build.save(path, newCompressed);
|
||||
console.log('\tSaved to ' + path);
|
||||
}
|
||||
});
|
||||
task('build', ['lint'], build.build);
|
||||
|
||||
task('default', ['build']);
|
||||
|
37
LICENSE
@ -1,22 +1,23 @@
|
||||
Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin
|
||||
All rights reserved.
|
||||
Copyright (c) 2010-2013, Vladimir Agafonkin
|
||||
Copyright (c) 2010-2011, CloudMade
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
50
README.md
@ -1,34 +1,28 @@
|
||||
<img src="http://leaflet.cloudmade.com/docs/images/logo.png" alt="Leaflet" />
|
||||
<img src="http://leafletjs.com/docs/images/logo.png" alt="Leaflet" />
|
||||
|
||||
Leaflet is a modern, lightweight open-source JavaScript library for mobile-friendly interactive maps, developed by [Vladimir Agafonkin](http://agafonkin.com/en) of [CloudMade](http://cloudmade.com) with a team of dedicated [contributors](https://github.com/CloudMade/Leaflet/graphs/contributors). Weighting just about 25kb of gzipped JS code, it still has all the [features](http://leaflet.cloudmade.com/features.html) most developers ever need for online maps, while providing a fast, pleasant user experience.
|
||||
Leaflet is a modern open-source JavaScript library for **mobile-friendly interactive maps**.
|
||||
It is developed by [Vladimir Agafonkin][] with a team of dedicated [contributors][].
|
||||
Weighing just about 27 KB of gzipped JS code, it has all the [features][] most developers ever need for online maps.
|
||||
|
||||
It is built from the ground up to work efficiently and smoothly on both desktop and mobile platforms like iOS and Android, taking advantage of HTML5 and CSS3 on modern browsers. The focus is on usability, performance, small size, [A-grade](http://developer.yahoo.com/yui/articles/gbs/) browser support, flexibility and [easy to use API](http://leaflet.cloudmade.com/reference.html) with convention over configuration. The OOP-based code of the library is designed to be modular, extensible and very easy to understand.
|
||||
Leaflet is designed with *simplicity*, *performance* and *usability* in mind.
|
||||
It works efficiently across all major desktop and mobile platforms out of the box,
|
||||
taking advantage of HTML5 and CSS3 on modern browsers while being accessible on older ones too.
|
||||
It can also be extended with many [plugins][],
|
||||
has a beautiful, easy to use and [well-documented][] API
|
||||
and a simple, readable [source code][] that is a joy to [contribute][] to.
|
||||
|
||||
Check out the website for more information: [leaflet.cloudmade.com](http://leaflet.cloudmade.com)
|
||||
For more information, check out the [official website][].
|
||||
|
||||
## Contributing to Leaflet
|
||||
We're happy to meet new contributors.
|
||||
If you want to **get involved** with Leaflet development, check out the [contribution guide][contribute].
|
||||
Let's make the best open-source library for maps that can possibly exist!
|
||||
|
||||
Contributing is simple: make the changes in your fork (preferably in a separate branch), make sure that Leaflet builds successfully (see below) and then create a pull request (without the built files, just the source changes) to [Vladimir Agafonkin](http://github.com/mourner) (Leaflet maintainer). Updates to Leaflet [documentation](http://leaflet.cloudmade.com/reference.html) and [examples](http://leaflet.cloudmade.com/examples.html) (located in the `gh-pages` branch for current stable release and `gh-pages-master` for the in-progress version) are really appreciated too.
|
||||
|
||||
Note that bugfixes and small improvements are higher priority than new features or substantial API changes, and will be reviewed and merged much faster than pulls with lots of new code. If your new feature is not expected to be widely used, consider making a plugin instead. Lets keep Leaflet slim, fast and simple!
|
||||
|
||||
Here's [a list of the awesome people](http://github.com/CloudMade/Leaflet/contributors) that joined us already. Looking forward to _your_ contributions!
|
||||
|
||||
## Building Leaflet
|
||||
Leaflet build system is powered by the Node.js platform and Jake, JSHint and UglifyJS libraries, which install easily and work well across all major platforms. Here are the steps to install it:
|
||||
|
||||
1. [Download and install Node](http://nodejs.org)
|
||||
2. Run the following commands in the command line:
|
||||
|
||||
```
|
||||
npm install -g jake
|
||||
npm install jshint
|
||||
npm install uglify-js
|
||||
```
|
||||
|
||||
Now that you have everything installed, run `jake` inside the Leaflet directory. This will check Leaflet source files for JavaScript errors and inconsistencies, and then combine and compress it to the `dist` folder.
|
||||
|
||||
To make a custom build of the library with only the things you need, use the build helper (`build/build.html`) to choose the components (it figures out dependencies for you) and then run the command generated with it.
|
||||
|
||||
If you add any new files to the Leaflet source, make sure to also add them to `build/deps.js` so that the build system knows about them. Happy coding!
|
||||
[Vladimir Agafonkin]: http://agafonkin.com/en
|
||||
[contributors]: https://github.com/Leaflet/Leaflet/graphs/contributors
|
||||
[features]: http://leafletjs.com/features.html
|
||||
[plugins]: http://leafletjs.com/plugins.html
|
||||
[well-documented]: http://leafletjs.com/reference.html "Leaflet API reference"
|
||||
[source code]: https://github.com/Leaflet/Leaflet "Leaflet GitHub repository"
|
||||
[hosted on GitHub]: http://github.com/Leaflet/Leaflet
|
||||
[contribute]: https://github.com/Leaflet/Leaflet/blob/master/CONTRIBUTING.md "A guide to contributing to Leaflet"
|
||||
[official website]: http://leafletjs.com
|
||||
|
140
build/build.js
@ -1,10 +1,35 @@
|
||||
var fs = require('fs'),
|
||||
uglifyjs = require('uglify-js'),
|
||||
deps = require('./deps.js').deps;
|
||||
jshint = require('jshint'),
|
||||
UglifyJS = require('uglify-js'),
|
||||
|
||||
exports.getFiles = function (compsBase32) {
|
||||
deps = require('./deps.js').deps,
|
||||
hintrc = require('./hintrc.js').config;
|
||||
|
||||
|
||||
function lintFiles(files) {
|
||||
|
||||
var errorsFound = 0,
|
||||
i, j, len, len2, src, errors, e;
|
||||
|
||||
for (i = 0, len = files.length; i < len; i++) {
|
||||
|
||||
jshint.JSHINT(fs.readFileSync(files[i], 'utf8'), hintrc);
|
||||
errors = jshint.JSHINT.errors;
|
||||
|
||||
for (j = 0, len2 = errors.length; j < len2; j++) {
|
||||
e = errors[j];
|
||||
console.log(files[i] + '\tline ' + e.line + '\tcol ' + e.character + '\t ' + e.reason);
|
||||
}
|
||||
|
||||
errorsFound += len2;
|
||||
}
|
||||
|
||||
return errorsFound;
|
||||
}
|
||||
|
||||
function getFiles(compsBase32) {
|
||||
var memo = {},
|
||||
comps;
|
||||
comps;
|
||||
|
||||
if (compsBase32) {
|
||||
comps = parseInt(compsBase32, 32).toString(2).split('');
|
||||
@ -37,43 +62,94 @@ exports.getFiles = function (compsBase32) {
|
||||
}
|
||||
|
||||
return files;
|
||||
};
|
||||
}
|
||||
|
||||
exports.uglify = function (code) {
|
||||
var pro = uglifyjs.uglify;
|
||||
exports.lint = function () {
|
||||
|
||||
var ast = uglifyjs.parser.parse(code);
|
||||
ast = pro.ast_mangle(ast, {mangle: true});
|
||||
ast = pro.ast_squeeze(ast);
|
||||
ast = pro.ast_squeeze_more(ast);
|
||||
var files = getFiles();
|
||||
|
||||
return pro.gen_code(ast) + ';';
|
||||
};
|
||||
console.log('Checking for JS errors...');
|
||||
|
||||
exports.combineFiles = function (files) {
|
||||
var content = '(function (window, undefined) {\n\n';
|
||||
for (var i = 0, len = files.length; i < len; i++) {
|
||||
content += fs.readFileSync(files[i], 'utf8') + '\n\n';
|
||||
}
|
||||
return content + '\n\n}(this));';
|
||||
};
|
||||
var errorsFound = lintFiles(files);
|
||||
|
||||
exports.save = function (savePath, compressed) {
|
||||
return fs.writeFileSync(savePath, compressed, 'utf8');
|
||||
};
|
||||
|
||||
exports.load = function (loadPath) {
|
||||
try {
|
||||
return fs.readFileSync(loadPath, 'utf8');
|
||||
} catch (e) {
|
||||
return null;
|
||||
if (errorsFound > 0) {
|
||||
console.log(errorsFound + ' error(s) found.\n');
|
||||
fail();
|
||||
} else {
|
||||
console.log('\tCheck passed');
|
||||
}
|
||||
};
|
||||
|
||||
exports.getSizeDelta = function (newContent, oldContent) {
|
||||
|
||||
function getSizeDelta(newContent, oldContent) {
|
||||
if (!oldContent) {
|
||||
return 'new';
|
||||
}
|
||||
var delta = newContent.length - oldContent.length;
|
||||
var newLen = newContent.replace(/\r\n?/g, '\n').length,
|
||||
oldLen = oldContent.replace(/\r\n?/g, '\n').length,
|
||||
delta = newLen - oldLen;
|
||||
|
||||
return (delta >= 0 ? '+' : '') + delta;
|
||||
};
|
||||
}
|
||||
|
||||
function loadSilently(path) {
|
||||
try {
|
||||
return fs.readFileSync(path, 'utf8');
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function combineFiles(files) {
|
||||
var content = '';
|
||||
for (var i = 0, len = files.length; i < len; i++) {
|
||||
content += fs.readFileSync(files[i], 'utf8') + '\n\n';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
exports.build = function (compsBase32, buildName) {
|
||||
|
||||
var files = getFiles(compsBase32);
|
||||
|
||||
console.log('Concatenating ' + files.length + ' files...');
|
||||
|
||||
var copy = fs.readFileSync('src/copyright.js', 'utf8'),
|
||||
intro = '(function (window, document, undefined) {',
|
||||
outro = '}(this, document));',
|
||||
newSrc = copy + intro + combineFiles(files) + outro,
|
||||
|
||||
pathPart = 'dist/leaflet' + (buildName ? '-' + buildName : ''),
|
||||
srcPath = pathPart + '-src.js',
|
||||
|
||||
oldSrc = loadSilently(srcPath),
|
||||
srcDelta = getSizeDelta(newSrc, oldSrc);
|
||||
|
||||
console.log('\tUncompressed size: ' + newSrc.length + ' bytes (' + srcDelta + ')');
|
||||
|
||||
if (newSrc === oldSrc) {
|
||||
console.log('\tNo changes');
|
||||
} else {
|
||||
fs.writeFileSync(srcPath, newSrc);
|
||||
console.log('\tSaved to ' + srcPath);
|
||||
}
|
||||
|
||||
console.log('Compressing...');
|
||||
|
||||
var path = pathPart + '.js',
|
||||
oldCompressed = loadSilently(path),
|
||||
newCompressed = copy + UglifyJS.minify(newSrc, {
|
||||
warnings: true,
|
||||
fromString: true
|
||||
}).code,
|
||||
delta = getSizeDelta(newCompressed, oldCompressed);
|
||||
|
||||
console.log('\tCompressed size: ' + newCompressed.length + ' bytes (' + delta + ')');
|
||||
|
||||
if (newCompressed === oldCompressed) {
|
||||
console.log('\tNo changes');
|
||||
} else {
|
||||
fs.writeFileSync(path, newCompressed);
|
||||
console.log('\tSaved to ' + path);
|
||||
}
|
||||
};
|
||||
|
@ -15,6 +15,7 @@ var deps = {
|
||||
'geo/projection/Projection.SphericalMercator.js',
|
||||
'geo/projection/Projection.LonLat.js',
|
||||
'geo/crs/CRS.js',
|
||||
'geo/crs/CRS.Simple.js',
|
||||
'geo/crs/CRS.EPSG3857.js',
|
||||
'geo/crs/CRS.EPSG4326.js',
|
||||
'map/Map.js'],
|
||||
@ -53,7 +54,9 @@ var deps = {
|
||||
},
|
||||
|
||||
Marker: {
|
||||
src: ['layer/marker/Icon.js', 'layer/marker/Icon.Default.js', 'layer/marker/Marker.js'],
|
||||
src: ['layer/marker/Icon.js',
|
||||
'layer/marker/Icon.Default.js',
|
||||
'layer/marker/Marker.js'],
|
||||
desc: 'Markers to put on the map.'
|
||||
},
|
||||
|
||||
@ -64,7 +67,9 @@ var deps = {
|
||||
},
|
||||
|
||||
Popup: {
|
||||
src: ['layer/Popup.js', 'layer/marker/Marker.Popup.js', 'map/ext/Map.Popup.js'],
|
||||
src: ['layer/Popup.js',
|
||||
'layer/marker/Marker.Popup.js',
|
||||
'map/ext/Map.Popup.js'],
|
||||
deps: ['Marker'],
|
||||
desc: 'Used to display the map popup (used mostly for binding HTML data to markers and paths on click).'
|
||||
},
|
||||
@ -82,7 +87,9 @@ var deps = {
|
||||
|
||||
|
||||
Path: {
|
||||
src: ['layer/vector/Path.js', 'layer/vector/Path.SVG.js', 'layer/vector/Path.Popup.js'],
|
||||
src: ['layer/vector/Path.js',
|
||||
'layer/vector/Path.SVG.js',
|
||||
'layer/vector/Path.Popup.js'],
|
||||
desc: 'Vector rendering core (SVG-powered), enables overlaying the map with SVG paths.',
|
||||
heading: 'Vector layers'
|
||||
},
|
||||
@ -99,13 +106,15 @@ var deps = {
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
src: ['geometry/LineUtil.js', 'layer/vector/Polyline.js'],
|
||||
src: ['geometry/LineUtil.js',
|
||||
'layer/vector/Polyline.js'],
|
||||
deps: ['Path'],
|
||||
desc: 'Polyline overlays.'
|
||||
},
|
||||
|
||||
Polygon: {
|
||||
src: ['geometry/PolyUtil.js', 'layer/vector/Polygon.js'],
|
||||
src: ['geometry/PolyUtil.js',
|
||||
'layer/vector/Polygon.js'],
|
||||
deps: ['Polyline'],
|
||||
desc: 'Polygon overlays.'
|
||||
},
|
||||
@ -169,10 +178,11 @@ var deps = {
|
||||
TouchZoom: {
|
||||
src: ['dom/DomEvent.js',
|
||||
'dom/DomEvent.DoubleTap.js',
|
||||
'dom/DomEvent.MsTouch.js',
|
||||
'core/Handler.js',
|
||||
'map/handler/Map.TouchZoom.js'],
|
||||
deps: ['MapAnimationZoom'],
|
||||
desc: 'Enables smooth touch zooming on iOS and double tap on iOS/Android.'
|
||||
desc: 'Enables smooth touch zooming on iOS and IE10 and double tap on iOS/IE10/Android.'
|
||||
},
|
||||
|
||||
BoxZoom: {
|
||||
@ -228,33 +238,28 @@ var deps = {
|
||||
},
|
||||
|
||||
|
||||
AnimationNative: {
|
||||
src: ['dom/DomEvent.js',
|
||||
'dom/transition/Transition.js',
|
||||
'dom/transition/Transition.Native.js'],
|
||||
desc: 'Animation core that uses CSS3 Transitions (for powering pan & zoom animations). Works on mobile webkit-powered browsers and some modern desktop browsers.',
|
||||
heading: 'Visual effects'
|
||||
AnimationPan: {
|
||||
src: [
|
||||
'dom/DomEvent.js',
|
||||
'dom/PosAnimation.js',
|
||||
'map/anim/Map.PanAnimation.js'
|
||||
],
|
||||
deps: ['AnimationPan'],
|
||||
desc: 'Core panning animation support.'
|
||||
},
|
||||
|
||||
AnimationTimer: {
|
||||
src: ['dom/transition/Transition.Timer.js'],
|
||||
deps: ['AnimationNative'],
|
||||
desc: 'Timer-based animation fallback for browsers that don\'t support CSS3 transitions.'
|
||||
},
|
||||
|
||||
AnimationPan: {
|
||||
src: ['map/anim/Map.PanAnimation.js'],
|
||||
src: ['dom/PosAnimation.Timer.js'],
|
||||
deps: ['AnimationPan'],
|
||||
desc: 'Panning animation. Can use both native and timer-based animation.'
|
||||
desc: 'Timer-based pan animation fallback for browsers that don\'t support CSS3 transitions.'
|
||||
},
|
||||
|
||||
AnimationZoom: {
|
||||
src: ['map/anim/Map.ZoomAnimation.js'],
|
||||
deps: ['AnimationPan', 'AnimationNative'],
|
||||
desc: 'Smooth zooming animation. So far it works only on browsers that support CSS3 Transitions.'
|
||||
deps: ['AnimationPan'],
|
||||
desc: 'Smooth zooming animation. Works only on browsers that support CSS3 Transitions.'
|
||||
},
|
||||
|
||||
|
||||
Geolocation: {
|
||||
src: ['map/ext/Map.Geolocation.js'],
|
||||
desc: 'Adds Map#locate method and related events to make geolocation easier.',
|
||||
|
@ -1,30 +0,0 @@
|
||||
var jshint = require('jshint').JSHINT,
|
||||
fs = require('fs'),
|
||||
config = require('./hintrc.js').config;
|
||||
|
||||
function jshintSrc(path, src) {
|
||||
jshint(src, config);
|
||||
|
||||
var errors = jshint.errors,
|
||||
i, len, e, line;
|
||||
|
||||
for (i = 0, len = errors.length; i < len; i++) {
|
||||
e = errors[i];
|
||||
//console.log(e.evidence);
|
||||
console.log(path + '\tline ' + e.line + '\tcol ' + e.character + '\t ' + e.reason);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
exports.jshint = function (files) {
|
||||
var errorsFound = 0;
|
||||
|
||||
for (var i = 0, len = files.length; i < len; i++) {
|
||||
var src = fs.readFileSync(files[i], 'utf8');
|
||||
|
||||
errorsFound += jshintSrc(files[i], src);
|
||||
}
|
||||
|
||||
return errorsFound;
|
||||
};
|
@ -16,12 +16,15 @@
|
||||
|
||||
'dom/DomEvent.js',
|
||||
'dom/DomEvent.DoubleTap.js',
|
||||
'dom/DomEvent.MsTouch.js',
|
||||
'dom/DomUtil.js',
|
||||
'dom/Draggable.js',
|
||||
|
||||
'dom/transition/Transition.js',
|
||||
'dom/transition/Transition.Native.js',
|
||||
'dom/transition/Transition.Timer.js',
|
||||
'dom/PosAnimation.js',
|
||||
'dom/PosAnimation.Timer.js',
|
||||
// 'dom/transition/Transition.js',
|
||||
// 'dom/transition/Transition.Native.js',
|
||||
// 'dom/transition/Transition.Timer.js',
|
||||
|
||||
'geo/LatLng.js',
|
||||
'geo/LatLngBounds.js',
|
||||
@ -35,6 +38,7 @@
|
||||
'geo/crs/CRS.EPSG3857.js',
|
||||
'geo/crs/CRS.EPSG4326.js',
|
||||
'geo/crs/CRS.EPSG3395.js',
|
||||
'geo/crs/CRS.Simple.js',
|
||||
|
||||
'map/Map.js',
|
||||
|
||||
@ -111,7 +115,7 @@
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
document.writeln("<script src='" + path + scripts[i] + "'></script>");
|
||||
}
|
||||
document.writeln('<script>L.Icon.Default.imagePath = "' + path + '../dist/images";</script>');
|
||||
document.writeln('<script defer>L.Icon.Default.imagePath = "' + path + '../dist/images";</script>');
|
||||
})();
|
||||
|
||||
function getRandomLatLng(map) {
|
||||
@ -125,3 +129,7 @@ function getRandomLatLng(map) {
|
||||
southWest.lat + latSpan * Math.random(),
|
||||
southWest.lng + lngSpan * Math.random());
|
||||
}
|
||||
|
||||
function logEvent(e) {
|
||||
console.log(e.type);
|
||||
}
|
||||
|
44
debug/map/simple-proj.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!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 src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = L.map('map', {
|
||||
crs: L.CRS.Simple
|
||||
}).setView([0, 0], 0);
|
||||
|
||||
L.polygon([
|
||||
[-200, -50],
|
||||
[-40, 250],
|
||||
[200, 100]
|
||||
]).addTo(map);
|
||||
|
||||
|
||||
L.marker([-200, -200]).addTo(map);
|
||||
L.marker([200, -200]).addTo(map);
|
||||
L.marker([200, 200]).addTo(map);
|
||||
L.marker([-200, 200]).addTo(map);
|
||||
|
||||
L.marker([0, 0]).addTo(map);
|
||||
|
||||
L.imageOverlay('http://leafletjs.com/docs/images/logo.png', [[0, 0], [73, 220]]).addTo(map);
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
45
debug/map/zoomlevels.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!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]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Test that changing between layers with differing zoomlevels also updates
|
||||
// the zoomlevels in the map + also
|
||||
|
||||
function getCloudMadeUrl(styleId) {
|
||||
return 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/' + styleId + '/256/{z}/{x}/{y}.png';
|
||||
}
|
||||
|
||||
var map = L.map('map').setView(L.latLng(50.5, 30.51), 0);
|
||||
|
||||
var cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = L.tileLayer(getCloudMadeUrl(997), {attribution: cloudmadeAttribution, minZoom: 0, maxZoom: 10}).addTo(map),
|
||||
cloudmade2 = L.tileLayer(getCloudMadeUrl(998), {attribution: 'Hello world', minZoom: 5, maxZoom: 18});
|
||||
|
||||
L.control.layers({
|
||||
'CloudMade Pale Dawn (5-18)': cloudmade2,
|
||||
'CloudMade Fresh (0-10)': cloudmade
|
||||
}).addTo(map);
|
||||
|
||||
L.control.scale().addTo(map);
|
||||
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
L.marker(getRandomLatLng(map)).addTo(map);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
88
debug/tests/add_remove_layers.html
Normal file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
|
||||
<script>
|
||||
L_PREFER_CANVAS = true;
|
||||
$(document).ready(function() {
|
||||
var map;
|
||||
var myLayerGroup = new L.LayerGroup();
|
||||
|
||||
initmap();
|
||||
|
||||
|
||||
function initmap() {
|
||||
|
||||
// set up the map
|
||||
map = new L.Map('map');
|
||||
|
||||
// create the tile layer with correct attribution
|
||||
var osmUrl = 'http://a.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
var osmAttrib = 'Map data © OpenStreetMap contributors';
|
||||
var osm = new L.TileLayer(osmUrl, { minZoom: 1, maxZoom: 17, attribution: osmAttrib, detectRetina: true });
|
||||
map.addLayer(osm);
|
||||
map.fitBounds(new L.LatLngBounds([51,7],[51,7]));
|
||||
drawTestLine();
|
||||
|
||||
|
||||
};
|
||||
|
||||
function drawTestLine() {
|
||||
var lat = 51;
|
||||
var long = 7;
|
||||
for (var i = 0; i < 50; i++) {
|
||||
|
||||
var myCircle = new L.Circle(new L.LatLng(lat, long),3);
|
||||
myCircle.on('click',
|
||||
function (e) {
|
||||
popup = new L.Popup();
|
||||
popup.setLatLng(this.getLatLng());
|
||||
|
||||
var popuptxt = "Hello!";
|
||||
alert("I am the click function");
|
||||
popup.setContent(popuptxt);
|
||||
|
||||
map.openPopup(popup);
|
||||
|
||||
|
||||
});
|
||||
myLayerGroup.addLayer(myCircle);
|
||||
lat = lat + 0.0001;
|
||||
long = long + 0.0001;
|
||||
|
||||
}
|
||||
|
||||
map.addLayer(myLayerGroup);
|
||||
|
||||
};
|
||||
|
||||
$("#b1").click(function() {
|
||||
map.addLayer(myLayerGroup);
|
||||
});
|
||||
|
||||
$("#b2").click(function() {
|
||||
map.removeLayer(myLayerGroup);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<div id="buttons">
|
||||
<button type="button" id="b1"> Add Layer</button>
|
||||
<button type="button" id="b2"> Remove Layer</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
37
debug/tests/bringtoback.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<button id="foo">Click to add layer, then zoom out or in</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = new L.Map('map', { center: new L.LatLng(45.50144, -122.67599), zoom: 4 });
|
||||
|
||||
var demoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/tile/{z}/{y}/{x}';
|
||||
var demoMap = new L.TileLayer(demoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
|
||||
map.addLayer(demoMap);
|
||||
|
||||
$('#foo').click(function() {
|
||||
var topoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}';
|
||||
var topoMap = new L.TileLayer(topoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
map.addLayer(topoMap);
|
||||
topoMap.bringToBack();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
51
debug/tests/click_on_canvas.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
|
||||
<script>
|
||||
L_PREFER_CANVAS = true;
|
||||
$(document).ready(function() {
|
||||
var map = L.map('map', {
|
||||
minZoom: 1,
|
||||
maxZoom: 19,
|
||||
center: [51.505, -0.09],
|
||||
zoom: 9
|
||||
});
|
||||
|
||||
var polygons = new L.FeatureGroup();
|
||||
var points = [[51.505, -0.01], [51.505, -0.09], [51.55, -0.09]];
|
||||
|
||||
polygons.addLayer(
|
||||
new L.Polyline(
|
||||
points, {
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
smoothFactor: 1,
|
||||
color: 'red'
|
||||
}));
|
||||
|
||||
polygons.on('click', function(m) {
|
||||
// m.layer is the clicked polygon here
|
||||
//m.layer.bindPopup('hello!').openPopup();
|
||||
console.log(m.layer)
|
||||
});
|
||||
|
||||
polygons.addTo(map);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
49
debug/tests/click_on_canvas_broken.html
Normal file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.css" />
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
|
||||
<script>
|
||||
L_PREFER_CANVAS = true;
|
||||
$(document).ready(function() {
|
||||
var map = L.map('map', {
|
||||
minZoom: 1,
|
||||
maxZoom: 19,
|
||||
center: [51.505, -0.09],
|
||||
zoom: 9
|
||||
});
|
||||
|
||||
var polygons = new L.FeatureGroup();
|
||||
var points = [[51.505, -0.01], [51.505, -0.09], [51.55, -0.09]];
|
||||
|
||||
polygons.addLayer(
|
||||
new L.Polyline(
|
||||
points, {
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
smoothFactor: 1,
|
||||
color: 'red'
|
||||
}));
|
||||
|
||||
polygons.on('click', function(m) {
|
||||
// m.layer is the clicked polygon here
|
||||
//m.layer.bindPopup('hello!').openPopup();
|
||||
console.log(m.layer)
|
||||
});
|
||||
|
||||
polygons.addTo(map);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
56
debug/tests/opacity.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
<style>
|
||||
.mybox {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
latlng = new L.LatLng(50.5, 30.51);
|
||||
|
||||
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
||||
|
||||
//Create a marker, clicking it toggles opacity
|
||||
var marker = new L.Marker(latlng, { icon: new L.DivIcon({ className: 'mybox', iconSize: new L.Point(100,100), html: 'opaque. click to toggle' }) });
|
||||
map.addLayer(marker);
|
||||
|
||||
var visible = true;
|
||||
marker.on('click', function () {
|
||||
if (visible) {
|
||||
marker.setOpacity(0.3);
|
||||
marker._icon.innerHTML = 'transparent';
|
||||
} else {
|
||||
marker.setOpacity(1);
|
||||
marker._icon.innerHTML = 'opaque';
|
||||
}
|
||||
visible = !visible;
|
||||
});
|
||||
|
||||
var marker2 = new L.Marker(new L.LatLng(50.5, 30.52));
|
||||
map.addLayer(marker2);
|
||||
marker2.bindPopup('This is an amazing message. I shouldn\'t of deleted the Ipsum text');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
41
debug/tests/removetilewhilepan.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = new L.Map('map', { center: new L.LatLng(45.50144, -122.67599), zoom: 4 });
|
||||
|
||||
var demoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/tile/{z}/{y}/{x}';
|
||||
var demoMap = new L.TileLayer(demoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
|
||||
var topoUrl = 'http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}';
|
||||
var topoMap = new L.TileLayer(topoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
map.addLayer(topoMap);
|
||||
|
||||
map.addLayer(demoMap);
|
||||
|
||||
map.on('dragstart', function () {
|
||||
console.log('dragstart');
|
||||
setTimeout(function () {
|
||||
console.log('removing');
|
||||
map.removeLayer(demoMap);
|
||||
}, 400);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -31,6 +31,7 @@
|
||||
map.addLayer(polygon);
|
||||
|
||||
var polyline = new L.Polyline([
|
||||
[51.50, -0.04],
|
||||
[51.49, -0.02],
|
||||
[51.51, 0],
|
||||
[51.52, -0.02]
|
||||
|
@ -8,44 +8,166 @@
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<style>
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.info {
|
||||
padding: 6px 8px;
|
||||
font: 14px/16px Arial, Helvetica, sans-serif;
|
||||
background: white;
|
||||
background: rgba(255,255,255,0.8);
|
||||
box-shadow: 0 0 15px rgba(0,0,0,0.2);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.info h4 {
|
||||
margin: 0 0 5px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.legend {
|
||||
text-align: left;
|
||||
line-height: 18px;
|
||||
color: #555;
|
||||
}
|
||||
.legend i {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
float: left;
|
||||
margin-right: 8px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<button id="populate">Populate with 10 markers</button>
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript" src="geojson-sample.js"></script>
|
||||
<script type="text/javascript" src="us-states.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
||||
var map = L.map('map').setView([37.8, -96], 4);
|
||||
|
||||
var map = new L.Map('map', {
|
||||
center: new L.LatLng(0.78, 102.37),
|
||||
zoom: 7,
|
||||
layers: [cloudmade]
|
||||
});
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 998
|
||||
}).addTo(map);
|
||||
|
||||
var geojson = L.geoJson(geojsonSample, {
|
||||
|
||||
style: function (feature) {
|
||||
return {color: feature.properties.color};
|
||||
},
|
||||
|
||||
onEachFeature: function (feature, layer) {
|
||||
var popupText = 'geometry type: ' + feature.geometry.type;
|
||||
// control that shows state info on hover
|
||||
var info = L.control();
|
||||
|
||||
if (feature.properties.color) {
|
||||
popupText += '<br/>color: ' + feature.properties.color
|
||||
}
|
||||
info.onAdd = function (map) {
|
||||
this._div = L.DomUtil.create('div', 'info');
|
||||
this.update();
|
||||
return this._div;
|
||||
};
|
||||
|
||||
layer.bindPopup(popupText);
|
||||
info.update = function (props) {
|
||||
this._div.innerHTML = '<h4>US Population Density</h4>' + (props ?
|
||||
'<b>' + props.name + '</b><br />' + props.density + ' people / mi<sup>2</sup>'
|
||||
: 'Hover over a state');
|
||||
};
|
||||
|
||||
info.addTo(map);
|
||||
|
||||
|
||||
// get color depending on population density value
|
||||
function getColor(d) {
|
||||
return d > 1000 ? '#800026' :
|
||||
d > 500 ? '#BD0026' :
|
||||
d > 200 ? '#E31A1C' :
|
||||
d > 100 ? '#FC4E2A' :
|
||||
d > 50 ? '#FD8D3C' :
|
||||
d > 20 ? '#FEB24C' :
|
||||
d > 10 ? '#FED976' :
|
||||
'#FFEDA0';
|
||||
}
|
||||
|
||||
function style(feature) {
|
||||
return {
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
color: 'white',
|
||||
dashArray: '3',
|
||||
fillOpacity: 0.7,
|
||||
fillColor: getColor(feature.properties.density)
|
||||
};
|
||||
}
|
||||
|
||||
function highlightFeature(e) {
|
||||
var layer = e.target;
|
||||
|
||||
layer.setStyle({
|
||||
weight: 5,
|
||||
color: '#666',
|
||||
dashArray: '',
|
||||
fillOpacity: 0.7
|
||||
});
|
||||
|
||||
if (!L.Browser.ie) {
|
||||
layer.bringToFront();
|
||||
}
|
||||
});
|
||||
|
||||
map.addLayer(geojson);
|
||||
info.update(layer.feature.properties);
|
||||
}
|
||||
|
||||
var geojson;
|
||||
|
||||
function resetHighlight(e) {
|
||||
geojson.resetStyle(e.target);
|
||||
info.update();
|
||||
}
|
||||
|
||||
function zoomToFeature(e) {
|
||||
map.fitBounds(e.target.getBounds());
|
||||
}
|
||||
|
||||
function onEachFeature(feature, layer) {
|
||||
layer.on({
|
||||
mouseover: highlightFeature,
|
||||
mouseout: resetHighlight,
|
||||
click: zoomToFeature
|
||||
});
|
||||
}
|
||||
|
||||
geojson = L.geoJson(statesData, {
|
||||
style: style,
|
||||
onEachFeature: onEachFeature
|
||||
}).addTo(map);
|
||||
|
||||
map.attributionControl.addAttribution('Population data © <a href="http://census.gov/">US Census Bureau</a>');
|
||||
|
||||
|
||||
var legend = L.control({position: 'bottomright'});
|
||||
|
||||
legend.onAdd = function (map) {
|
||||
|
||||
var div = L.DomUtil.create('div', 'info legend'),
|
||||
grades = [0, 10, 20, 50, 100, 200, 500, 1000],
|
||||
labels = [],
|
||||
from, to;
|
||||
|
||||
for (var i = 0; i < grades.length; i++) {
|
||||
from = grades[i];
|
||||
to = grades[i + 1];
|
||||
|
||||
labels.push(
|
||||
'<i style="background:' + getColor(from + 1) + '"></i> ' +
|
||||
from + (to ? '–' + to : '+'));
|
||||
}
|
||||
|
||||
div.innerHTML = labels.join('<br>');
|
||||
return div;
|
||||
};
|
||||
|
||||
legend.addTo(map);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
54
debug/vector/us-states.js
Normal file
BIN
dist/images/layers.png
vendored
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 973 B |
BIN
dist/images/marker-icon.png
vendored
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
dist/images/marker-icon@2x.png
vendored
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
dist/images/marker-shadow.png
vendored
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 797 B |
BIN
dist/images/zoom-in.png
vendored
Before Width: | Height: | Size: 963 B |
BIN
dist/images/zoom-out.png
vendored
Before Width: | Height: | Size: 959 B |
3284
dist/leaflet-src.js
vendored
382
dist/leaflet.css
vendored
@ -12,60 +12,55 @@
|
||||
.leaflet-overlay-pane svg,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer { /* TODO optimize classes */
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
outline: 0;
|
||||
-ms-touch-action: none;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
.leaflet-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-dragging, .leaflet-dragging .leaflet-clickable {
|
||||
cursor: move;
|
||||
}
|
||||
/* map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container img {
|
||||
/* map is broken in FF if you have max-width: 100% on tiles */
|
||||
max-width: none !important;
|
||||
}
|
||||
/* stupid Android 2 doesn't understand "max-width: none" properly */
|
||||
.leaflet-container img.leaflet-image-layer {
|
||||
/* stupid Android 2 doesn't understand "max-width: none" properly */
|
||||
max-width: 15000px !important;
|
||||
}
|
||||
|
||||
.leaflet-tile-pane { z-index: 2; }
|
||||
.leaflet-objects-pane { z-index: 3; }
|
||||
.leaflet-overlay-pane { z-index: 4; }
|
||||
.leaflet-shadow-pane { z-index: 5; }
|
||||
.leaflet-marker-pane { z-index: 6; }
|
||||
.leaflet-popup-pane { z-index: 7; }
|
||||
|
||||
max-width: 15000px !important;
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* Leaflet controls */
|
||||
.leaflet-tile-pane { z-index: 2; }
|
||||
.leaflet-objects-pane { z-index: 3; }
|
||||
.leaflet-overlay-pane { z-index: 4; }
|
||||
.leaflet-shadow-pane { z-index: 5; }
|
||||
.leaflet-marker-pane { z-index: 6; }
|
||||
.leaflet-popup-pane { z-index: 7; }
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
@ -110,58 +105,191 @@
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.leaflet-control-zoom {
|
||||
-moz-border-radius: 7px;
|
||||
-webkit-border-radius: 7px;
|
||||
border-radius: 7px;
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-tile,
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
-o-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-control-zoom {
|
||||
padding: 5px;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
.leaflet-fade-anim .leaflet-tile-loaded,
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile,
|
||||
.leaflet-touching .leaflet-zoom-animated {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-container {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging,
|
||||
.leaflet-dragging .leaflet-clickable,
|
||||
.leaflet-dragging .leaflet-container {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
}
|
||||
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline: 0;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-container a.leaflet-active {
|
||||
outline: 2px solid orange;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #05f;
|
||||
background: white;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 0 8px rgba(0,0,0,0.4);
|
||||
border: 1px solid #888;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-bar-part {
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
.leaflet-bar-part-top {
|
||||
-webkit-border-radius: 4px 4px 0 0;
|
||||
border-radius: 4px 4px 0 0;
|
||||
}
|
||||
.leaflet-bar-part-bottom {
|
||||
-webkit-border-radius: 0 0 4px 4px;
|
||||
border-radius: 0 0 4px 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar {
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar-part {
|
||||
border-bottom: 4px solid rgba(0,0,0,0.3);
|
||||
}
|
||||
.leaflet-touch .leaflet-bar-part-top {
|
||||
-webkit-border-radius: 7px 7px 0 0;
|
||||
border-radius: 7px 7px 0 0;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar-part-bottom {
|
||||
-webkit-border-radius: 0 0 7px 7px;
|
||||
border-radius: 0 0 7px 7px;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-container .leaflet-control-zoom {
|
||||
margin-left: 13px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.leaflet-control-zoom a {
|
||||
background-color: rgba(255, 255, 255, 0.75);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-control-zoom a, .leaflet-control-layers a {
|
||||
.leaflet-control-zoom a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-control-zoom a {
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
}
|
||||
.leaflet-control-zoom a:hover {
|
||||
background-color: #fff;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-zoom a {
|
||||
width: 27px;
|
||||
height: 27px;
|
||||
color: #777;
|
||||
}
|
||||
.leaflet-control-zoom-in {
|
||||
background-image: url(images/zoom-in.png);
|
||||
margin-bottom: 5px;
|
||||
font: bold 18px/24px Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.leaflet-control-zoom-out {
|
||||
background-image: url(images/zoom-out.png);
|
||||
font: bold 23px/20px Tahoma, Verdana, sans-serif;
|
||||
}
|
||||
.leaflet-control-zoom a.leaflet-control-zoom-disabled {
|
||||
cursor: default;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 7px #999;
|
||||
background: #f8f8f9;
|
||||
-moz-border-radius: 8px;
|
||||
-webkit-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
.leaflet-touch .leaflet-control-zoom a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.leaflet-control-layers a {
|
||||
.leaflet-touch .leaflet-control-zoom-in {
|
||||
font-size: 24px;
|
||||
line-height: 29px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 28px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 7px rgba(0,0,0,0.4);
|
||||
background: #f8f8f9;
|
||||
-webkit-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers a {
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
@ -175,11 +303,10 @@
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers input {
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
@ -193,94 +320,64 @@
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
box-shadow: 0 0 5px #bbb;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.leaflet-container .leaflet-control-attribution,
|
||||
.leaflet-container .leaflet-control-scale {
|
||||
font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
color: black;
|
||||
line-height: 1;
|
||||
font-size: 10px;
|
||||
padding-bottom: 2px;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
font-size: 11px;
|
||||
text-shadow: 1px 1px 1px #fff;
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.2);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
padding-top: 1px;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-layers {
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-control-zoom {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers {
|
||||
border: 5px solid #bbb;
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-control-zoom {
|
||||
border: 4px solid rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
|
||||
/* Zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-tile, .leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
-o-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-tile-loaded, .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0.25,0.1,0.25,0.75);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0.25,0.1,0.25,0.75);
|
||||
-o-transition: -o-transform 0.25s cubic-bezier(0.25,0.1,0.25,0.75);
|
||||
transition: transform 0.25s cubic-bezier(0.25,0.1,0.25,0.75);
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile,
|
||||
.leaflet-touching .leaflet-zoom-animated {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* Popup layout */
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
@ -289,9 +386,15 @@
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 14px 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 18px 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
margin: 0 auto;
|
||||
@ -307,11 +410,16 @@
|
||||
|
||||
margin: -8px auto 0;
|
||||
|
||||
-moz-transform: rotate(45deg);
|
||||
-webkit-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
-o-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
-o-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||
background: white;
|
||||
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
@ -325,13 +433,11 @@
|
||||
color: #c3c3c3;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover {
|
||||
color: #999;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 18px 0;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
border-bottom: 1px solid #ddd;
|
||||
@ -339,41 +445,13 @@
|
||||
}
|
||||
|
||||
|
||||
/* Visual appearance */
|
||||
/* div icon */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-container a.leaflet-active {
|
||||
outline: 2px solid orange;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #05f;
|
||||
background: white;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
.leaflet-editing-icon {
|
||||
border-radius: 2px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||
background: white;
|
||||
|
||||
box-shadow: 0 3px 10px #888;
|
||||
-moz-box-shadow: 0 3px 10px #888;
|
||||
-webkit-box-shadow: 0 3px 14px #999;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
-moz-border-radius: 20px;
|
||||
-webkit-border-radius: 20px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
font: 12px/1.4 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
31
dist/leaflet.ie.css
vendored
@ -3,11 +3,11 @@
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.leaflet-control {
|
||||
display: inline;
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
_width: 27px;
|
||||
margin: 0 auto;
|
||||
_margin-top: -3px;
|
||||
|
||||
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
}
|
||||
@ -25,11 +25,15 @@
|
||||
margin-top: -1px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
|
||||
border: 1px solid #bbb;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.leaflet-control-zoom {
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#3F000000',EndColorStr='#3F000000');
|
||||
.leaflet-control-zoom,
|
||||
.leaflet-control-layers {
|
||||
border: 3px solid #999;
|
||||
}
|
||||
.leaflet-control-zoom a {
|
||||
background-color: #eee;
|
||||
@ -39,6 +43,15 @@
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
}
|
||||
.leaflet-control-attribution, .leaflet-control-layers {
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-layers,
|
||||
.leaflet-control-scale-line {
|
||||
background: white;
|
||||
}
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
filter: alpha(opacity=50);
|
||||
}
|
||||
.leaflet-control-attribution {
|
||||
border-top: 1px solid #bbb;
|
||||
border-left: 1px solid #bbb;
|
||||
}
|
||||
|
10
dist/leaflet.js
vendored
93
spec/happen.js
Normal file
@ -0,0 +1,93 @@
|
||||
// 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);
|
@ -5,6 +5,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css">
|
||||
<script type="text/javascript" src="jasmine/jasmine.js"></script>
|
||||
<script type="text/javascript" src="jasmine/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="happen.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
|
||||
@ -20,6 +21,10 @@
|
||||
<script type="text/javascript" src="suites/SpecHelper.js"></script>
|
||||
<script type="text/javascript" src="suites/LeafletSpec.js"></script>
|
||||
|
||||
<!-- /control -->
|
||||
<script type="text/javascript" src="suites/control/Control.LayersSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/control/Control.ScaleSpec.js"></script>
|
||||
|
||||
<!-- /core -->
|
||||
<script type="text/javascript" src="suites/core/UtilSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/core/ClassSpec.js"></script>
|
||||
@ -42,6 +47,7 @@
|
||||
<!-- /layer -->
|
||||
<script type="text/javascript" src="suites/layer/TileLayerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineGeometrySpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleSpec.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
<script type="text/javascript" src="suites/map/MapSpec.js"></script>
|
||||
@ -63,4 +69,4 @@
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
67
spec/suites/control/Control.LayersSpec.js
Normal file
@ -0,0 +1,67 @@
|
||||
describe("Control.Layers", function () {
|
||||
var map;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
});
|
||||
|
||||
describe("baselayerchange event", function () {
|
||||
it("is fired on input that changes the base layer", function () {
|
||||
var baseLayers = {"Layer 1": L.tileLayer(), "Layer 2": L.tileLayer()},
|
||||
layers = L.control.layers(baseLayers).addTo(map),
|
||||
spy = jasmine.createSpy();
|
||||
|
||||
map.on('baselayerchange', spy)
|
||||
.whenReady(function(){
|
||||
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.mostRecentCall.args[0].layer).toBe(baseLayers["Layer 1"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("is not fired on input that doesn't change the base layer", function () {
|
||||
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
|
||||
layers = L.control.layers({}, overlays).addTo(map),
|
||||
spy = jasmine.createSpy();
|
||||
|
||||
map.on('baselayerchange', spy);
|
||||
happen.click(layers._overlaysList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("updates", function () {
|
||||
beforeEach(function () {
|
||||
map.setView([0, 0], 14);
|
||||
});
|
||||
|
||||
it("when an included layer is addded or removed", function () {
|
||||
var baseLayer = L.tileLayer(),
|
||||
overlay = L.marker([0, 0]),
|
||||
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
|
||||
|
||||
spyOn(layers, '_update').andCallThrough();
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(layers._update).toHaveBeenCalled();
|
||||
expect(layers._update.callCount).toEqual(2);
|
||||
});
|
||||
|
||||
it("not when a non-included layer is added or removed", function () {
|
||||
var baseLayer = L.tileLayer(),
|
||||
overlay = L.marker([0, 0]),
|
||||
layers = L.control.layers({"Base": baseLayer}).addTo(map);
|
||||
|
||||
spyOn(layers, '_update').andCallThrough();
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(layers._update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
6
spec/suites/control/Control.ScaleSpec.js
Normal file
@ -0,0 +1,6 @@
|
||||
describe("Control.Scale", function () {
|
||||
it("can be added to an unloaded map", function () {
|
||||
var map = L.map(document.createElement('div'));
|
||||
new L.Control.Scale().addTo(map);
|
||||
})
|
||||
});
|
@ -1,10 +1,10 @@
|
||||
describe("Class", function() {
|
||||
|
||||
|
||||
describe("#extend", function() {
|
||||
var Klass,
|
||||
constructor,
|
||||
method;
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
constructor = jasmine.createSpy("Klass constructor");
|
||||
method = jasmine.createSpy("Klass#bar method");
|
||||
@ -12,78 +12,78 @@ describe("Class", function() {
|
||||
Klass = L.Class.extend({
|
||||
statics: {bla: 1},
|
||||
includes: {mixin: true},
|
||||
|
||||
|
||||
initialize: constructor,
|
||||
foo: 5,
|
||||
bar: method
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should create a class with the given constructor & properties", function() {
|
||||
var a = new Klass();
|
||||
|
||||
|
||||
expect(constructor).toHaveBeenCalled();
|
||||
expect(a.foo).toEqual(5);
|
||||
|
||||
|
||||
a.bar();
|
||||
|
||||
|
||||
expect(method).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
it("should inherit parent classes' constructor & properties", function() {
|
||||
var Klass2 = Klass.extend({baz: 2});
|
||||
|
||||
|
||||
var b = new Klass2();
|
||||
|
||||
|
||||
expect(b instanceof Klass).toBeTruthy();
|
||||
expect(b instanceof Klass2).toBeTruthy();
|
||||
|
||||
|
||||
expect(constructor).toHaveBeenCalled();
|
||||
expect(b.baz).toEqual(2);
|
||||
|
||||
|
||||
b.bar();
|
||||
|
||||
|
||||
expect(method).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
it("should support static properties", function() {
|
||||
expect(Klass.bla).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it("should inherit parent static properties", function() {
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
|
||||
expect(Klass2.bla).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it("should override parent static properties", function() {
|
||||
var Klass2 = Klass.extend({statics: {bla: 2}});
|
||||
|
||||
|
||||
expect(Klass2.bla).toEqual(2);
|
||||
});
|
||||
|
||||
|
||||
it("should include the given mixin", function() {
|
||||
var a = new Klass();
|
||||
expect(a.mixin).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
it("should be able to include multiple mixins", function() {
|
||||
var Klass2 = L.Class.extend({
|
||||
includes: [{mixin: true}, {mixin2: true}]
|
||||
});
|
||||
var a = new Klass2();
|
||||
|
||||
|
||||
expect(a.mixin).toBeTruthy();
|
||||
expect(a.mixin2).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
it("should grant the ability to include the given mixin", function() {
|
||||
Klass.include({mixin2: true});
|
||||
|
||||
|
||||
var a = new Klass();
|
||||
expect(a.mixin2).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
it("should merge options instead of replacing them", function() {
|
||||
var KlassWithOptions1 = L.Class.extend({
|
||||
options: {
|
||||
@ -97,18 +97,60 @@ describe("Class", function() {
|
||||
foo3: 4
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var a = new KlassWithOptions2();
|
||||
|
||||
|
||||
expect(a.options).toEqual({
|
||||
foo1: 1,
|
||||
foo2: 3,
|
||||
foo3: 4
|
||||
});
|
||||
});
|
||||
|
||||
it("should add constructor hooks correctly", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1");
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass.addInitHook('bar', 1, 2, 3);
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(method).toHaveBeenCalledWith(1, 2, 3);
|
||||
});
|
||||
|
||||
it("should inherit constructor hooks", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1"),
|
||||
spy2 = jasmine.createSpy("init hook 2");
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass2.addInitHook(spy2);
|
||||
|
||||
var a = new Klass2();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not call child constructor hooks", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1"),
|
||||
spy2 = jasmine.createSpy("init hook 2");
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass2.addInitHook(spy2);
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(spy2).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Class.include
|
||||
|
||||
// TODO Class.mergeOptions
|
||||
});
|
||||
});
|
||||
|
@ -61,6 +61,35 @@ describe('Util', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#getParamString', function() {
|
||||
it('should create a valid query string for appending depending on url input', function() {
|
||||
var a = {
|
||||
url: "http://example.com/get",
|
||||
obj: {bar: 7, baz: 3},
|
||||
result: "?bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(a.obj,a.url)).toEqual(a.result);
|
||||
|
||||
var b = {
|
||||
url: "http://example.com/get?justone=qs",
|
||||
obj: {bar: 7, baz: 3},
|
||||
result: "&bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(b.obj,b.url)).toEqual(b.result);
|
||||
|
||||
var c = {
|
||||
url: undefined,
|
||||
obj: {bar: 7, baz: 3},
|
||||
result: "?bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(c.obj,c.url)).toEqual(c.result);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO cancel/requestAnimFrame?
|
||||
|
||||
// TODO limitExecByInterval
|
||||
@ -71,7 +100,5 @@ describe('Util', function() {
|
||||
|
||||
// TODO setOptions
|
||||
|
||||
// TODO getParamString
|
||||
|
||||
// TODO template
|
||||
});
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ describe('DomEvent', function() {
|
||||
});
|
||||
|
||||
describe('#removeListener', function() {
|
||||
it('should remove prevously added listener', function() {
|
||||
it('should remove previously added listener', function() {
|
||||
var listener = jasmine.createSpy('listener');
|
||||
|
||||
L.DomEvent.addListener(el, 'click', listener);
|
||||
|
@ -1 +1,23 @@
|
||||
describe('LatLngBounds', noSpecs);
|
||||
describe('LatLngBounds', function() {
|
||||
var a, c;
|
||||
|
||||
beforeEach(function() {
|
||||
a = new L.LatLngBounds(
|
||||
new L.LatLng(14, 12),
|
||||
new L.LatLng(30, 40));
|
||||
c = new L.LatLngBounds();
|
||||
});
|
||||
|
||||
describe('#isValid', function() {
|
||||
it('should return true if properly set up', function() {
|
||||
expect(a.isValid()).toBeTruthy();
|
||||
});
|
||||
it('should return false if is invalid', function() {
|
||||
expect(c.isValid()).toBeFalsy();
|
||||
});
|
||||
it('should be valid if extended', function() {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
@ -4,73 +4,59 @@ describe('LatLng', function() {
|
||||
var a = new L.LatLng(25, 74);
|
||||
expect(a.lat).toEqual(25);
|
||||
expect(a.lng).toEqual(74);
|
||||
|
||||
|
||||
var a = new L.LatLng(-25, -74);
|
||||
expect(a.lat).toEqual(-25);
|
||||
expect(a.lng).toEqual(-74);
|
||||
});
|
||||
|
||||
it("should clamp latitude to lie between -90 and 90", function() {
|
||||
var a = new L.LatLng(150, 0).lat;
|
||||
expect(a).toEqual(90);
|
||||
|
||||
var b = new L.LatLng(-230, 0).lat;
|
||||
expect(b).toEqual(-90);
|
||||
});
|
||||
|
||||
it("should clamp longtitude to lie between -180 and 180", function() {
|
||||
var a = new L.LatLng(0, 190).lng;
|
||||
expect(a).toEqual(-170);
|
||||
|
||||
var b = new L.LatLng(0, 360).lng;
|
||||
expect(b).toEqual(0);
|
||||
|
||||
var c = new L.LatLng(0, 380).lng;
|
||||
expect(c).toEqual(20);
|
||||
|
||||
var d = new L.LatLng(0, -190).lng;
|
||||
expect(d).toEqual(170);
|
||||
|
||||
var e = new L.LatLng(0, -360).lng;
|
||||
expect(e).toEqual(0);
|
||||
|
||||
var f = new L.LatLng(0, -380).lng;
|
||||
expect(f).toEqual(-20);
|
||||
|
||||
var g = new L.LatLng(0, 90).lng;
|
||||
expect(g).toEqual(90);
|
||||
|
||||
var h = new L.LatLng(0, 180).lng;
|
||||
expect(h).toEqual(180);
|
||||
});
|
||||
|
||||
it("should not clamp latitude and longtitude if unbounded flag set to true", function() {
|
||||
var a = new L.LatLng(150, 0, true).lat;
|
||||
expect(a).toEqual(150);
|
||||
|
||||
var b = new L.LatLng(-230, 0, true).lat;
|
||||
expect(b).toEqual(-230);
|
||||
|
||||
var c = new L.LatLng(0, 250, true).lng;
|
||||
expect(c).toEqual(250);
|
||||
|
||||
var d = new L.LatLng(0, -190, true).lng;
|
||||
expect(d).toEqual(-190);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#equals', function() {
|
||||
it("should return true if compared objects are equal within a certain margin", function() {
|
||||
var a = new L.LatLng(10, 20);
|
||||
var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
|
||||
expect(a.equals(b)).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
it("should return false if compared objects are not equal within a certain margin", function() {
|
||||
var a = new L.LatLng(10, 20);
|
||||
var b = new L.LatLng(10, 23.3);
|
||||
expect(a.equals(b)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#wrap', function () {
|
||||
it("#wrap should wrap longitude to lie between -180 and 180 by default", function() {
|
||||
var a = new L.LatLng(0, 190).wrap().lng;
|
||||
expect(a).toEqual(-170);
|
||||
|
||||
var b = new L.LatLng(0, 360).wrap().lng;
|
||||
expect(b).toEqual(0);
|
||||
|
||||
var c = new L.LatLng(0, 380).wrap().lng;
|
||||
expect(c).toEqual(20);
|
||||
|
||||
var d = new L.LatLng(0, -190).wrap().lng;
|
||||
expect(d).toEqual(170);
|
||||
|
||||
var e = new L.LatLng(0, -360).wrap().lng;
|
||||
expect(e).toEqual(0);
|
||||
|
||||
var f = new L.LatLng(0, -380).wrap().lng;
|
||||
expect(f).toEqual(-20);
|
||||
|
||||
var g = new L.LatLng(0, 90).wrap().lng;
|
||||
expect(g).toEqual(90);
|
||||
|
||||
var h = new L.LatLng(0, 180).wrap().lng;
|
||||
expect(h).toEqual(180);
|
||||
});
|
||||
|
||||
it("#wrap should wrap longitude within the given range", function() {
|
||||
var a = new L.LatLng(0, 190).wrap(-100, 100).lng;
|
||||
expect(a).toEqual(-10);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
describe('Bounds', function() {
|
||||
var a, b;
|
||||
var a, b, c;
|
||||
|
||||
beforeEach(function() {
|
||||
a = new L.Bounds(
|
||||
new L.Point(14, 12),
|
||||
new L.Point(30, 40));
|
||||
b = new L.Bounds([
|
||||
new L.Point(20, 12),
|
||||
new L.Point(14, 20),
|
||||
new L.Point(30, 40)
|
||||
]);
|
||||
new L.Point(20, 12),
|
||||
new L.Point(14, 20),
|
||||
new L.Point(30, 40)
|
||||
]);
|
||||
c = new L.Bounds();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
@ -40,14 +41,27 @@ describe('Bounds', function() {
|
||||
expect(a.getCenter()).toEqual(new L.Point(22, 26));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#contains', function() {
|
||||
it('should contains other bounds or point', function() {
|
||||
a.extend(new L.Point(50, 10));
|
||||
expect(a.contains(b)).toBeTruthy();
|
||||
expect(b.contains(a)).toBeFalsy();
|
||||
expect(a.contains(new L.Point(24, 25))).toBeTruthy();
|
||||
expect(a.contains(new L.Point(54, 65))).toBeFalsy();
|
||||
});
|
||||
it('should contains other bounds or point', function() {
|
||||
a.extend(new L.Point(50, 10));
|
||||
expect(a.contains(b)).toBeTruthy();
|
||||
expect(b.contains(a)).toBeFalsy();
|
||||
expect(a.contains(new L.Point(24, 25))).toBeTruthy();
|
||||
expect(a.contains(new L.Point(54, 65))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isValid', function() {
|
||||
it('should return true if properly set up', function() {
|
||||
expect(a.isValid()).toBeTruthy();
|
||||
});
|
||||
it('should return false if is invalid', function() {
|
||||
expect(c.isValid()).toBeFalsy();
|
||||
});
|
||||
it('should be valid if extended', function() {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
@ -1 +1,75 @@
|
||||
describe('TileLayer', noSpecs);
|
||||
|
||||
describe('TileLayer', function () {
|
||||
describe("#getMaxZoom, #getMinZoom", function () {
|
||||
var map;
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
});
|
||||
describe("when a tilelayer is added to a map with no other layers", function () {
|
||||
it("should have the same zoomlevels as the tilelayer", function () {
|
||||
var maxZoom = 10,
|
||||
minZoom = 5;
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
L.tileLayer("{z}{x}{y}", {
|
||||
maxZoom: maxZoom,
|
||||
minZoom: minZoom
|
||||
}).addTo(map);
|
||||
expect(map.getMaxZoom() === maxZoom).toBeTruthy();
|
||||
expect(map.getMinZoom() === minZoom).toBeTruthy();
|
||||
});
|
||||
});
|
||||
describe("when a tilelayer is added to a map that already has a tilelayer", function () {
|
||||
it("should have its zoomlevels updated to fit the new layer", function () {
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:10, maxZoom: 15 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(10);
|
||||
expect(map.getMaxZoom()).toBe(15);
|
||||
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 10 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5); // changed
|
||||
expect(map.getMaxZoom()).toBe(15); // unchanged
|
||||
|
||||
|
||||
L.tileLayer("{z}{x}{y}",{ minZoom:10, maxZoom: 20 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5); // unchanged
|
||||
expect(map.getMaxZoom()).toBe(20); // changed
|
||||
|
||||
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 25 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(0); // changed
|
||||
expect(map.getMaxZoom()).toBe(25); // changed
|
||||
});
|
||||
});
|
||||
describe("when a tilelayer is removed from a map", function () {
|
||||
it("it should have its zoomlevels updated to only fit the layers it currently has", function () {
|
||||
var tiles = [ L.tileLayer("{z}{x}{y}", { minZoom:10, maxZoom: 15 }).addTo(map),
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 10 }).addTo(map),
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:10, maxZoom: 20 }).addTo(map),
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 25 }).addTo(map)
|
||||
];
|
||||
map.whenReady(function() {
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(25);
|
||||
|
||||
map.removeLayer(tiles[0]);
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(25);
|
||||
|
||||
map.removeLayer(tiles[3]);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(20);
|
||||
|
||||
map.removeLayer(tiles[2]);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(10);
|
||||
|
||||
map.removeLayer(tiles[1]);
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(Infinity);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
17
spec/suites/layer/vector/CircleSpec.js
Normal file
@ -0,0 +1,17 @@
|
||||
describe('Circle', function () {
|
||||
describe('#getBounds', function () {
|
||||
|
||||
var circle;
|
||||
|
||||
beforeEach(function () {
|
||||
circle = L.circle([50, 30], 200);
|
||||
});
|
||||
|
||||
it('should return correct bounds', function () {
|
||||
var bounds = circle.getBounds();
|
||||
|
||||
expect(bounds.getSouthWest().equals([49.998203369, 29.997204939])).toBeTruthy();
|
||||
expect(bounds.getNorthEast().equals([50.001796631, 30.002795061])).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
@ -1 +1,54 @@
|
||||
describe("Map", noSpecs);
|
||||
describe("Map", function () {
|
||||
describe("#whenReady", function () {
|
||||
describe("when the map has not yet been loaded", function () {
|
||||
it("calls the callback when the map is loaded", function () {
|
||||
var map = L.map(document.createElement('div')),
|
||||
spy = jasmine.createSpy();
|
||||
|
||||
map.whenReady(spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
|
||||
map.setView([0, 0], 1);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the map has already been loaded", function () {
|
||||
it("calls the callback immediately", function () {
|
||||
var map = L.map(document.createElement('div')),
|
||||
spy = jasmine.createSpy();
|
||||
|
||||
map.setView([0, 0], 1);
|
||||
map.whenReady(spy);
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#getBounds", function () {
|
||||
it("is safe to call from within a moveend callback during initial "
|
||||
+ "load (#1027)", function () {
|
||||
var c = document.createElement('div'),
|
||||
map = L.map(c);
|
||||
|
||||
map.on("moveend", function () {
|
||||
map.getBounds();
|
||||
});
|
||||
|
||||
map.setView([51.505, -0.09], 13);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#getMinZoom and #getMaxZoom", function () {
|
||||
it("The minZoom and maxZoom options overrides any"
|
||||
+ " minZoom and maxZoom set on layers", function () {
|
||||
var c = document.createElement('div'),
|
||||
map = L.map(c, { minZoom: 5, maxZoom: 10 });
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 15 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* The L namespace contains all Leaflet classes and functions.
|
||||
* This code allows you to handle any possible namespace conflicts.
|
||||
*/
|
||||
|
||||
var L, originalL;
|
||||
|
||||
if (typeof exports !== undefined + '') {
|
||||
@ -14,4 +19,4 @@ if (typeof exports !== undefined + '') {
|
||||
window.L = L;
|
||||
}
|
||||
|
||||
L.version = '0.4.2';
|
||||
L.version = '0.5';
|
||||
|
@ -1,11 +1,15 @@
|
||||
/*
|
||||
* L.Control.Attribution is used for displaying attribution on the map (added by default).
|
||||
*/
|
||||
|
||||
L.Control.Attribution = L.Control.extend({
|
||||
options: {
|
||||
position: 'bottomright',
|
||||
prefix: 'Powered by <a href="http://leaflet.cloudmade.com">Leaflet</a>'
|
||||
prefix: 'Powered by <a href="http://leafletjs.com">Leaflet</a>'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._attributions = {};
|
||||
},
|
||||
@ -15,8 +19,8 @@ L.Control.Attribution = L.Control.extend({
|
||||
L.DomEvent.disableClickPropagation(this._container);
|
||||
|
||||
map
|
||||
.on('layeradd', this._onLayerAdd, this)
|
||||
.on('layerremove', this._onLayerRemove, this);
|
||||
.on('layeradd', this._onLayerAdd, this)
|
||||
.on('layerremove', this._onLayerRemove, this);
|
||||
|
||||
this._update();
|
||||
|
||||
@ -25,8 +29,8 @@ L.Control.Attribution = L.Control.extend({
|
||||
|
||||
onRemove: function (map) {
|
||||
map
|
||||
.off('layeradd', this._onLayerAdd)
|
||||
.off('layerremove', this._onLayerRemove);
|
||||
.off('layeradd', this._onLayerAdd)
|
||||
.off('layerremove', this._onLayerRemove);
|
||||
|
||||
},
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* L.Control.Layers is a control to allow users to switch between different layers on the map.
|
||||
*/
|
||||
|
||||
L.Control.Layers = L.Control.extend({
|
||||
options: {
|
||||
@ -7,10 +10,11 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
initialize: function (baseLayers, overlays, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
this._lastZIndex = 0;
|
||||
this._handlingClick = false;
|
||||
|
||||
for (var i in baseLayers) {
|
||||
if (baseLayers.hasOwnProperty(i)) {
|
||||
@ -29,9 +33,19 @@ L.Control.Layers = L.Control.extend({
|
||||
this._initLayout();
|
||||
this._update();
|
||||
|
||||
map
|
||||
.on('layeradd', this._onLayerChange, this)
|
||||
.on('layerremove', this._onLayerChange, this);
|
||||
|
||||
return this._container;
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
map
|
||||
.off('layeradd', this._onLayerChange)
|
||||
.off('layerremove', this._onLayerChange);
|
||||
},
|
||||
|
||||
addBaseLayer: function (layer, name) {
|
||||
this._addLayer(layer, name);
|
||||
this._update();
|
||||
@ -45,7 +59,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
delete this._layers[id];
|
||||
this._update();
|
||||
return this;
|
||||
@ -57,6 +71,7 @@ L.Control.Layers = L.Control.extend({
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomEvent.disableClickPropagation(container);
|
||||
L.DomEvent.on(container, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
} else {
|
||||
L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
|
||||
}
|
||||
@ -65,8 +80,8 @@ L.Control.Layers = L.Control.extend({
|
||||
|
||||
if (this.options.collapsed) {
|
||||
L.DomEvent
|
||||
.on(container, 'mouseover', this._expand, this)
|
||||
.on(container, 'mouseout', this._collapse, this);
|
||||
.on(container, 'mouseover', this._expand, this)
|
||||
.on(container, 'mouseout', this._collapse, this);
|
||||
|
||||
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
|
||||
link.href = '#';
|
||||
@ -74,9 +89,9 @@ L.Control.Layers = L.Control.extend({
|
||||
|
||||
if (L.Browser.touch) {
|
||||
L.DomEvent
|
||||
.on(link, 'click', L.DomEvent.stopPropagation)
|
||||
.on(link, 'click', L.DomEvent.preventDefault)
|
||||
.on(link, 'click', this._expand, this);
|
||||
.on(link, 'click', L.DomEvent.stopPropagation)
|
||||
.on(link, 'click', L.DomEvent.preventDefault)
|
||||
.on(link, 'click', this._expand, this);
|
||||
}
|
||||
else {
|
||||
L.DomEvent.on(link, 'focus', this._expand, this);
|
||||
@ -96,7 +111,7 @@ L.Control.Layers = L.Control.extend({
|
||||
},
|
||||
|
||||
_addLayer: function (layer, name, overlay) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = {
|
||||
layer: layer,
|
||||
@ -119,7 +134,7 @@ L.Control.Layers = L.Control.extend({
|
||||
this._overlaysList.innerHTML = '';
|
||||
|
||||
var baseLayersPresent = false,
|
||||
overlaysPresent = false;
|
||||
overlaysPresent = false;
|
||||
|
||||
for (var i in this._layers) {
|
||||
if (this._layers.hasOwnProperty(i)) {
|
||||
@ -133,10 +148,18 @@ L.Control.Layers = L.Control.extend({
|
||||
this._separator.style.display = (overlaysPresent && baseLayersPresent ? '' : 'none');
|
||||
},
|
||||
|
||||
_onLayerChange: function (e) {
|
||||
var id = L.stamp(e.layer);
|
||||
|
||||
if (this._layers[id] && !this._handlingClick) {
|
||||
this._update();
|
||||
}
|
||||
},
|
||||
|
||||
// IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)
|
||||
_createRadioElement: function (name, checked) {
|
||||
|
||||
var radioHtml = '<input type="radio" name="' + name + '"';
|
||||
var radioHtml = '<input type="radio" class="leaflet-control-layers-selector" name="' + name + '"';
|
||||
if (checked) {
|
||||
radioHtml += ' checked="checked"';
|
||||
}
|
||||
@ -156,39 +179,56 @@ L.Control.Layers = L.Control.extend({
|
||||
if (obj.overlay) {
|
||||
input = document.createElement('input');
|
||||
input.type = 'checkbox';
|
||||
input.className = 'leaflet-control-layers-selector';
|
||||
input.defaultChecked = checked;
|
||||
} else {
|
||||
input = this._createRadioElement('leaflet-base-layers', checked);
|
||||
}
|
||||
|
||||
input.layerId = L.Util.stamp(obj.layer);
|
||||
input.layerId = L.stamp(obj.layer);
|
||||
|
||||
L.DomEvent.on(input, 'click', this._onInputClick, this);
|
||||
|
||||
var name = document.createTextNode(' ' + obj.name);
|
||||
var name = document.createElement('span');
|
||||
name.innerHTML = ' ' + obj.name;
|
||||
|
||||
label.appendChild(input);
|
||||
label.appendChild(name);
|
||||
|
||||
var container = obj.overlay ? this._overlaysList : this._baseLayersList;
|
||||
container.appendChild(label);
|
||||
|
||||
return label;
|
||||
},
|
||||
|
||||
_onInputClick: function () {
|
||||
var i, input, obj,
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
inputsLen = inputs.length;
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
inputsLen = inputs.length,
|
||||
baseLayer;
|
||||
|
||||
this._handlingClick = true;
|
||||
|
||||
for (i = 0; i < inputsLen; i++) {
|
||||
input = inputs[i];
|
||||
obj = this._layers[input.layerId];
|
||||
|
||||
if (input.checked) {
|
||||
this._map.addLayer(obj.layer, !obj.overlay);
|
||||
} else {
|
||||
if (input.checked && !this._map.hasLayer(obj.layer)) {
|
||||
this._map.addLayer(obj.layer);
|
||||
if (!obj.overlay) {
|
||||
baseLayer = obj.layer;
|
||||
}
|
||||
} else if (!input.checked && this._map.hasLayer(obj.layer)) {
|
||||
this._map.removeLayer(obj.layer);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseLayer) {
|
||||
this._map.setZoom(this._map.getZoom());
|
||||
this._map.fire('baselayerchange', {layer: baseLayer});
|
||||
}
|
||||
|
||||
this._handlingClick = false;
|
||||
},
|
||||
|
||||
_expand: function () {
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* L.Control.Scale is used for displaying metric/imperial scale on the map.
|
||||
*/
|
||||
|
||||
L.Control.Scale = L.Control.extend({
|
||||
options: {
|
||||
position: 'bottomleft',
|
||||
@ -17,7 +21,7 @@ L.Control.Scale = L.Control.extend({
|
||||
this._addScales(options, className, container);
|
||||
|
||||
map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
|
||||
this._update();
|
||||
map.whenReady(this._update, this);
|
||||
|
||||
return container;
|
||||
},
|
||||
@ -71,8 +75,8 @@ L.Control.Scale = L.Control.extend({
|
||||
|
||||
_updateImperial: function (maxMeters) {
|
||||
var maxFeet = maxMeters * 3.2808399,
|
||||
scale = this._iScale,
|
||||
maxMiles, miles, feet;
|
||||
scale = this._iScale,
|
||||
maxMiles, miles, feet;
|
||||
|
||||
if (maxFeet > 5280) {
|
||||
maxMiles = maxFeet / 5280;
|
||||
|
@ -1,30 +1,80 @@
|
||||
/*
|
||||
* L.Control.Zoom is used for the default zoom buttons on the map.
|
||||
*/
|
||||
|
||||
L.Control.Zoom = L.Control.extend({
|
||||
options: {
|
||||
position: 'topleft'
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
var className = 'leaflet-control-zoom',
|
||||
container = L.DomUtil.create('div', className);
|
||||
var zoomName = 'leaflet-control-zoom',
|
||||
barName = 'leaflet-bar',
|
||||
partName = barName + '-part',
|
||||
container = L.DomUtil.create('div', zoomName + ' ' + barName);
|
||||
|
||||
this._createButton('Zoom in', className + '-in', container, map.zoomIn, map);
|
||||
this._createButton('Zoom out', className + '-out', container, map.zoomOut, map);
|
||||
this._map = map;
|
||||
|
||||
this._zoomInButton = this._createButton('+', 'Zoom in',
|
||||
zoomName + '-in ' +
|
||||
partName + ' ' +
|
||||
partName + '-top',
|
||||
container, this._zoomIn, this);
|
||||
|
||||
this._zoomOutButton = this._createButton('-', 'Zoom out',
|
||||
zoomName + '-out ' +
|
||||
partName + ' ' +
|
||||
partName + '-bottom',
|
||||
container, this._zoomOut, this);
|
||||
|
||||
map.on('zoomend', this._updateDisabled, this);
|
||||
|
||||
return container;
|
||||
},
|
||||
|
||||
_createButton: function (title, className, container, fn, context) {
|
||||
onRemove: function (map) {
|
||||
map.off('zoomend', this._updateDisabled, this);
|
||||
},
|
||||
|
||||
_zoomIn: function (e) {
|
||||
this._map.zoomIn(e.shiftKey ? 3 : 1);
|
||||
},
|
||||
|
||||
_zoomOut: function (e) {
|
||||
this._map.zoomOut(e.shiftKey ? 3 : 1);
|
||||
},
|
||||
|
||||
_createButton: function (html, title, className, container, fn, context) {
|
||||
var link = L.DomUtil.create('a', className, container);
|
||||
link.innerHTML = html;
|
||||
link.href = '#';
|
||||
link.title = title;
|
||||
|
||||
var stop = L.DomEvent.stopPropagation;
|
||||
|
||||
L.DomEvent
|
||||
.on(link, 'click', L.DomEvent.stopPropagation)
|
||||
.on(link, 'click', L.DomEvent.preventDefault)
|
||||
.on(link, 'click', fn, context)
|
||||
.on(link, 'dblclick', L.DomEvent.stopPropagation);
|
||||
.on(link, 'click', stop)
|
||||
.on(link, 'mousedown', stop)
|
||||
.on(link, 'dblclick', stop)
|
||||
.on(link, 'click', L.DomEvent.preventDefault)
|
||||
.on(link, 'click', fn, context);
|
||||
|
||||
return link;
|
||||
},
|
||||
|
||||
_updateDisabled: function () {
|
||||
var map = this._map,
|
||||
className = 'leaflet-control-zoom-disabled';
|
||||
|
||||
L.DomUtil.removeClass(this._zoomInButton, className);
|
||||
L.DomUtil.removeClass(this._zoomOutButton, className);
|
||||
|
||||
if (map._zoom === map.getMinZoom()) {
|
||||
L.DomUtil.addClass(this._zoomOutButton, className);
|
||||
}
|
||||
if (map._zoom === map.getMaxZoom()) {
|
||||
L.DomUtil.addClass(this._zoomInButton, className);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -41,4 +91,5 @@ L.Map.addInitHook(function () {
|
||||
|
||||
L.control.zoom = function (options) {
|
||||
return new L.Control.Zoom(options);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* L.Control is a base class for implementing map controls. Handles positioning.
|
||||
* All other controls extend from this class.
|
||||
*/
|
||||
|
||||
L.Control = L.Class.extend({
|
||||
options: {
|
||||
@ -5,7 +9,7 @@ L.Control = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
@ -33,7 +37,7 @@ L.Control = L.Class.extend({
|
||||
|
||||
var container = this._container = this.onAdd(map),
|
||||
pos = this.getPosition(),
|
||||
corner = map._controlCorners[pos];
|
||||
corner = map._controlCorners[pos];
|
||||
|
||||
L.DomUtil.addClass(container, 'leaflet-control');
|
||||
|
||||
@ -48,7 +52,7 @@ L.Control = L.Class.extend({
|
||||
|
||||
removeFrom: function (map) {
|
||||
var pos = this.getPosition(),
|
||||
corner = map._controlCorners[pos];
|
||||
corner = map._controlCorners[pos];
|
||||
|
||||
corner.removeChild(this._container);
|
||||
this._map = null;
|
||||
|
4
src/copyright.js
Normal file
@ -0,0 +1,4 @@
|
||||
/*
|
||||
Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
|
||||
(c) 2010-2013, Vladimir Agafonkin, CloudMade
|
||||
*/
|
@ -1,32 +1,47 @@
|
||||
/*
|
||||
* L.Browser handles different browser and feature detections for internal Leaflet use.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var ua = navigator.userAgent.toLowerCase(),
|
||||
ie = !!window.ActiveXObject,
|
||||
ie6 = ie && !window.XMLHttpRequest,
|
||||
webkit = ua.indexOf("webkit") !== -1,
|
||||
gecko = ua.indexOf("gecko") !== -1,
|
||||
//Terrible browser detection to work around a safari / iOS / android browser bug. See TileLayer._addTile and debug/hacks/jitter.html
|
||||
chrome = ua.indexOf("chrome") !== -1,
|
||||
opera = window.opera,
|
||||
android = ua.indexOf("android") !== -1,
|
||||
android23 = ua.search("android [23]") !== -1,
|
||||
mobile = typeof orientation !== undefined + '' ? true : false,
|
||||
doc = document.documentElement,
|
||||
ie3d = ie && ('transition' in doc.style),
|
||||
webkit3d = webkit && ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
|
||||
gecko3d = gecko && ('MozPerspective' in doc.style),
|
||||
opera3d = opera && ('OTransition' in doc.style);
|
||||
|
||||
var ie = !!window.ActiveXObject,
|
||||
ie6 = ie && !window.XMLHttpRequest,
|
||||
ie7 = ie && !document.querySelector,
|
||||
|
||||
// terrible browser detection to work around Safari / iOS / Android browser bugs
|
||||
ua = navigator.userAgent.toLowerCase(),
|
||||
webkit = ua.indexOf('webkit') !== -1,
|
||||
chrome = ua.indexOf('chrome') !== -1,
|
||||
android = ua.indexOf('android') !== -1,
|
||||
android23 = ua.search('android [23]') !== -1,
|
||||
|
||||
mobile = typeof orientation !== undefined + '',
|
||||
msTouch = window.navigator && window.navigator.msPointerEnabled &&
|
||||
window.navigator.msMaxTouchPoints,
|
||||
retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) ||
|
||||
('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') &&
|
||||
window.matchMedia('(min-resolution:144dpi)').matches),
|
||||
|
||||
doc = document.documentElement,
|
||||
ie3d = ie && ('transition' in doc.style),
|
||||
webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
|
||||
gecko3d = 'MozPerspective' in doc.style,
|
||||
opera3d = 'OTransition' in doc.style,
|
||||
any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d);
|
||||
|
||||
|
||||
var touch = !window.L_NO_TOUCH && (function () {
|
||||
|
||||
var startName = 'ontouchstart';
|
||||
|
||||
// WebKit, etc
|
||||
if (startName in doc) {
|
||||
// IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.MsTouch) or WebKit, etc.
|
||||
if (msTouch || (startName in doc)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Firefox/Gecko
|
||||
var div = document.createElement('div'),
|
||||
supported = false;
|
||||
supported = false;
|
||||
|
||||
if (!div.setAttribute) {
|
||||
return false;
|
||||
@ -43,15 +58,13 @@
|
||||
return supported;
|
||||
}());
|
||||
|
||||
var retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches));
|
||||
|
||||
L.Browser = {
|
||||
ua: ua,
|
||||
ie: ie,
|
||||
ie6: ie6,
|
||||
ie7: ie7,
|
||||
webkit: webkit,
|
||||
gecko: gecko,
|
||||
opera: opera,
|
||||
|
||||
android: android,
|
||||
android23: android23,
|
||||
|
||||
@ -61,15 +74,17 @@
|
||||
webkit3d: webkit3d,
|
||||
gecko3d: gecko3d,
|
||||
opera3d: opera3d,
|
||||
any3d: !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d),
|
||||
any3d: any3d,
|
||||
|
||||
mobile: mobile,
|
||||
mobileWebkit: mobile && webkit,
|
||||
mobileWebkit3d: mobile && webkit3d,
|
||||
mobileOpera: mobile && opera,
|
||||
mobileOpera: mobile && window.opera,
|
||||
|
||||
touch: touch,
|
||||
msTouch: msTouch,
|
||||
|
||||
retina: retina
|
||||
};
|
||||
|
||||
}());
|
||||
|
@ -1,16 +1,24 @@
|
||||
/*
|
||||
* Class powers the OOP facilities of the library. Thanks to John Resig and Dean Edwards for inspiration!
|
||||
* L.Class powers the OOP facilities of the library.
|
||||
* Thanks to John Resig and Dean Edwards for inspiration!
|
||||
*/
|
||||
|
||||
L.Class = function () {};
|
||||
|
||||
L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
L.Class.extend = function (props) {
|
||||
|
||||
// extended class with the new prototype
|
||||
var NewClass = function () {
|
||||
|
||||
// call the constructor
|
||||
if (this.initialize) {
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
|
||||
// call all constructor hooks
|
||||
if (this._initHooks) {
|
||||
this.callInitHooks();
|
||||
}
|
||||
};
|
||||
|
||||
// instantiate class without calling constructor
|
||||
@ -31,7 +39,7 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// mix static properties into the class
|
||||
if (props.statics) {
|
||||
L.Util.extend(NewClass, props.statics);
|
||||
L.extend(NewClass, props.statics);
|
||||
delete props.statics;
|
||||
}
|
||||
|
||||
@ -43,11 +51,30 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// merge options
|
||||
if (props.options && proto.options) {
|
||||
props.options = L.Util.extend({}, proto.options, props.options);
|
||||
props.options = L.extend({}, proto.options, props.options);
|
||||
}
|
||||
|
||||
// mix given properties into the prototype
|
||||
L.Util.extend(proto, props);
|
||||
L.extend(proto, props);
|
||||
|
||||
proto._initHooks = [];
|
||||
|
||||
var parent = this;
|
||||
// add method for calling all hooks
|
||||
proto.callInitHooks = function () {
|
||||
|
||||
if (this._initHooksCalled) { return; }
|
||||
|
||||
if (parent.prototype.callInitHooks) {
|
||||
parent.prototype.callInitHooks.call(this);
|
||||
}
|
||||
|
||||
this._initHooksCalled = true;
|
||||
|
||||
for (var i = 0, len = proto._initHooks.length; i < len; i++) {
|
||||
proto._initHooks[i].call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return NewClass;
|
||||
};
|
||||
@ -55,9 +82,22 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
|
||||
|
||||
// method for adding properties to prototype
|
||||
L.Class.include = function (props) {
|
||||
L.Util.extend(this.prototype, props);
|
||||
L.extend(this.prototype, props);
|
||||
};
|
||||
|
||||
// merge new default options to the Class
|
||||
L.Class.mergeOptions = function (options) {
|
||||
L.Util.extend(this.prototype.options, options);
|
||||
};
|
||||
L.extend(this.prototype.options, options);
|
||||
};
|
||||
|
||||
// add a constructor hook
|
||||
L.Class.addInitHook = function (fn) { // (Function) || (String, args...)
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
var init = typeof fn === 'function' ? fn : function () {
|
||||
this[fn].apply(this, args);
|
||||
};
|
||||
|
||||
this.prototype._initHooks = this.prototype._initHooks || [];
|
||||
this.prototype._initHooks.push(init);
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* L.Mixin.Events adds custom events functionality to Leaflet classes
|
||||
* L.Mixin.Events is used to add custom events functionality to Leaflet classes.
|
||||
*/
|
||||
|
||||
var key = '_leaflet_events';
|
||||
@ -7,11 +7,11 @@ var key = '_leaflet_events';
|
||||
L.Mixin = {};
|
||||
|
||||
L.Mixin.Events = {
|
||||
|
||||
|
||||
addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object])
|
||||
var events = this[key] = this[key] || {},
|
||||
type, i, len;
|
||||
|
||||
|
||||
// Types can be a map of types/handlers
|
||||
if (typeof types === 'object') {
|
||||
for (type in types) {
|
||||
@ -19,12 +19,12 @@ L.Mixin.Events = {
|
||||
this.addEventListener(type, types[type], fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
types = L.Util.splitWords(types);
|
||||
|
||||
|
||||
for (i = 0, len = types.length; i < len; i++) {
|
||||
events[types[i]] = events[types[i]] || [];
|
||||
events[types[i]].push({
|
||||
@ -32,7 +32,7 @@ L.Mixin.Events = {
|
||||
context: context || this
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -43,24 +43,24 @@ L.Mixin.Events = {
|
||||
removeEventListener: function (types, fn, context) { // (String[, Function, Object]) or (Object[, Object])
|
||||
var events = this[key],
|
||||
type, i, len, listeners, j;
|
||||
|
||||
|
||||
if (typeof types === 'object') {
|
||||
for (type in types) {
|
||||
if (types.hasOwnProperty(type)) {
|
||||
this.removeEventListener(type, types[type], fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
types = L.Util.splitWords(types);
|
||||
|
||||
for (i = 0, len = types.length; i < len; i++) {
|
||||
|
||||
if (this.hasEventListeners(types[i])) {
|
||||
listeners = events[types[i]];
|
||||
|
||||
|
||||
for (j = listeners.length - 1; j >= 0; j--) {
|
||||
if (
|
||||
(!fn || listeners[j].action === fn) &&
|
||||
@ -71,7 +71,7 @@ L.Mixin.Events = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -80,7 +80,7 @@ L.Mixin.Events = {
|
||||
return this;
|
||||
}
|
||||
|
||||
var event = L.Util.extend({
|
||||
var event = L.extend({
|
||||
type: type,
|
||||
target: this
|
||||
}, data);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* L.Handler classes are used internally to inject interaction features to classes like Map and Marker.
|
||||
*/
|
||||
L.Handler is a base class for handler classes that are used internally to inject
|
||||
interaction features like dragging to classes like Map and Marker.
|
||||
*/
|
||||
|
||||
L.Handler = L.Class.extend({
|
||||
initialize: function (map) {
|
||||
|
@ -1,13 +1,15 @@
|
||||
/*
|
||||
* L.Util is a namespace for various utility functions.
|
||||
* L.Util contains various utility functions used throughout Leaflet code.
|
||||
*/
|
||||
|
||||
L.Util = {
|
||||
extend: function (/*Object*/ dest) /*-> Object*/ { // merge src properties into dest
|
||||
var sources = Array.prototype.slice.call(arguments, 1);
|
||||
for (var j = 0, len = sources.length, src; j < len; j++) {
|
||||
extend: function (dest) { // (Object[, Object, ...]) ->
|
||||
var sources = Array.prototype.slice.call(arguments, 1),
|
||||
i, j, len, src;
|
||||
|
||||
for (j = 0, len = sources.length; j < len; j++) {
|
||||
src = sources[j] || {};
|
||||
for (var i in src) {
|
||||
for (i in src) {
|
||||
if (src.hasOwnProperty(i)) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
@ -71,18 +73,18 @@ L.Util = {
|
||||
},
|
||||
|
||||
setOptions: function (obj, options) {
|
||||
obj.options = L.Util.extend({}, obj.options, options);
|
||||
obj.options = L.extend({}, obj.options, options);
|
||||
return obj.options;
|
||||
},
|
||||
|
||||
getParamString: function (obj) {
|
||||
getParamString: function (obj, existingUrl) {
|
||||
var params = [];
|
||||
for (var i in obj) {
|
||||
if (obj.hasOwnProperty(i)) {
|
||||
params.push(i + '=' + obj[i]);
|
||||
}
|
||||
}
|
||||
return '?' + params.join('&');
|
||||
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
|
||||
},
|
||||
|
||||
template: function (str, data) {
|
||||
@ -95,14 +97,20 @@ L.Util = {
|
||||
});
|
||||
},
|
||||
|
||||
isArray: function (obj) {
|
||||
return (Object.prototype.toString.call(obj) === '[object Array]');
|
||||
},
|
||||
|
||||
emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
|
||||
};
|
||||
|
||||
(function () {
|
||||
|
||||
// inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
|
||||
function getPrefixed(name) {
|
||||
var i, fn,
|
||||
prefixes = ['webkit', 'moz', 'o', 'ms'];
|
||||
prefixes = ['webkit', 'moz', 'o', 'ms'];
|
||||
|
||||
for (i = 0; i < prefixes.length && !fn; i++) {
|
||||
fn = window[prefixes[i] + name];
|
||||
@ -111,23 +119,27 @@ L.Util = {
|
||||
return fn;
|
||||
}
|
||||
|
||||
var lastTime = 0;
|
||||
|
||||
function timeoutDefer(fn) {
|
||||
return window.setTimeout(fn, 1000 / 60);
|
||||
var time = +new Date(),
|
||||
timeToCall = Math.max(0, 16 - (time - lastTime));
|
||||
|
||||
lastTime = time + timeToCall;
|
||||
return window.setTimeout(fn, timeToCall);
|
||||
}
|
||||
|
||||
var requestFn = window.requestAnimationFrame ||
|
||||
getPrefixed('RequestAnimationFrame') || timeoutDefer;
|
||||
getPrefixed('RequestAnimationFrame') || timeoutDefer;
|
||||
|
||||
var cancelFn = window.cancelAnimationFrame ||
|
||||
getPrefixed('CancelAnimationFrame') ||
|
||||
getPrefixed('CancelRequestAnimationFrame') ||
|
||||
function (id) {
|
||||
window.clearTimeout(id);
|
||||
};
|
||||
getPrefixed('CancelAnimationFrame') ||
|
||||
getPrefixed('CancelRequestAnimationFrame') ||
|
||||
function (id) { window.clearTimeout(id); };
|
||||
|
||||
|
||||
L.Util.requestAnimFrame = function (fn, context, immediate, element) {
|
||||
fn = L.Util.bind(fn, context);
|
||||
fn = L.bind(fn, context);
|
||||
|
||||
if (immediate && requestFn === timeoutDefer) {
|
||||
fn();
|
||||
@ -143,3 +155,9 @@ L.Util = {
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
// shortcuts for most used utility functions
|
||||
L.extend = L.Util.extend;
|
||||
L.bind = L.Util.bind;
|
||||
L.stamp = L.Util.stamp;
|
||||
L.setOptions = L.Util.setOptions;
|
||||
|
@ -1,28 +1,69 @@
|
||||
L.Util.extend(L.DomEvent, {
|
||||
/*
|
||||
* Extends the event handling code with double tap support for mobile browsers.
|
||||
*/
|
||||
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_touchstart: L.Browser.msTouch ? 'MSPointerDown' : 'touchstart',
|
||||
_touchend: L.Browser.msTouch ? 'MSPointerUp' : 'touchend',
|
||||
|
||||
// inspired by Zepto touch code by Thomas Fuchs
|
||||
addDoubleTapListener: function (obj, handler, id) {
|
||||
var last,
|
||||
doubleTap = false,
|
||||
delay = 250,
|
||||
touch,
|
||||
pre = '_leaflet_',
|
||||
touchstart = 'touchstart',
|
||||
touchend = 'touchend';
|
||||
doubleTap = false,
|
||||
delay = 250,
|
||||
touch,
|
||||
pre = '_leaflet_',
|
||||
touchstart = this._touchstart,
|
||||
touchend = this._touchend,
|
||||
trackedTouches = [];
|
||||
|
||||
function onTouchStart(e) {
|
||||
if (e.touches.length !== 1) {
|
||||
var count;
|
||||
if (L.Browser.msTouch) {
|
||||
trackedTouches.push(e.pointerId);
|
||||
count = trackedTouches.length;
|
||||
} else {
|
||||
count = e.touches.length;
|
||||
}
|
||||
if (count > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var now = Date.now(),
|
||||
delta = now - (last || now);
|
||||
|
||||
touch = e.touches[0];
|
||||
touch = e.touches ? e.touches[0] : e;
|
||||
doubleTap = (delta > 0 && delta <= delay);
|
||||
last = now;
|
||||
}
|
||||
|
||||
function onTouchEnd(e) {
|
||||
/*jshint forin:false */
|
||||
if (L.Browser.msTouch) {
|
||||
var idx = trackedTouches.indexOf(e.pointerId);
|
||||
if (idx === -1) {
|
||||
return;
|
||||
}
|
||||
trackedTouches.splice(idx, 1);
|
||||
}
|
||||
|
||||
if (doubleTap) {
|
||||
if (L.Browser.msTouch) {
|
||||
//Work around .type being readonly with MSPointer* events
|
||||
var newTouch = { },
|
||||
prop;
|
||||
|
||||
for (var i in touch) {
|
||||
prop = touch[i];
|
||||
if (typeof prop === 'function') {
|
||||
newTouch[i] = prop.bind(touch);
|
||||
} else {
|
||||
newTouch[i] = prop;
|
||||
}
|
||||
}
|
||||
touch = newTouch;
|
||||
}
|
||||
touch.type = 'dblclick';
|
||||
handler(touch);
|
||||
last = null;
|
||||
@ -31,15 +72,25 @@ L.Util.extend(L.DomEvent, {
|
||||
obj[pre + touchstart + id] = onTouchStart;
|
||||
obj[pre + touchend + id] = onTouchEnd;
|
||||
|
||||
//On msTouch we need to listen on the document otherwise a drag starting on the map and moving off screen will not come through to us
|
||||
// so we will lose track of how many touches are ongoing
|
||||
var endElement = L.Browser.msTouch ? document.documentElement : obj;
|
||||
|
||||
obj.addEventListener(touchstart, onTouchStart, false);
|
||||
obj.addEventListener(touchend, onTouchEnd, false);
|
||||
endElement.addEventListener(touchend, onTouchEnd, false);
|
||||
if (L.Browser.msTouch) {
|
||||
endElement.addEventListener('MSPointerCancel', onTouchEnd, false);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
removeDoubleTapListener: function (obj, id) {
|
||||
var pre = '_leaflet_';
|
||||
obj.removeEventListener(obj, obj[pre + 'touchstart' + id], false);
|
||||
obj.removeEventListener(obj, obj[pre + 'touchend' + id], false);
|
||||
obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);
|
||||
(L.Browser.msTouch ? document.documentElement : obj).removeEventListener(this._touchend, obj[pre + this._touchend + id], false);
|
||||
if (L.Browser.msTouch) {
|
||||
document.documentElement.removeEventListener('MSPointerCancel', obj[pre + this._touchend + id], false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
146
src/dom/DomEvent.MsTouch.js
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
|
||||
*/
|
||||
|
||||
L.extend(L.DomEvent, {
|
||||
|
||||
_msTouches: [],
|
||||
_msDocumentListener: false,
|
||||
|
||||
// Provides a touch events wrapper for msPointer events.
|
||||
// Based on changes by veproza https://github.com/CloudMade/Leaflet/pull/1019
|
||||
|
||||
addMsTouchListener: function (obj, type, handler, id) {
|
||||
|
||||
switch (type) {
|
||||
case 'touchstart':
|
||||
return this.addMsTouchListenerStart(obj, type, handler, id);
|
||||
case 'touchend':
|
||||
return this.addMsTouchListenerEnd(obj, type, handler, id);
|
||||
case 'touchmove':
|
||||
return this.addMsTouchListenerMove(obj, type, handler, id);
|
||||
default:
|
||||
throw 'Unknown touch event type';
|
||||
}
|
||||
},
|
||||
|
||||
addMsTouchListenerStart: function (obj, type, handler, id) {
|
||||
var pre = '_leaflet_',
|
||||
touches = this._msTouches;
|
||||
|
||||
var cb = function (e) {
|
||||
|
||||
var alreadyInArray = false;
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
if (touches[i].pointerId === e.pointerId) {
|
||||
alreadyInArray = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyInArray) {
|
||||
touches.push(e);
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
e.changedTouches = [e];
|
||||
|
||||
handler(e);
|
||||
};
|
||||
|
||||
obj[pre + 'touchstart' + id] = cb;
|
||||
obj.addEventListener('MSPointerDown', cb, false);
|
||||
|
||||
// need to also listen for end events to keep the _msTouches list accurate
|
||||
// this needs to be on the body and never go away
|
||||
if (!this._msDocumentListener) {
|
||||
var internalCb = function (e) {
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
if (touches[i].pointerId === e.pointerId) {
|
||||
touches.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
//We listen on the documentElement as any drags that end by moving the touch off the screen get fired there
|
||||
document.documentElement.addEventListener('MSPointerUp', internalCb, false);
|
||||
document.documentElement.addEventListener('MSPointerCancel', internalCb, false);
|
||||
|
||||
this._msDocumentListener = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
addMsTouchListenerMove: function (obj, type, handler, id) {
|
||||
var pre = '_leaflet_',
|
||||
touches = this._msTouches;
|
||||
|
||||
function cb(e) {
|
||||
|
||||
// don't fire touch moves when mouse isn't down
|
||||
if (e.pointerType === e.MSPOINTER_TYPE_MOUSE && e.buttons === 0) { return; }
|
||||
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
if (touches[i].pointerId === e.pointerId) {
|
||||
touches[i] = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
e.changedTouches = [e];
|
||||
|
||||
handler(e);
|
||||
}
|
||||
|
||||
obj[pre + 'touchmove' + id] = cb;
|
||||
obj.addEventListener('MSPointerMove', cb, false);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
addMsTouchListenerEnd: function (obj, type, handler, id) {
|
||||
var pre = '_leaflet_',
|
||||
touches = this._msTouches;
|
||||
|
||||
var cb = function (e) {
|
||||
for (var i = 0; i < touches.length; i++) {
|
||||
if (touches[i].pointerId === e.pointerId) {
|
||||
touches.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
e.changedTouches = [e];
|
||||
|
||||
handler(e);
|
||||
};
|
||||
|
||||
obj[pre + 'touchend' + id] = cb;
|
||||
obj.addEventListener('MSPointerUp', cb, false);
|
||||
obj.addEventListener('MSPointerCancel', cb, false);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeMsTouchListener: function (obj, type, id) {
|
||||
var pre = '_leaflet_',
|
||||
cb = obj[pre + type + id];
|
||||
|
||||
switch (type) {
|
||||
case 'touchstart':
|
||||
obj.removeEventListener('MSPointerDown', cb, false);
|
||||
break;
|
||||
case 'touchmove':
|
||||
obj.removeEventListener('MSPointerMove', cb, false);
|
||||
break;
|
||||
case 'touchend':
|
||||
obj.removeEventListener('MSPointerUp', cb, false);
|
||||
obj.removeEventListener('MSPointerCancel', cb, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -3,12 +3,12 @@
|
||||
*/
|
||||
|
||||
L.DomEvent = {
|
||||
/* inpired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
/* inspired by John Resig, Dean Edwards and YUI addEvent implementations */
|
||||
addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler, originalHandler, newType;
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler, originalHandler, newType;
|
||||
|
||||
if (obj[key]) { return this; }
|
||||
|
||||
@ -16,11 +16,15 @@ L.DomEvent = {
|
||||
return fn.call(context || obj, e || L.DomEvent._getEvent());
|
||||
};
|
||||
|
||||
if (L.Browser.msTouch && type.indexOf('touch') === 0) {
|
||||
return this.addMsTouchListener(obj, type, handler, id);
|
||||
}
|
||||
if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
|
||||
return this.addDoubleTapListener(obj, handler, id);
|
||||
this.addDoubleTapListener(obj, handler, id);
|
||||
}
|
||||
|
||||
if ('addEventListener' in obj) {
|
||||
|
||||
} else if ('addEventListener' in obj) {
|
||||
|
||||
if (type === 'mousewheel') {
|
||||
obj.addEventListener('DOMMouseScroll', handler, false);
|
||||
obj.addEventListener(type, handler, false);
|
||||
@ -52,13 +56,15 @@ L.DomEvent = {
|
||||
|
||||
removeListener: function (obj, type, fn) { // (HTMLElement, String, Function)
|
||||
|
||||
var id = L.Util.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler = obj[key];
|
||||
var id = L.stamp(fn),
|
||||
key = '_leaflet_' + type + id,
|
||||
handler = obj[key];
|
||||
|
||||
if (!handler) { return; }
|
||||
|
||||
if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
|
||||
if (L.Browser.msTouch && type.indexOf('touch') === 0) {
|
||||
this.removeMsTouchListener(obj, type, id);
|
||||
} else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
|
||||
this.removeDoubleTapListener(obj, id);
|
||||
|
||||
} else if ('removeEventListener' in obj) {
|
||||
@ -94,9 +100,12 @@ L.DomEvent = {
|
||||
disableClickPropagation: function (el) {
|
||||
|
||||
var stop = L.DomEvent.stopPropagation;
|
||||
|
||||
|
||||
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
||||
L.DomEvent.addListener(el, L.Draggable.START[i], stop);
|
||||
}
|
||||
|
||||
return L.DomEvent
|
||||
.addListener(el, L.Draggable.START, stop)
|
||||
.addListener(el, 'click', stop)
|
||||
.addListener(el, 'dblclick', stop);
|
||||
},
|
||||
@ -118,10 +127,10 @@ L.DomEvent = {
|
||||
getMousePosition: function (e, container) {
|
||||
|
||||
var 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);
|
||||
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);
|
||||
|
||||
return (container ? pos._subtract(L.DomUtil.getViewportOffset(container)) : pos);
|
||||
},
|
||||
@ -156,9 +165,8 @@ L.DomEvent = {
|
||||
return (related !== el);
|
||||
},
|
||||
|
||||
/*jshint noarg:false */
|
||||
_getEvent: function () { // evil magic for IE
|
||||
|
||||
/*jshint noarg:false */
|
||||
var e = window.event;
|
||||
if (!e) {
|
||||
var caller = arguments.callee.caller;
|
||||
@ -172,8 +180,7 @@ L.DomEvent = {
|
||||
}
|
||||
return e;
|
||||
}
|
||||
/*jshint noarg:false */
|
||||
};
|
||||
|
||||
L.DomEvent.on = L.DomEvent.addListener;
|
||||
L.DomEvent.off = L.DomEvent.removeListener;
|
||||
L.DomEvent.off = L.DomEvent.removeListener;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* L.DomUtil contains various utility functions for working with DOM
|
||||
* L.DomUtil contains various utility functions for working with DOM.
|
||||
*/
|
||||
|
||||
L.DomUtil = {
|
||||
@ -8,62 +8,95 @@ L.DomUtil = {
|
||||
},
|
||||
|
||||
getStyle: function (el, style) {
|
||||
|
||||
var value = el.style[style];
|
||||
|
||||
if (!value && el.currentStyle) {
|
||||
value = el.currentStyle[style];
|
||||
}
|
||||
if (!value || value === 'auto') {
|
||||
|
||||
if ((!value || value === 'auto') && document.defaultView) {
|
||||
var css = document.defaultView.getComputedStyle(el, null);
|
||||
value = css ? css[style] : null;
|
||||
}
|
||||
return (value === 'auto' ? null : value);
|
||||
|
||||
return value === 'auto' ? null : value;
|
||||
},
|
||||
|
||||
getViewportOffset: function (element) {
|
||||
|
||||
var top = 0,
|
||||
left = 0,
|
||||
el = element,
|
||||
docBody = document.body;
|
||||
left = 0,
|
||||
el = element,
|
||||
docBody = document.body,
|
||||
pos,
|
||||
ie7 = L.Browser.ie7;
|
||||
|
||||
do {
|
||||
top += el.offsetTop || 0;
|
||||
top += el.offsetTop || 0;
|
||||
left += el.offsetLeft || 0;
|
||||
|
||||
if (el.offsetParent === docBody &&
|
||||
L.DomUtil.getStyle(el, 'position') === 'absolute') {
|
||||
break;
|
||||
}
|
||||
if (L.DomUtil.getStyle(el, 'position') === 'fixed') {
|
||||
top += docBody.scrollTop || 0;
|
||||
//add borders
|
||||
top += parseInt(L.DomUtil.getStyle(el, "borderTopWidth"), 10) || 0;
|
||||
left += parseInt(L.DomUtil.getStyle(el, "borderLeftWidth"), 10) || 0;
|
||||
|
||||
pos = L.DomUtil.getStyle(el, 'position');
|
||||
|
||||
if (el.offsetParent === docBody && pos === 'absolute') { break; }
|
||||
|
||||
if (pos === 'fixed') {
|
||||
top += docBody.scrollTop || 0;
|
||||
left += docBody.scrollLeft || 0;
|
||||
break;
|
||||
}
|
||||
|
||||
el = el.offsetParent;
|
||||
|
||||
} while (el);
|
||||
|
||||
el = element;
|
||||
|
||||
do {
|
||||
if (el === docBody) {
|
||||
break;
|
||||
}
|
||||
if (el === docBody) { break; }
|
||||
|
||||
top -= el.scrollTop || 0;
|
||||
top -= el.scrollTop || 0;
|
||||
left -= el.scrollLeft || 0;
|
||||
|
||||
// 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 += el.scrollWidth - el.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(el, 'overflow-y') !== 'hidden' &&
|
||||
L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
|
||||
left += 17;
|
||||
}
|
||||
}
|
||||
|
||||
el = el.parentNode;
|
||||
} while (el);
|
||||
|
||||
return new L.Point(left, top);
|
||||
},
|
||||
|
||||
documentIsLtr: function () {
|
||||
if (!L.DomUtil._docIsLtrCached) {
|
||||
L.DomUtil._docIsLtrCached = true;
|
||||
L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === "ltr";
|
||||
}
|
||||
return L.DomUtil._docIsLtr;
|
||||
},
|
||||
|
||||
create: function (tagName, className, container) {
|
||||
|
||||
var el = document.createElement(tagName);
|
||||
el.className = className;
|
||||
|
||||
if (container) {
|
||||
container.appendChild(el);
|
||||
}
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
@ -72,19 +105,21 @@ L.DomUtil = {
|
||||
document.selection.empty();
|
||||
}
|
||||
if (!this._onselectstart) {
|
||||
this._onselectstart = document.onselectstart;
|
||||
this._onselectstart = document.onselectstart || null;
|
||||
document.onselectstart = L.Util.falseFn;
|
||||
}
|
||||
},
|
||||
|
||||
enableTextSelection: function () {
|
||||
document.onselectstart = this._onselectstart;
|
||||
this._onselectstart = null;
|
||||
if (document.onselectstart === L.Util.falseFn) {
|
||||
document.onselectstart = this._onselectstart;
|
||||
this._onselectstart = null;
|
||||
}
|
||||
},
|
||||
|
||||
hasClass: function (el, name) {
|
||||
return (el.className.length > 0) &&
|
||||
new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className);
|
||||
new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className);
|
||||
},
|
||||
|
||||
addClass: function (el, name) {
|
||||
@ -94,15 +129,15 @@ L.DomUtil = {
|
||||
},
|
||||
|
||||
removeClass: function (el, name) {
|
||||
|
||||
function replaceFn(w, match) {
|
||||
if (match === name) {
|
||||
return '';
|
||||
}
|
||||
if (match === name) { return ''; }
|
||||
return w;
|
||||
}
|
||||
|
||||
el.className = el.className
|
||||
.replace(/(\S+)\s*/g, replaceFn)
|
||||
.replace(/(^\s+|\s+$)/, '');
|
||||
.replace(/(\S+)\s*/g, replaceFn)
|
||||
.replace(/(^\s+|\s+$)/, '');
|
||||
},
|
||||
|
||||
setOpacity: function (el, value) {
|
||||
@ -110,10 +145,10 @@ L.DomUtil = {
|
||||
if ('opacity' in el.style) {
|
||||
el.style.opacity = value;
|
||||
|
||||
} else if (L.Browser.ie) {
|
||||
} else if ('filter' in el.style) {
|
||||
|
||||
var filter = false,
|
||||
filterName = 'DXImageTransform.Microsoft.Alpha';
|
||||
filterName = 'DXImageTransform.Microsoft.Alpha';
|
||||
|
||||
// filters collection throws an error if we try to retrieve a filter that doesn't exist
|
||||
try { filter = el.filters.item(filterName); } catch (e) {}
|
||||
@ -130,6 +165,7 @@ L.DomUtil = {
|
||||
},
|
||||
|
||||
testProp: function (props) {
|
||||
|
||||
var style = document.documentElement.style;
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
@ -141,27 +177,29 @@ L.DomUtil = {
|
||||
},
|
||||
|
||||
getTranslateString: function (point) {
|
||||
// On webkit browsers (Chrome/Safari/MobileSafari/Android) using translate3d instead of translate
|
||||
// on WebKit browsers (Chrome/Safari/iOS Safari/Android) using translate3d instead of translate
|
||||
// makes animation smoother as it ensures HW accel is used. Firefox 13 doesn't care
|
||||
// (same speed either way), Opera 12 doesn't support translate3d
|
||||
|
||||
var is3d = L.Browser.webkit3d,
|
||||
open = 'translate' + (is3d ? '3d' : '') + '(',
|
||||
close = (is3d ? ',0' : '') + ')';
|
||||
open = 'translate' + (is3d ? '3d' : '') + '(',
|
||||
close = (is3d ? ',0' : '') + ')';
|
||||
|
||||
return open + point.x + 'px,' + point.y + 'px' + close;
|
||||
},
|
||||
|
||||
getScaleString: function (scale, origin) {
|
||||
var preTranslateStr = L.DomUtil.getTranslateString(origin),
|
||||
scaleStr = ' scale(' + scale + ') ',
|
||||
postTranslateStr = L.DomUtil.getTranslateString(origin.multiplyBy(-1));
|
||||
|
||||
return preTranslateStr + scaleStr + postTranslateStr;
|
||||
var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))),
|
||||
scaleStr = ' scale(' + scale + ') ';
|
||||
|
||||
return preTranslateStr + scaleStr;
|
||||
},
|
||||
|
||||
setPosition: function (el, point, disable3D) {
|
||||
setPosition: function (el, point, disable3D) { // (HTMLElement, Point[, Boolean])
|
||||
|
||||
el._leaflet_pos = point;
|
||||
|
||||
if (!disable3D && L.Browser.any3d) {
|
||||
el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point);
|
||||
|
||||
@ -176,11 +214,24 @@ L.DomUtil = {
|
||||
},
|
||||
|
||||
getPosition: function (el) {
|
||||
// this method is only used for elements previously positioned using setPosition,
|
||||
// so it's safe to cache the position for performance
|
||||
return el._leaflet_pos;
|
||||
}
|
||||
};
|
||||
|
||||
L.Util.extend(L.DomUtil, {
|
||||
TRANSITION: L.DomUtil.testProp(['transition', 'webkitTransition', 'OTransition', 'MozTransition', 'msTransition']),
|
||||
TRANSFORM: L.DomUtil.testProp(['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform'])
|
||||
});
|
||||
|
||||
// prefix style property names
|
||||
|
||||
L.DomUtil.TRANSFORM = L.DomUtil.testProp(
|
||||
['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
|
||||
|
||||
// webkitTransition comes first because some browser versions that drop vendor prefix don't do
|
||||
// the same for the transitionend event, in particular the Android 4.1 stock browser
|
||||
|
||||
L.DomUtil.TRANSITION = L.DomUtil.testProp(
|
||||
['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);
|
||||
|
||||
L.DomUtil.TRANSITION_END =
|
||||
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
|
||||
L.DomUtil.TRANSITION + 'End' : 'transitionend';
|
||||
|
@ -6,73 +6,98 @@ L.Draggable = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
statics: {
|
||||
START: L.Browser.touch ? 'touchstart' : 'mousedown',
|
||||
END: L.Browser.touch ? 'touchend' : 'mouseup',
|
||||
MOVE: L.Browser.touch ? 'touchmove' : 'mousemove',
|
||||
START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],
|
||||
END: {
|
||||
mousedown: 'mouseup',
|
||||
touchstart: 'touchend',
|
||||
MSPointerDown: 'touchend'
|
||||
},
|
||||
MOVE: {
|
||||
mousedown: 'mousemove',
|
||||
touchstart: 'touchmove',
|
||||
MSPointerDown: 'touchmove'
|
||||
},
|
||||
TAP_TOLERANCE: 15
|
||||
},
|
||||
|
||||
initialize: function (element, dragStartTarget) {
|
||||
initialize: function (element, dragStartTarget, longPress) {
|
||||
this._element = element;
|
||||
this._dragStartTarget = dragStartTarget || element;
|
||||
this._longPress = longPress && !L.Browser.msTouch;
|
||||
},
|
||||
|
||||
enable: function () {
|
||||
if (this._enabled) {
|
||||
return;
|
||||
if (this._enabled) { return; }
|
||||
|
||||
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
||||
L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
|
||||
}
|
||||
L.DomEvent.on(this._dragStartTarget, L.Draggable.START, this._onDown, this);
|
||||
this._enabled = true;
|
||||
},
|
||||
|
||||
disable: function () {
|
||||
if (!this._enabled) {
|
||||
return;
|
||||
if (!this._enabled) { return; }
|
||||
|
||||
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
||||
L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
|
||||
}
|
||||
L.DomEvent.off(this._dragStartTarget, L.Draggable.START, this._onDown);
|
||||
this._enabled = false;
|
||||
this._moved = false;
|
||||
},
|
||||
|
||||
_onDown: function (e) {
|
||||
if ((!L.Browser.touch && e.shiftKey) || ((e.which !== 1) && (e.button !== 1) && !e.touches)) {
|
||||
return;
|
||||
}
|
||||
if ((!L.Browser.touch && e.shiftKey) ||
|
||||
((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }
|
||||
|
||||
L.DomEvent.preventDefault(e);
|
||||
L.DomEvent.stopPropagation(e);
|
||||
|
||||
if (L.Draggable._disabled) { return; }
|
||||
|
||||
this._simulateClick = true;
|
||||
|
||||
if (e.touches && e.touches.length > 1) {
|
||||
this._simulateClick = false;
|
||||
clearTimeout(this._longPressTimeout);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),
|
||||
el = first.target;
|
||||
|
||||
L.DomEvent.preventDefault(e);
|
||||
el = first.target;
|
||||
|
||||
if (L.Browser.touch && el.tagName.toLowerCase() === 'a') {
|
||||
L.DomUtil.addClass(el, 'leaflet-active');
|
||||
}
|
||||
|
||||
this._moved = false;
|
||||
if (this._moving) {
|
||||
return;
|
||||
if (this._moving) { return; }
|
||||
|
||||
this._startPoint = new L.Point(first.clientX, first.clientY);
|
||||
this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
|
||||
|
||||
//Touch contextmenu event emulation
|
||||
if (e.touches && e.touches.length === 1 && L.Browser.touch && this._longPress) {
|
||||
this._longPressTimeout = setTimeout(L.bind(function () {
|
||||
var dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
||||
|
||||
if (dist < L.Draggable.TAP_TOLERANCE) {
|
||||
this._simulateClick = false;
|
||||
this._onUp();
|
||||
this._simulateEvent('contextmenu', first);
|
||||
}
|
||||
}, this), 1000);
|
||||
}
|
||||
|
||||
this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
|
||||
this._startPoint = new L.Point(first.clientX, first.clientY);
|
||||
|
||||
L.DomEvent.on(document, L.Draggable.MOVE, this._onMove, this);
|
||||
L.DomEvent.on(document, L.Draggable.END, this._onUp, this);
|
||||
L.DomEvent.on(document, L.Draggable.MOVE[e.type], this._onMove, this);
|
||||
L.DomEvent.on(document, L.Draggable.END[e.type], this._onUp, this);
|
||||
},
|
||||
|
||||
_onMove: function (e) {
|
||||
if (e.touches && e.touches.length > 1) { return; }
|
||||
|
||||
var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),
|
||||
newPoint = new L.Point(first.clientX, first.clientY),
|
||||
diffVec = newPoint.subtract(this._startPoint);
|
||||
newPoint = new L.Point(first.clientX, first.clientY),
|
||||
diffVec = newPoint.subtract(this._startPoint);
|
||||
|
||||
if (!diffVec.x && !diffVec.y) { return; }
|
||||
|
||||
@ -82,6 +107,8 @@ L.Draggable = L.Class.extend({
|
||||
this.fire('dragstart');
|
||||
this._moved = true;
|
||||
|
||||
this._startPos = L.DomUtil.getPosition(this._element).subtract(diffVec);
|
||||
|
||||
if (!L.Browser.touch) {
|
||||
L.DomUtil.disableTextSelection();
|
||||
this._setMovingCursor();
|
||||
@ -102,17 +129,19 @@ L.Draggable = L.Class.extend({
|
||||
},
|
||||
|
||||
_onUp: function (e) {
|
||||
var simulateClickTouch;
|
||||
clearTimeout(this._longPressTimeout);
|
||||
if (this._simulateClick && e.changedTouches) {
|
||||
var first = e.changedTouches[0],
|
||||
el = first.target,
|
||||
dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
||||
el = first.target,
|
||||
dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
||||
|
||||
if (el.tagName.toLowerCase() === 'a') {
|
||||
L.DomUtil.removeClass(el, 'leaflet-active');
|
||||
}
|
||||
|
||||
if (dist < L.Draggable.TAP_TOLERANCE) {
|
||||
this._simulateEvent('click', first);
|
||||
simulateClickTouch = first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +150,12 @@ L.Draggable = L.Class.extend({
|
||||
this._restoreCursor();
|
||||
}
|
||||
|
||||
L.DomEvent.off(document, L.Draggable.MOVE, this._onMove);
|
||||
L.DomEvent.off(document, L.Draggable.END, this._onUp);
|
||||
for (var i in L.Draggable.MOVE) {
|
||||
if (L.Draggable.MOVE.hasOwnProperty(i)) {
|
||||
L.DomEvent.off(document, L.Draggable.MOVE[i], this._onMove);
|
||||
L.DomEvent.off(document, L.Draggable.END[i], this._onUp);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._moved) {
|
||||
// ensure drag is not fired after dragend
|
||||
@ -131,6 +164,11 @@ L.Draggable = L.Class.extend({
|
||||
this.fire('dragend');
|
||||
}
|
||||
this._moving = false;
|
||||
|
||||
if (simulateClickTouch) {
|
||||
this._moved = false;
|
||||
this._simulateEvent('click', simulateClickTouch);
|
||||
}
|
||||
},
|
||||
|
||||
_setMovingCursor: function () {
|
||||
@ -145,10 +183,10 @@ L.Draggable = L.Class.extend({
|
||||
var simulatedEvent = document.createEvent('MouseEvents');
|
||||
|
||||
simulatedEvent.initMouseEvent(
|
||||
type, true, true, window, 1,
|
||||
e.screenX, e.screenY,
|
||||
e.clientX, e.clientY,
|
||||
false, false, false, false, 0, null);
|
||||
type, true, true, window, 1,
|
||||
e.screenX, e.screenY,
|
||||
e.clientX, e.clientY,
|
||||
false, false, false, false, 0, null);
|
||||
|
||||
e.target.dispatchEvent(simulatedEvent);
|
||||
}
|
||||
|
67
src/dom/PosAnimation.Timer.js
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* L.PosAnimation fallback implementation that powers Leaflet pan animations
|
||||
* in browsers that don't support CSS3 Transitions.
|
||||
*/
|
||||
|
||||
L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({
|
||||
|
||||
run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
|
||||
this.stop();
|
||||
|
||||
this._el = el;
|
||||
this._inProgress = true;
|
||||
this._duration = duration || 0.25;
|
||||
this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
|
||||
|
||||
this._startPos = L.DomUtil.getPosition(el);
|
||||
this._offset = newPos.subtract(this._startPos);
|
||||
this._startTime = +new Date();
|
||||
|
||||
this.fire('start');
|
||||
|
||||
this._animate();
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
if (!this._inProgress) { return; }
|
||||
|
||||
this._step();
|
||||
this._complete();
|
||||
},
|
||||
|
||||
_animate: function () {
|
||||
// animation loop
|
||||
this._animId = L.Util.requestAnimFrame(this._animate, this);
|
||||
this._step();
|
||||
},
|
||||
|
||||
_step: function () {
|
||||
var elapsed = (+new Date()) - this._startTime,
|
||||
duration = this._duration * 1000;
|
||||
|
||||
if (elapsed < duration) {
|
||||
this._runFrame(this._easeOut(elapsed / duration));
|
||||
} else {
|
||||
this._runFrame(1);
|
||||
this._complete();
|
||||
}
|
||||
},
|
||||
|
||||
_runFrame: function (progress) {
|
||||
var pos = this._startPos.add(this._offset.multiplyBy(progress));
|
||||
L.DomUtil.setPosition(this._el, pos);
|
||||
|
||||
this.fire('step');
|
||||
},
|
||||
|
||||
_complete: function () {
|
||||
L.Util.cancelAnimFrame(this._animId);
|
||||
|
||||
this._inProgress = false;
|
||||
this.fire('end');
|
||||
},
|
||||
|
||||
_easeOut: function (t) {
|
||||
return 1 - Math.pow(1 - t, this._easeOutPower);
|
||||
}
|
||||
});
|
75
src/dom/PosAnimation.js
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* L.PosAnimation is used by Leaflet internally for pan animations.
|
||||
*/
|
||||
|
||||
L.PosAnimation = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
|
||||
this.stop();
|
||||
|
||||
this._el = el;
|
||||
this._inProgress = true;
|
||||
|
||||
this.fire('start');
|
||||
|
||||
el.style[L.DomUtil.TRANSITION] = 'all ' + (duration || 0.25) +
|
||||
's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)';
|
||||
|
||||
L.DomEvent.on(el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
|
||||
L.DomUtil.setPosition(el, newPos);
|
||||
|
||||
// toggle reflow, Chrome flickers for some reason if you don't do this
|
||||
L.Util.falseFn(el.offsetWidth);
|
||||
|
||||
// there's no native way to track value updates of transitioned properties, so we imitate this
|
||||
this._stepTimer = setInterval(L.bind(this.fire, this, 'step'), 50);
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
if (!this._inProgress) { return; }
|
||||
|
||||
// if we just removed the transition property, the element would jump to its final position,
|
||||
// so we need to make it stay at the current position
|
||||
|
||||
L.DomUtil.setPosition(this._el, this._getPos());
|
||||
this._onTransitionEnd();
|
||||
L.Util.falseFn(this._el.offsetWidth); // force reflow in case we are about to start a new animation
|
||||
},
|
||||
|
||||
// you can't easily get intermediate values of properties animated with CSS3 Transitions,
|
||||
// we need to parse computed style (in case of transform it returns matrix string)
|
||||
|
||||
_transformRe: /(-?[\d\.]+), (-?[\d\.]+)\)/,
|
||||
|
||||
_getPos: function () {
|
||||
var left, top, matches,
|
||||
el = this._el,
|
||||
style = window.getComputedStyle(el);
|
||||
|
||||
if (L.Browser.any3d) {
|
||||
matches = style[L.DomUtil.TRANSFORM].match(this._transformRe);
|
||||
left = parseFloat(matches[1]);
|
||||
top = parseFloat(matches[2]);
|
||||
} else {
|
||||
left = parseFloat(style.left);
|
||||
top = parseFloat(style.top);
|
||||
}
|
||||
|
||||
return new L.Point(left, top, true);
|
||||
},
|
||||
|
||||
_onTransitionEnd: function () {
|
||||
L.DomEvent.off(this._el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
|
||||
|
||||
if (!this._inProgress) { return; }
|
||||
this._inProgress = false;
|
||||
|
||||
this._el.style[L.DomUtil.TRANSITION] = '';
|
||||
|
||||
clearInterval(this._stepTimer);
|
||||
|
||||
this.fire('step').fire('end');
|
||||
}
|
||||
|
||||
});
|
@ -1,122 +0,0 @@
|
||||
/*
|
||||
* L.Transition native implementation that powers Leaflet animation
|
||||
* in browsers that support CSS3 Transitions
|
||||
*/
|
||||
|
||||
L.Transition = L.Transition.extend({
|
||||
statics: (function () {
|
||||
var transition = L.DomUtil.TRANSITION,
|
||||
transitionEnd = (transition === 'webkitTransition' || transition === 'OTransition' ?
|
||||
transition + 'End' : 'transitionend');
|
||||
|
||||
return {
|
||||
NATIVE: !!transition,
|
||||
|
||||
TRANSITION: transition,
|
||||
PROPERTY: transition + 'Property',
|
||||
DURATION: transition + 'Duration',
|
||||
EASING: transition + 'TimingFunction',
|
||||
END: transitionEnd,
|
||||
|
||||
// transition-property value to use with each particular custom property
|
||||
CUSTOM_PROPS_PROPERTIES: {
|
||||
position: L.Browser.any3d ? L.DomUtil.TRANSFORM : 'top, left'
|
||||
}
|
||||
};
|
||||
}()),
|
||||
|
||||
options: {
|
||||
fakeStepInterval: 100
|
||||
},
|
||||
|
||||
initialize: function (/*HTMLElement*/ el, /*Object*/ options) {
|
||||
this._el = el;
|
||||
L.Util.setOptions(this, options);
|
||||
|
||||
L.DomEvent.on(el, L.Transition.END, this._onTransitionEnd, this);
|
||||
this._onFakeStep = L.Util.bind(this._onFakeStep, this);
|
||||
},
|
||||
|
||||
run: function (/*Object*/ props) {
|
||||
var prop,
|
||||
propsList = [],
|
||||
customProp = L.Transition.CUSTOM_PROPS_PROPERTIES;
|
||||
|
||||
for (prop in props) {
|
||||
if (props.hasOwnProperty(prop)) {
|
||||
prop = customProp[prop] ? customProp[prop] : prop;
|
||||
prop = this._dasherize(prop);
|
||||
propsList.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
this._el.style[L.Transition.DURATION] = this.options.duration + 's';
|
||||
this._el.style[L.Transition.EASING] = this.options.easing;
|
||||
this._el.style[L.Transition.PROPERTY] = propsList.join(', ');
|
||||
|
||||
for (prop in props) {
|
||||
if (props.hasOwnProperty(prop)) {
|
||||
this._setProperty(prop, props[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
this._inProgress = true;
|
||||
|
||||
this.fire('start');
|
||||
|
||||
if (L.Browser.mobileWebkit) {
|
||||
// Set up a slightly delayed call to a backup event if webkitTransitionEnd doesn't fire properly
|
||||
this.backupEventFire = setTimeout(L.Util.bind(this._onBackupFireEnd, this), this.options.duration * 1.2 * 1000);
|
||||
}
|
||||
|
||||
if (L.Transition.NATIVE) {
|
||||
clearInterval(this._timer);
|
||||
this._timer = setInterval(this._onFakeStep, this.options.fakeStepInterval);
|
||||
} else {
|
||||
this._onTransitionEnd();
|
||||
}
|
||||
},
|
||||
|
||||
_dasherize: (function () {
|
||||
var re = /([A-Z])/g;
|
||||
|
||||
function replaceFn(w) {
|
||||
return '-' + w.toLowerCase();
|
||||
}
|
||||
|
||||
return function (str) {
|
||||
return str.replace(re, replaceFn);
|
||||
};
|
||||
}()),
|
||||
|
||||
_onFakeStep: function () {
|
||||
this.fire('step');
|
||||
},
|
||||
|
||||
_onTransitionEnd: function (e) {
|
||||
if (this._inProgress) {
|
||||
this._inProgress = false;
|
||||
clearInterval(this._timer);
|
||||
|
||||
this._el.style[L.Transition.TRANSITION] = '';
|
||||
|
||||
// Clear the delayed call to the backup event, we have recieved some form of webkitTransitionEnd
|
||||
clearTimeout(this.backupEventFire);
|
||||
delete this.backupEventFire;
|
||||
|
||||
this.fire('step');
|
||||
|
||||
if (e && e.type) {
|
||||
this.fire('end');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onBackupFireEnd: function () {
|
||||
// Create and fire a transitionEnd event on the element.
|
||||
|
||||
var event = document.createEvent("Event");
|
||||
event.initEvent(L.Transition.END, true, false);
|
||||
this._el.dispatchEvent(event);
|
||||
}
|
||||
});
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* L.Transition fallback implementation that powers Leaflet animation
|
||||
* in browsers that don't support CSS3 Transitions
|
||||
*/
|
||||
|
||||
L.Transition = L.Transition.NATIVE ? L.Transition : L.Transition.extend({
|
||||
statics: {
|
||||
getTime: Date.now || function () {
|
||||
return +new Date();
|
||||
},
|
||||
|
||||
TIMER: true,
|
||||
|
||||
EASINGS: {
|
||||
'linear': function (t) { return t; },
|
||||
'ease-out': function (t) { return t * (2 - t); }
|
||||
},
|
||||
|
||||
CUSTOM_PROPS_GETTERS: {
|
||||
position: L.DomUtil.getPosition
|
||||
},
|
||||
|
||||
//used to get units from strings like "10.5px" (->px)
|
||||
UNIT_RE: /^[\d\.]+(\D*)$/
|
||||
},
|
||||
|
||||
options: {
|
||||
fps: 50
|
||||
},
|
||||
|
||||
initialize: function (el, options) {
|
||||
this._el = el;
|
||||
L.Util.extend(this.options, options);
|
||||
|
||||
this._easing = L.Transition.EASINGS[this.options.easing] || L.Transition.EASINGS['ease-out'];
|
||||
|
||||
this._step = L.Util.bind(this._step, this);
|
||||
this._interval = Math.round(1000 / this.options.fps);
|
||||
},
|
||||
|
||||
run: function (props) {
|
||||
this._props = {};
|
||||
|
||||
var getters = L.Transition.CUSTOM_PROPS_GETTERS,
|
||||
re = L.Transition.UNIT_RE;
|
||||
|
||||
this.fire('start');
|
||||
|
||||
for (var prop in props) {
|
||||
if (props.hasOwnProperty(prop)) {
|
||||
var p = {};
|
||||
if (prop in getters) {
|
||||
p.from = getters[prop](this._el);
|
||||
} else {
|
||||
var matches = this._el.style[prop].match(re);
|
||||
p.from = parseFloat(matches[0]);
|
||||
p.unit = matches[1];
|
||||
}
|
||||
p.to = props[prop];
|
||||
this._props[prop] = p;
|
||||
}
|
||||
}
|
||||
|
||||
clearInterval(this._timer);
|
||||
this._timer = setInterval(this._step, this._interval);
|
||||
this._startTime = L.Transition.getTime();
|
||||
},
|
||||
|
||||
_step: function () {
|
||||
var time = L.Transition.getTime(),
|
||||
elapsed = time - this._startTime,
|
||||
duration = this.options.duration * 1000;
|
||||
|
||||
if (elapsed < duration) {
|
||||
this._runFrame(this._easing(elapsed / duration));
|
||||
} else {
|
||||
this._runFrame(1);
|
||||
this._complete();
|
||||
}
|
||||
},
|
||||
|
||||
_runFrame: function (percentComplete) {
|
||||
var setters = L.Transition.CUSTOM_PROPS_SETTERS,
|
||||
prop, p, value;
|
||||
|
||||
for (prop in this._props) {
|
||||
if (this._props.hasOwnProperty(prop)) {
|
||||
p = this._props[prop];
|
||||
if (prop in setters) {
|
||||
value = p.to.subtract(p.from).multiplyBy(percentComplete).add(p.from);
|
||||
setters[prop](this._el, value);
|
||||
} else {
|
||||
this._el.style[prop] =
|
||||
((p.to - p.from) * percentComplete + p.from) + p.unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fire('step');
|
||||
},
|
||||
|
||||
_complete: function () {
|
||||
clearInterval(this._timer);
|
||||
this.fire('end');
|
||||
}
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
L.Transition = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
statics: {
|
||||
CUSTOM_PROPS_SETTERS: {
|
||||
position: L.DomUtil.setPosition
|
||||
//TODO transform custom attr
|
||||
},
|
||||
|
||||
implemented: function () {
|
||||
return L.Transition.NATIVE || L.Transition.TIMER;
|
||||
}
|
||||
},
|
||||
|
||||
options: {
|
||||
easing: 'ease',
|
||||
duration: 0.5
|
||||
},
|
||||
|
||||
_setProperty: function (prop, value) {
|
||||
var setters = L.Transition.CUSTOM_PROPS_SETTERS;
|
||||
if (prop in setters) {
|
||||
setters[prop](this._el, value);
|
||||
} else {
|
||||
this._el.style[prop] = value;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,25 +1,20 @@
|
||||
/*
|
||||
CM.LatLng represents a geographical point with latitude and longtitude coordinates.
|
||||
*/
|
||||
* L.LatLng represents a geographical point with latitude and longitude coordinates.
|
||||
*/
|
||||
|
||||
L.LatLng = function (rawLat, rawLng, noWrap) { // (Number, Number[, Boolean])
|
||||
L.LatLng = function (rawLat, rawLng) { // (Number, Number)
|
||||
var lat = parseFloat(rawLat),
|
||||
lng = parseFloat(rawLng);
|
||||
lng = parseFloat(rawLng);
|
||||
|
||||
if (isNaN(lat) || isNaN(lng)) {
|
||||
throw new Error('Invalid LatLng object: (' + rawLat + ', ' + rawLng + ')');
|
||||
}
|
||||
|
||||
if (noWrap !== true) {
|
||||
lat = Math.max(Math.min(lat, 90), -90); // clamp latitude into -90..90
|
||||
lng = (lng + 180) % 360 + ((lng < -180 || lng === 180) ? 180 : -180); // wrap longtitude into -180..180
|
||||
}
|
||||
|
||||
this.lat = lat;
|
||||
this.lng = lng;
|
||||
};
|
||||
|
||||
L.Util.extend(L.LatLng, {
|
||||
L.extend(L.LatLng, {
|
||||
DEG_TO_RAD: Math.PI / 180,
|
||||
RAD_TO_DEG: 180 / Math.PI,
|
||||
MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
|
||||
@ -31,45 +26,60 @@ L.LatLng.prototype = {
|
||||
|
||||
obj = L.latLng(obj);
|
||||
|
||||
var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng));
|
||||
var margin = Math.max(
|
||||
Math.abs(this.lat - obj.lat),
|
||||
Math.abs(this.lng - obj.lng));
|
||||
|
||||
return margin <= L.LatLng.MAX_MARGIN;
|
||||
},
|
||||
|
||||
toString: function () { // -> String
|
||||
toString: function (precision) { // (Number) -> String
|
||||
return 'LatLng(' +
|
||||
L.Util.formatNum(this.lat) + ', ' +
|
||||
L.Util.formatNum(this.lng) + ')';
|
||||
L.Util.formatNum(this.lat, precision) + ', ' +
|
||||
L.Util.formatNum(this.lng, precision) + ')';
|
||||
},
|
||||
|
||||
// Haversine distance formula, see http://en.wikipedia.org/wiki/Haversine_formula
|
||||
// TODO move to projection code, LatLng shouldn't know about Earth
|
||||
distanceTo: function (other) { // (LatLng) -> Number
|
||||
other = L.latLng(other);
|
||||
|
||||
var R = 6378137, // earth radius in meters
|
||||
d2r = L.LatLng.DEG_TO_RAD,
|
||||
dLat = (other.lat - this.lat) * d2r,
|
||||
dLon = (other.lng - this.lng) * d2r,
|
||||
lat1 = this.lat * d2r,
|
||||
lat2 = other.lat * d2r,
|
||||
sin1 = Math.sin(dLat / 2),
|
||||
sin2 = Math.sin(dLon / 2);
|
||||
d2r = L.LatLng.DEG_TO_RAD,
|
||||
dLat = (other.lat - this.lat) * d2r,
|
||||
dLon = (other.lng - this.lng) * d2r,
|
||||
lat1 = this.lat * d2r,
|
||||
lat2 = other.lat * d2r,
|
||||
sin1 = Math.sin(dLat / 2),
|
||||
sin2 = Math.sin(dLon / 2);
|
||||
|
||||
var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2);
|
||||
|
||||
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
},
|
||||
|
||||
wrap: function (a, b) { // (Number, Number) -> LatLng
|
||||
var lng = this.lng;
|
||||
|
||||
a = a || -180;
|
||||
b = b || 180;
|
||||
|
||||
lng = (lng + b) % (b - a) + (lng < a || lng === b ? b : a);
|
||||
|
||||
return new L.LatLng(this.lat, lng);
|
||||
}
|
||||
};
|
||||
|
||||
L.latLng = function (a, b, c) { // (LatLng) or ([Number, Number]) or (Number, Number, Boolean)
|
||||
L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Number)
|
||||
if (a instanceof L.LatLng) {
|
||||
return a;
|
||||
}
|
||||
if (a instanceof Array) {
|
||||
if (L.Util.isArray(a)) {
|
||||
return new L.LatLng(a[0], a[1]);
|
||||
}
|
||||
if (isNaN(a)) {
|
||||
return a;
|
||||
}
|
||||
return new L.LatLng(a, b, c);
|
||||
return new L.LatLng(a, b);
|
||||
};
|
||||
|
||||
|
||||
|
@ -2,20 +2,20 @@
|
||||
* L.LatLngBounds represents a rectangular area on the map in geographical coordinates.
|
||||
*/
|
||||
|
||||
L.LatLngBounds = L.Class.extend({
|
||||
initialize: function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])
|
||||
if (!southWest) { return; }
|
||||
L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])
|
||||
if (!southWest) { return; }
|
||||
|
||||
var latlngs = northEast ? [southWest, northEast] : southWest;
|
||||
var latlngs = northEast ? [southWest, northEast] : southWest;
|
||||
|
||||
for (var i = 0, len = latlngs.length; i < len; i++) {
|
||||
this.extend(latlngs[i]);
|
||||
}
|
||||
},
|
||||
for (var i = 0, len = latlngs.length; i < len; i++) {
|
||||
this.extend(latlngs[i]);
|
||||
}
|
||||
};
|
||||
|
||||
L.LatLngBounds.prototype = {
|
||||
// extend the bounds to contain the given point or bounds
|
||||
extend: function (obj) { // (LatLng) or (LatLngBounds)
|
||||
if (typeof obj[0] === 'number' || obj instanceof L.LatLng) {
|
||||
if (typeof obj[0] === 'number' || typeof obj[0] === 'string' || obj instanceof L.LatLng) {
|
||||
obj = L.latLng(obj);
|
||||
} else {
|
||||
obj = L.latLngBounds(obj);
|
||||
@ -23,8 +23,8 @@ L.LatLngBounds = L.Class.extend({
|
||||
|
||||
if (obj instanceof L.LatLng) {
|
||||
if (!this._southWest && !this._northEast) {
|
||||
this._southWest = new L.LatLng(obj.lat, obj.lng, true);
|
||||
this._northEast = new L.LatLng(obj.lat, obj.lng, true);
|
||||
this._southWest = new L.LatLng(obj.lat, obj.lng);
|
||||
this._northEast = new L.LatLng(obj.lat, obj.lng);
|
||||
} else {
|
||||
this._southWest.lat = Math.min(obj.lat, this._southWest.lat);
|
||||
this._southWest.lng = Math.min(obj.lng, this._southWest.lng);
|
||||
@ -34,7 +34,7 @@ L.LatLngBounds = L.Class.extend({
|
||||
}
|
||||
} else if (obj instanceof L.LatLngBounds) {
|
||||
this.extend(obj._southWest);
|
||||
this.extend(obj._northEast);
|
||||
this.extend(obj._northEast);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
@ -42,19 +42,19 @@ L.LatLngBounds = L.Class.extend({
|
||||
// extend the bounds by a percentage
|
||||
pad: function (bufferRatio) { // (Number) -> LatLngBounds
|
||||
var sw = this._southWest,
|
||||
ne = this._northEast,
|
||||
heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
|
||||
widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
|
||||
ne = this._northEast,
|
||||
heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
|
||||
widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
|
||||
|
||||
return new L.LatLngBounds(
|
||||
new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
|
||||
new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
|
||||
new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
|
||||
new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
|
||||
},
|
||||
|
||||
getCenter: function () { // -> LatLng
|
||||
return new L.LatLng(
|
||||
(this._southWest.lat + this._northEast.lat) / 2,
|
||||
(this._southWest.lng + this._northEast.lng) / 2);
|
||||
(this._southWest.lat + this._northEast.lat) / 2,
|
||||
(this._southWest.lng + this._northEast.lng) / 2);
|
||||
},
|
||||
|
||||
getSouthWest: function () {
|
||||
@ -66,11 +66,11 @@ L.LatLngBounds = L.Class.extend({
|
||||
},
|
||||
|
||||
getNorthWest: function () {
|
||||
return new L.LatLng(this._northEast.lat, this._southWest.lng, true);
|
||||
return new L.LatLng(this._northEast.lat, this._southWest.lng);
|
||||
},
|
||||
|
||||
getSouthEast: function () {
|
||||
return new L.LatLng(this._southWest.lat, this._northEast.lng, true);
|
||||
return new L.LatLng(this._southWest.lat, this._northEast.lng);
|
||||
},
|
||||
|
||||
contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
|
||||
@ -81,8 +81,8 @@ L.LatLngBounds = L.Class.extend({
|
||||
}
|
||||
|
||||
var sw = this._southWest,
|
||||
ne = this._northEast,
|
||||
sw2, ne2;
|
||||
ne = this._northEast,
|
||||
sw2, ne2;
|
||||
|
||||
if (obj instanceof L.LatLngBounds) {
|
||||
sw2 = obj.getSouthWest();
|
||||
@ -92,26 +92,27 @@ L.LatLngBounds = L.Class.extend({
|
||||
}
|
||||
|
||||
return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
|
||||
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
|
||||
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
|
||||
},
|
||||
|
||||
intersects: function (bounds) { // (LatLngBounds)
|
||||
bounds = L.latLngBounds(bounds);
|
||||
|
||||
var sw = this._southWest,
|
||||
ne = this._northEast,
|
||||
sw2 = bounds.getSouthWest(),
|
||||
ne2 = bounds.getNorthEast();
|
||||
ne = this._northEast,
|
||||
sw2 = bounds.getSouthWest(),
|
||||
ne2 = bounds.getNorthEast(),
|
||||
|
||||
var latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
|
||||
lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
|
||||
latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
|
||||
lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
|
||||
|
||||
return latIntersects && lngIntersects;
|
||||
},
|
||||
|
||||
toBBoxString: function () {
|
||||
var sw = this._southWest,
|
||||
ne = this._northEast;
|
||||
ne = this._northEast;
|
||||
|
||||
return [sw.lng, sw.lat, ne.lng, ne.lat].join(',');
|
||||
},
|
||||
|
||||
@ -122,8 +123,12 @@ L.LatLngBounds = L.Class.extend({
|
||||
|
||||
return this._southWest.equals(bounds.getSouthWest()) &&
|
||||
this._northEast.equals(bounds.getNorthEast());
|
||||
},
|
||||
|
||||
isValid: function () {
|
||||
return !!(this._southWest && this._northEast);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//TODO International date line?
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
|
||||
L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3395 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3395',
|
||||
|
||||
projection: L.Projection.Mercator,
|
||||
|
||||
transformation: (function () {
|
||||
var m = L.Projection.Mercator,
|
||||
r = m.R_MAJOR,
|
||||
r2 = m.R_MINOR;
|
||||
r = m.R_MAJOR,
|
||||
r2 = m.R_MINOR;
|
||||
|
||||
return new L.Transformation(0.5 / (Math.PI * r), 0.5, -0.5 / (Math.PI * r2), 0.5);
|
||||
}())
|
||||
|
@ -1,5 +1,9 @@
|
||||
/*
|
||||
* L.CRS.EPSG3857 (Spherical Mercator) is the most common CRS for web mapping
|
||||
* and is used by Leaflet by default.
|
||||
*/
|
||||
|
||||
L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG3857 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:3857',
|
||||
|
||||
projection: L.Projection.SphericalMercator,
|
||||
@ -7,11 +11,11 @@ L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
||||
|
||||
project: function (latlng) { // (LatLng) -> Point
|
||||
var projectedPoint = this.projection.project(latlng),
|
||||
earthRadius = 6378137;
|
||||
earthRadius = 6378137;
|
||||
return projectedPoint.multiplyBy(earthRadius);
|
||||
}
|
||||
});
|
||||
|
||||
L.CRS.EPSG900913 = L.Util.extend({}, L.CRS.EPSG3857, {
|
||||
L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {
|
||||
code: 'EPSG:900913'
|
||||
});
|
||||
|
@ -1,5 +1,8 @@
|
||||
/*
|
||||
* L.CRS.EPSG4326 is a CRS popular among advanced GIS specialists.
|
||||
*/
|
||||
|
||||
L.CRS.EPSG4326 = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.EPSG4326 = L.extend({}, L.CRS, {
|
||||
code: 'EPSG:4326',
|
||||
|
||||
projection: L.Projection.LonLat,
|
||||
|
@ -1,5 +1,12 @@
|
||||
/*
|
||||
* A simple CRS that can be used for flat non-Earth maps like panoramas or game maps.
|
||||
*/
|
||||
|
||||
L.CRS.Simple = L.Util.extend({}, L.CRS, {
|
||||
L.CRS.Simple = L.extend({}, L.CRS, {
|
||||
projection: L.Projection.LonLat,
|
||||
transformation: new L.Transformation(1, 0, 1, 0)
|
||||
transformation: new L.Transformation(1, 0, -1, 0),
|
||||
|
||||
scale: function (zoom) {
|
||||
return Math.pow(2, zoom);
|
||||
}
|
||||
});
|
||||
|
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* L.CRS is a base object for all defined CRS (Coordinate Reference Systems) in Leaflet.
|
||||
*/
|
||||
|
||||
L.CRS = {
|
||||
latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point
|
||||
|
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* Simple equirectangular (Plate Carree) projection, used by CRS like EPSG:4326 and Simple.
|
||||
*/
|
||||
|
||||
L.Projection.LonLat = {
|
||||
project: function (latlng) {
|
||||
@ -5,6 +8,6 @@ L.Projection.LonLat = {
|
||||
},
|
||||
|
||||
unproject: function (point) {
|
||||
return new L.LatLng(point.y, point.x, true);
|
||||
return new L.LatLng(point.y, point.x);
|
||||
}
|
||||
};
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Mercator projection that takes into account that the Earth is not a perfect sphere.
|
||||
* Less popular than spherical mercator; used by projections like EPSG:3395.
|
||||
*/
|
||||
|
||||
L.Projection.Mercator = {
|
||||
MAX_LATITUDE: 85.0840591556,
|
||||
@ -7,15 +11,15 @@ L.Projection.Mercator = {
|
||||
|
||||
project: function (latlng) { // (LatLng) -> Point
|
||||
var d = L.LatLng.DEG_TO_RAD,
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
r = this.R_MAJOR,
|
||||
r2 = this.R_MINOR,
|
||||
x = latlng.lng * d * r,
|
||||
y = lat * d,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1.0 - tmp * tmp),
|
||||
con = eccent * Math.sin(y);
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
r = this.R_MAJOR,
|
||||
r2 = this.R_MINOR,
|
||||
x = latlng.lng * d * r,
|
||||
y = lat * d,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1.0 - tmp * tmp),
|
||||
con = eccent * Math.sin(y);
|
||||
|
||||
con = Math.pow((1 - con) / (1 + con), eccent * 0.5);
|
||||
|
||||
@ -27,25 +31,26 @@ L.Projection.Mercator = {
|
||||
|
||||
unproject: function (point) { // (Point, Boolean) -> LatLng
|
||||
var d = L.LatLng.RAD_TO_DEG,
|
||||
r = this.R_MAJOR,
|
||||
r2 = this.R_MINOR,
|
||||
lng = point.x * d / r,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1 - (tmp * tmp)),
|
||||
ts = Math.exp(- point.y / r2),
|
||||
phi = (Math.PI / 2) - 2 * Math.atan(ts),
|
||||
numIter = 15,
|
||||
tol = 1e-7,
|
||||
i = numIter,
|
||||
dphi = 0.1,
|
||||
con;
|
||||
r = this.R_MAJOR,
|
||||
r2 = this.R_MINOR,
|
||||
lng = point.x * d / r,
|
||||
tmp = r2 / r,
|
||||
eccent = Math.sqrt(1 - (tmp * tmp)),
|
||||
ts = Math.exp(- point.y / r2),
|
||||
phi = (Math.PI / 2) - 2 * Math.atan(ts),
|
||||
numIter = 15,
|
||||
tol = 1e-7,
|
||||
i = numIter,
|
||||
dphi = 0.1,
|
||||
con;
|
||||
|
||||
while ((Math.abs(dphi) > tol) && (--i > 0)) {
|
||||
con = eccent * Math.sin(phi);
|
||||
dphi = (Math.PI / 2) - 2 * Math.atan(ts * Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi;
|
||||
dphi = (Math.PI / 2) - 2 * Math.atan(ts *
|
||||
Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi;
|
||||
phi += dphi;
|
||||
}
|
||||
|
||||
return new L.LatLng(phi * d, lng, true);
|
||||
return new L.LatLng(phi * d, lng);
|
||||
}
|
||||
};
|
||||
|
@ -1,13 +1,17 @@
|
||||
/*
|
||||
* Spherical Mercator is the most popular map projection, used by EPSG:3857 CRS used by default.
|
||||
*/
|
||||
|
||||
L.Projection.SphericalMercator = {
|
||||
MAX_LATITUDE: 85.0511287798,
|
||||
|
||||
project: function (latlng) { // (LatLng) -> Point
|
||||
var d = L.LatLng.DEG_TO_RAD,
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
x = latlng.lng * d,
|
||||
y = lat * d;
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
x = latlng.lng * d,
|
||||
y = lat * d;
|
||||
|
||||
y = Math.log(Math.tan((Math.PI / 4) + (y / 2)));
|
||||
|
||||
return new L.Point(x, y);
|
||||
@ -15,10 +19,9 @@ L.Projection.SphericalMercator = {
|
||||
|
||||
unproject: function (point) { // (Point, Boolean) -> LatLng
|
||||
var d = L.LatLng.RAD_TO_DEG,
|
||||
lng = point.x * d,
|
||||
lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
|
||||
lng = point.x * d,
|
||||
lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
|
||||
|
||||
// TODO refactor LatLng wrapping
|
||||
return new L.LatLng(lat, lng, true);
|
||||
return new L.LatLng(lat, lng);
|
||||
}
|
||||
};
|
||||
|
@ -2,18 +2,17 @@
|
||||
* L.Bounds represents a rectangular area on the screen in pixel coordinates.
|
||||
*/
|
||||
|
||||
L.Bounds = L.Class.extend({
|
||||
L.Bounds = function (a, b) { //(Point, Point) or Point[]
|
||||
if (!a) { return; }
|
||||
|
||||
initialize: function (a, b) { //(Point, Point) or Point[]
|
||||
if (!a) { return; }
|
||||
var points = b ? [a, b] : a;
|
||||
|
||||
var points = b ? [a, b] : a;
|
||||
|
||||
for (var i = 0, len = points.length; i < len; i++) {
|
||||
this.extend(points[i]);
|
||||
}
|
||||
},
|
||||
for (var i = 0, len = points.length; i < len; i++) {
|
||||
this.extend(points[i]);
|
||||
}
|
||||
};
|
||||
|
||||
L.Bounds.prototype = {
|
||||
// extend the bounds to contain the given point
|
||||
extend: function (point) { // (Point)
|
||||
point = L.point(point);
|
||||
@ -32,8 +31,8 @@ L.Bounds = L.Class.extend({
|
||||
|
||||
getCenter: function (round) { // (Boolean) -> Point
|
||||
return new L.Point(
|
||||
(this.min.x + this.max.x) / 2,
|
||||
(this.min.y + this.max.y) / 2, round);
|
||||
(this.min.x + this.max.x) / 2,
|
||||
(this.min.y + this.max.y) / 2, round);
|
||||
},
|
||||
|
||||
getBottomLeft: function () { // -> Point
|
||||
@ -44,6 +43,10 @@ L.Bounds = L.Class.extend({
|
||||
return new L.Point(this.max.x, this.min.y);
|
||||
},
|
||||
|
||||
getSize: function () {
|
||||
return this.max.subtract(this.min);
|
||||
},
|
||||
|
||||
contains: function (obj) { // (Bounds) or (Point) -> Boolean
|
||||
var min, max;
|
||||
|
||||
@ -61,26 +64,28 @@ L.Bounds = L.Class.extend({
|
||||
}
|
||||
|
||||
return (min.x >= this.min.x) &&
|
||||
(max.x <= this.max.x) &&
|
||||
(min.y >= this.min.y) &&
|
||||
(max.y <= this.max.y);
|
||||
(max.x <= this.max.x) &&
|
||||
(min.y >= this.min.y) &&
|
||||
(max.y <= this.max.y);
|
||||
},
|
||||
|
||||
intersects: function (bounds) { // (Bounds) -> Boolean
|
||||
bounds = L.bounds(bounds);
|
||||
|
||||
var min = this.min,
|
||||
max = this.max,
|
||||
min2 = bounds.min,
|
||||
max2 = bounds.max;
|
||||
|
||||
var xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
|
||||
yIntersects = (max2.y >= min.y) && (min2.y <= max.y);
|
||||
max = this.max,
|
||||
min2 = bounds.min,
|
||||
max2 = bounds.max,
|
||||
xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
|
||||
yIntersects = (max2.y >= min.y) && (min2.y <= max.y);
|
||||
|
||||
return xIntersects && yIntersects;
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
isValid: function () {
|
||||
return !!(this.min && this.max);
|
||||
}
|
||||
};
|
||||
|
||||
L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[])
|
||||
if (!a || a instanceof L.Bounds) {
|
||||
|
@ -3,6 +3,8 @@
|
||||
* and polylines (clipping, simplification, distances, etc.)
|
||||
*/
|
||||
|
||||
/*jshint bitwise:false */ // allow bitwise oprations for this file
|
||||
|
||||
L.LineUtil = {
|
||||
|
||||
// Simplify polyline with vertex reduction and Douglas-Peucker simplification.
|
||||
@ -37,15 +39,15 @@ L.LineUtil = {
|
||||
_simplifyDP: function (points, sqTolerance) {
|
||||
|
||||
var len = points.length,
|
||||
ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,
|
||||
markers = new ArrayConstructor(len);
|
||||
ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,
|
||||
markers = new ArrayConstructor(len);
|
||||
|
||||
markers[0] = markers[len - 1] = 1;
|
||||
|
||||
this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1);
|
||||
|
||||
var i,
|
||||
newPoints = [];
|
||||
newPoints = [];
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (markers[i]) {
|
||||
@ -59,7 +61,7 @@ L.LineUtil = {
|
||||
_simplifyDPStep: function (points, markers, sqTolerance, first, last) {
|
||||
|
||||
var maxSqDist = 0,
|
||||
index, i, sqDist;
|
||||
index, i, sqDist;
|
||||
|
||||
for (i = first + 1; i <= last - 1; i++) {
|
||||
sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true);
|
||||
@ -94,17 +96,14 @@ L.LineUtil = {
|
||||
return reducedPoints;
|
||||
},
|
||||
|
||||
/*jshint bitwise:false */ // temporarily allow bitwise oprations
|
||||
|
||||
// Cohen-Sutherland line clipping algorithm.
|
||||
// Used to avoid rendering parts of a polyline that are not currently visible.
|
||||
|
||||
clipSegment: function (a, b, bounds, useLastCode) {
|
||||
var min = bounds.min,
|
||||
max = bounds.max;
|
||||
|
||||
var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
|
||||
codeB = this._getBitCode(b, bounds);
|
||||
codeB = this._getBitCode(b, bounds),
|
||||
|
||||
codeOut, p, newCode;
|
||||
|
||||
// save 2nd code to avoid calculating it on the next segment
|
||||
this._lastCode = codeB;
|
||||
@ -118,9 +117,9 @@ L.LineUtil = {
|
||||
return false;
|
||||
// other cases
|
||||
} else {
|
||||
var codeOut = codeA || codeB,
|
||||
p = this._getEdgeIntersection(a, b, codeOut, bounds),
|
||||
newCode = this._getBitCode(p, bounds);
|
||||
codeOut = codeA || codeB,
|
||||
p = this._getEdgeIntersection(a, b, codeOut, bounds),
|
||||
newCode = this._getBitCode(p, bounds);
|
||||
|
||||
if (codeOut === codeA) {
|
||||
a = p;
|
||||
@ -135,9 +134,9 @@ L.LineUtil = {
|
||||
|
||||
_getEdgeIntersection: function (a, b, code, bounds) {
|
||||
var dx = b.x - a.x,
|
||||
dy = b.y - a.y,
|
||||
min = bounds.min,
|
||||
max = bounds.max;
|
||||
dy = b.y - a.y,
|
||||
min = bounds.min,
|
||||
max = bounds.max;
|
||||
|
||||
if (code & 8) { // top
|
||||
return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y);
|
||||
@ -167,23 +166,21 @@ L.LineUtil = {
|
||||
return code;
|
||||
},
|
||||
|
||||
/*jshint bitwise:true */
|
||||
|
||||
// square distance (to avoid unnecessary Math.sqrt calls)
|
||||
_sqDist: function (p1, p2) {
|
||||
var dx = p2.x - p1.x,
|
||||
dy = p2.y - p1.y;
|
||||
dy = p2.y - p1.y;
|
||||
return dx * dx + dy * dy;
|
||||
},
|
||||
|
||||
// return closest point on segment or distance to that point
|
||||
_sqClosestPointOnSegment: function (p, p1, p2, sqDist) {
|
||||
var x = p1.x,
|
||||
y = p1.y,
|
||||
dx = p2.x - x,
|
||||
dy = p2.y - y,
|
||||
dot = dx * dx + dy * dy,
|
||||
t;
|
||||
y = p1.y,
|
||||
dx = p2.x - x,
|
||||
dy = p2.y - y,
|
||||
dot = dx * dx + dy * dy,
|
||||
t;
|
||||
|
||||
if (dot > 0) {
|
||||
t = ((p.x - x) * dx + (p.y - y) * dy) / dot;
|
||||
|
@ -8,10 +8,17 @@ L.Point = function (/*Number*/ x, /*Number*/ y, /*Boolean*/ round) {
|
||||
};
|
||||
|
||||
L.Point.prototype = {
|
||||
|
||||
clone: function () {
|
||||
return new L.Point(this.x, this.y);
|
||||
},
|
||||
|
||||
// non-destructive, returns a new point
|
||||
add: function (point) {
|
||||
return this.clone()._add(L.point(point));
|
||||
},
|
||||
|
||||
// destructive, used directly for performance in situations where it's safe to modify existing point
|
||||
_add: function (point) {
|
||||
this.x += point.x;
|
||||
this.y += point.y;
|
||||
@ -22,35 +29,36 @@ L.Point.prototype = {
|
||||
return this.clone()._subtract(L.point(point));
|
||||
},
|
||||
|
||||
// destructive subtract (faster)
|
||||
_subtract: function (point) {
|
||||
this.x -= point.x;
|
||||
this.y -= point.y;
|
||||
return this;
|
||||
},
|
||||
|
||||
divideBy: function (num, round) {
|
||||
return new L.Point(this.x / num, this.y / num, round);
|
||||
divideBy: function (num) {
|
||||
return this.clone()._divideBy(num);
|
||||
},
|
||||
|
||||
multiplyBy: function (num, round) {
|
||||
return new L.Point(this.x * num, this.y * num, round);
|
||||
_divideBy: function (num) {
|
||||
this.x /= num;
|
||||
this.y /= num;
|
||||
return this;
|
||||
},
|
||||
|
||||
distanceTo: function (point) {
|
||||
point = L.point(point);
|
||||
multiplyBy: function (num) {
|
||||
return this.clone()._multiplyBy(num);
|
||||
},
|
||||
|
||||
var x = point.x - this.x,
|
||||
y = point.y - this.y;
|
||||
|
||||
return Math.sqrt(x * x + y * y);
|
||||
_multiplyBy: function (num) {
|
||||
this.x *= num;
|
||||
this.y *= num;
|
||||
return this;
|
||||
},
|
||||
|
||||
round: function () {
|
||||
return this.clone()._round();
|
||||
},
|
||||
|
||||
// destructive round
|
||||
_round: function () {
|
||||
this.x = Math.round(this.x);
|
||||
this.y = Math.round(this.y);
|
||||
@ -67,14 +75,24 @@ L.Point.prototype = {
|
||||
return this;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
return new L.Point(this.x, this.y);
|
||||
distanceTo: function (point) {
|
||||
point = L.point(point);
|
||||
|
||||
var x = point.x - this.x,
|
||||
y = point.y - this.y;
|
||||
|
||||
return Math.sqrt(x * x + y * y);
|
||||
},
|
||||
|
||||
equals: function (point) {
|
||||
return point.x === this.x &&
|
||||
point.y === this.y;
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return 'Point(' +
|
||||
L.Util.formatNum(this.x) + ', ' +
|
||||
L.Util.formatNum(this.y) + ')';
|
||||
L.Util.formatNum(this.x) + ', ' +
|
||||
L.Util.formatNum(this.y) + ')';
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,7 +100,7 @@ L.point = function (x, y, round) {
|
||||
if (x instanceof L.Point) {
|
||||
return x;
|
||||
}
|
||||
if (x instanceof Array) {
|
||||
if (L.Util.isArray(x)) {
|
||||
return new L.Point(x[0], x[1]);
|
||||
}
|
||||
if (isNaN(x)) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* L.PolyUtil contains utilify functions for polygons (clipping, etc.).
|
||||
* L.PolyUtil contains utility functions for polygons (clipping, etc.).
|
||||
*/
|
||||
|
||||
/*jshint bitwise:false */ // allow bitwise oprations here
|
||||
/*jshint bitwise:false */ // allow bitwise operations here
|
||||
|
||||
L.PolyUtil = {};
|
||||
|
||||
@ -11,14 +11,12 @@ L.PolyUtil = {};
|
||||
* Used to avoid rendering parts of a polygon that are not currently visible.
|
||||
*/
|
||||
L.PolyUtil.clipPolygon = function (points, bounds) {
|
||||
var min = bounds.min,
|
||||
max = bounds.max,
|
||||
clippedPoints,
|
||||
edges = [1, 4, 2, 8],
|
||||
i, j, k,
|
||||
a, b,
|
||||
len, edge, p,
|
||||
lu = L.LineUtil;
|
||||
var clippedPoints,
|
||||
edges = [1, 4, 2, 8],
|
||||
i, j, k,
|
||||
a, b,
|
||||
len, edge, p,
|
||||
lu = L.LineUtil;
|
||||
|
||||
for (i = 0, len = points.length; i < len; i++) {
|
||||
points[i]._code = lu._getBitCode(points[i], bounds);
|
||||
@ -55,5 +53,3 @@ L.PolyUtil.clipPolygon = function (points, bounds) {
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
/*jshint bitwise:true */
|
||||
|
@ -2,30 +2,30 @@
|
||||
* L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.
|
||||
*/
|
||||
|
||||
L.Transformation = L.Class.extend({
|
||||
initialize: function (/*Number*/ a, /*Number*/ b, /*Number*/ c, /*Number*/ d) {
|
||||
this._a = a;
|
||||
this._b = b;
|
||||
this._c = c;
|
||||
this._d = d;
|
||||
},
|
||||
L.Transformation = function (a, b, c, d) {
|
||||
this._a = a;
|
||||
this._b = b;
|
||||
this._c = c;
|
||||
this._d = d;
|
||||
};
|
||||
|
||||
transform: function (point, scale) {
|
||||
L.Transformation.prototype = {
|
||||
transform: function (point, scale) { // (Point, Number) -> Point
|
||||
return this._transform(point.clone(), scale);
|
||||
},
|
||||
|
||||
// destructive transform (faster)
|
||||
_transform: function (/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
|
||||
_transform: function (point, scale) {
|
||||
scale = scale || 1;
|
||||
point.x = scale * (this._a * point.x + this._b);
|
||||
point.y = scale * (this._c * point.y + this._d);
|
||||
return point;
|
||||
},
|
||||
|
||||
untransform: function (/*Point*/ point, /*Number*/ scale) /*-> Point*/ {
|
||||
untransform: function (point, scale) {
|
||||
scale = scale || 1;
|
||||
return new L.Point(
|
||||
(point.x / scale - this._b) / this._a,
|
||||
(point.y / scale - this._d) / this._c);
|
||||
(point.x / scale - this._b) / this._a,
|
||||
(point.y / scale - this._d) / this._c);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
344
src/images/marker.svg
Normal file
@ -0,0 +1,344 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.2 r9819"
|
||||
sodipodi:docname="marker.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="linearGradient3889">
|
||||
<stop
|
||||
style="stop-color:#2e6c97;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3891" />
|
||||
<stop
|
||||
style="stop-color:#3883b7;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3893" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3788">
|
||||
<stop
|
||||
style="stop-color:#126fc6;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3790" />
|
||||
<stop
|
||||
style="stop-color:#4c9cd1;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3792" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3802"
|
||||
x1="351.1384"
|
||||
y1="551.58929"
|
||||
x2="351.1384"
|
||||
y2="512.92847"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-2.714785,0)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3850"
|
||||
x1="318.57059"
|
||||
y1="550.05206"
|
||||
x2="318.57059"
|
||||
y2="512.42175"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(94.732143,2.0535714)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3857"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-1,0,0,1,731.26786,2.0535714)"
|
||||
x1="318.57059"
|
||||
y1="550.05206"
|
||||
x2="318.57059"
|
||||
y2="512.42175" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3863"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(94.232143,2.0535714)"
|
||||
x1="318.57059"
|
||||
y1="550.05206"
|
||||
x2="318.57059"
|
||||
y2="512.42175" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3809"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-28.580028,-0.437314)"
|
||||
x1="445.30099"
|
||||
y1="541.28564"
|
||||
x2="445.30099"
|
||||
y2="503.72021" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3889"
|
||||
id="linearGradient3811"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(63,-0.4375)"
|
||||
x1="351.74811"
|
||||
y1="522.77393"
|
||||
x2="351.74811"
|
||||
y2="503.72079" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3807"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-28.580028,-0.437314)"
|
||||
x1="445.30099"
|
||||
y1="541.28564"
|
||||
x2="445.30099"
|
||||
y2="503.72021" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3889"
|
||||
id="linearGradient3810"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(63,-0.4375)"
|
||||
x1="351.74811"
|
||||
y1="522.77393"
|
||||
x2="351.74811"
|
||||
y2="503.72079" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3832"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-28.580028,-0.437314)"
|
||||
x1="445.30099"
|
||||
y1="541.28564"
|
||||
x2="445.30099"
|
||||
y2="503.72021" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3889"
|
||||
id="linearGradient3834"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(63,-0.4375)"
|
||||
x1="351.74811"
|
||||
y1="522.77393"
|
||||
x2="351.74811"
|
||||
y2="503.72079" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3844"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-28.846019,-0.2873201)"
|
||||
x1="445.30099"
|
||||
y1="541.28564"
|
||||
x2="445.30099"
|
||||
y2="503.72021" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3889"
|
||||
id="linearGradient3846"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(62.734009,-0.2875061)"
|
||||
x1="351.74811"
|
||||
y1="522.77393"
|
||||
x2="351.74811"
|
||||
y2="503.72079" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3788"
|
||||
id="linearGradient3797"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-28.846019,-0.2873201)"
|
||||
x1="445.30099"
|
||||
y1="541.28564"
|
||||
x2="445.30099"
|
||||
y2="503.72021" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3889"
|
||||
id="linearGradient3799"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(62.734009,-0.2875061)"
|
||||
x1="351.74811"
|
||||
y1="522.77393"
|
||||
x2="351.74811"
|
||||
y2="503.72079" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="16.000001"
|
||||
inkscape:cx="418.3474"
|
||||
inkscape:cy="537.41791"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1931"
|
||||
inkscape:window-height="1374"
|
||||
inkscape:window-x="705"
|
||||
inkscape:window-y="45"
|
||||
inkscape:window-maximized="0"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true">
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="367.51875,543.94189"
|
||||
id="guide3897" />
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3842" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<image
|
||||
y="502.23718"
|
||||
x="369.375"
|
||||
id="image2993"
|
||||
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAABHNCSVQICAgIfAhkiAAABgRJREFU WIWdl2uIXGcZx3/nOjNnZueWZlPUtgiKF2gRugWD9UswJfWD+MG7WC1SQcGP6ZdAkvpp28LK0ohQ qASE0tKgELtaGiwEi0EWKXFtbKRmQ2wys5nZy8ycM+f+Pn6YvZ2dmd2J7/DAYc77vL/3/1zel6PN PPcn7mF8CqhsPl8H3MXTJw500mae++N+7+vAj4ATwHHbstANDYAoSlBKNYGLwKuLp5+8PB5ydiTE AE4Cp+q1cqlYLFB08kOTkiTF9Xy6XY++H7wFPLt45smlEZCFUbt/rVYpH6/VylimSZgqvChFJDvR NnWmbAOAjU6PldaqDzy1eOarF3bP00WEXVYXkb/Wq5Xjh++rk4hO24vpBSlKgUjWwljR9mJW+zGV 8hSf+NiRQqnovDFzduGnGcieEL1Rr1U/Uz9UY91P6IUpSjjQUgUtL8bO5anVqwAvzZxdOLYD2dna yUp56litXmO9nxClMnJBU9eQMbDVfoJl2Rw5Mm0g8trMmTfrg3AhCFIX5FS5UqUfKqJEUIptyxs6 tYJFrWBha0J187mSNzPzlIJWL8ZxilSq1cOCnNxUAgjfK09VSoZh4oZpJu51x8I2NNZWV7m5vIze X+Pm8g1WVlYIg4C6YwHZXHlhSqVSBeEnj57+g2Fulsy3nWKJMFGoXRVUyZuEQUiz8RFPf/nTPPX4 FynlB4u+vXSbFxaWCPNlapUqbS/e9vMiRcGyyOdy9SAIjuqClAQ5att5Ov00I93QNDqdDU597RF+ 9pXPbgMAnnj44/zmmcfxe+ukiSJn6EOhyxUcBDmhI/KgZVqGEkh3JdEydMIoYrqg+PqjD+3tJUSE B+pFvvHYQ3S7HfKWkSmCfqwwTRtEPq+LSF3T9aFKyZk6QeDz8AO1kQAApRRfeLCG73tDFZcoAU1H RComIpEoNUia2llIpYBAnKixABEhiFM0TRvy10RDDTrY10Fup0k8tBMvSrHzRRb/c5c4HQZtQf7y wR1y+RLJnr4yNI00SQC5rYtIM0liN1UKTdO2JwWJoOkmrspz7u33h1QAXPl3g0sfrJMvVugG2dNB 1zXiOEJEbhn3f+mbAjxmWIXPlQoFvFBlar7olHjvxl2u3rjD/VWHQ6Ucy3c7XPjbDZ5/cwmnPI1h 5ugGO/2lAQXLoLfWQKXJz7VHnn0d4JidL/65Ov1JWm6cCY1j6xRtg8DbwHfXSCIfw7TJORUKpTq6 YQ75HC5ZBN4G3dWPLl19/ltPbDXjO5HvXgl99+ghp0jbS3YaK1T4kXCoWCXnVDOL9WOF188CNAZq /N4aiPwCwITtFn/R763+zrJLqGyeUQgr3exi48Z0ySL0OsSh+87VF77zLmTvk4thf+PDOA4o582J jviRBvTdVURkdgu8+6hPEZnze21MQ/u/ADXHJPJdYr/793+8+N1L25A9t935oNdupWlCwRo+BQ4y TdPw3TYizO4OoU6W4iPyctBt4VgGopjYanmTJOgTe+vXEfl9BrLnjkdE5oNOw1dKYZuTq9F1jcBt ISKzS3PfT7NKNm+tXdYC+W3otpnKGRMBynmDNA6IvfYtkFf3VtzecG3ZXLhxKxUR9K3Dbx+zDZ3I bYHI3D9/+YNoCDIiXIjIdRFZiLw16gUDpWSsOZZOmkREvWZLRF4Z1TvjlIDIXOzdRbF/qAq2TuSu gMi59+d/6I6EjFGCiFxOg+6VNOhxX9EcuQ/H0hGVEnfvuCIyPwowLvG7bT72VkAb3ZxOziDuNQH5 9bWXnu6Mh+yf1Quq3/5QYp9Kwci8ypk6KCHp/jdCZG4c4KBwISKpiMwnbhPb0IfKNnYbiMj5a+d+ 3NwXckC4ADmfeo2WpDFFeyDc0jVEhLR7MwWZHb/8tpL9e0AEV4SXE6+JYw+as+qYJN4KIrz+r189 s3wg5MBOG9g51b0ViRJy5qaL2wA5WMWk4QKkCXJe9ZtU8gbKbyGJtwAy9FU1RskkDECYF68xUOE1 QJjduVQPgGx+OkzyuyaJd1GCFhJ1LgvyrkxImTQn20eNeHcGudj6byLIvY3LRJ1XgLfuxel/1MGY 0YvhJSIAAAAASUVORK5CYII= "
|
||||
height="41"
|
||||
width="25"
|
||||
inkscape:export-filename="C:\Users\dave.STK\Desktop\path3868.png"
|
||||
inkscape:export-xdpi="644.65582"
|
||||
inkscape:export-ydpi="644.65582" />
|
||||
<rect
|
||||
inkscape:export-ydpi="180"
|
||||
inkscape:export-xdpi="180"
|
||||
inkscape:export-filename="C:\Users\dave.STK\Desktop\git\Leaflet\Leaflet\dist\images\marker-icon@2x.png"
|
||||
y="502.36218"
|
||||
x="404"
|
||||
height="41"
|
||||
width="25"
|
||||
id="rect3771"
|
||||
style="opacity:0;fill:#ffffff;fill-opacity:0.49468085;stroke:none" />
|
||||
<rect
|
||||
inkscape:export-ydpi="180"
|
||||
inkscape:export-xdpi="180"
|
||||
inkscape:export-filename="C:\Users\dave.STK\Desktop\git\Leaflet\Leaflet\dist\images\marker-icon@2x.png"
|
||||
y="507.57468"
|
||||
x="410.27899"
|
||||
height="14.5"
|
||||
width="12.625"
|
||||
id="rect3773"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="zscccszcscsc"
|
||||
style="fill:url(#linearGradient3844);fill-opacity:1;stroke:url(#linearGradient3846);stroke-width:1.10000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 416.54436,503.61217 c -6.57257,0 -12.04436,5.69119 -12.04436,11.86601 0,2.77793 1.56377,6.30831 2.69401,8.746 l 9.30616,17.87172 9.26184,-17.87172 c 1.13024,-2.43769 2.73799,-5.79129 2.73799,-8.746 0,-6.17482 -5.38307,-11.86601 -11.95564,-11.86601 z m 0,7.15501 c 2.58449,0.0167 4.67909,2.1215 4.67909,4.70988 0,2.5884 -2.0946,4.66256 -4.67909,4.67912 -2.58449,-0.0165 -4.67909,-2.09048 -4.67909,-4.67888 0,-2.58837 2.0946,-4.69335 4.67909,-4.71012 z"
|
||||
id="path3873"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="C:\Users\dave.STK\Desktop\git\Leaflet\Leaflet\dist\images\marker-icon@2x.png"
|
||||
inkscape:export-xdpi="180"
|
||||
inkscape:export-ydpi="180" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:4px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||
x="403.75"
|
||||
y="489.36218"
|
||||
id="text3899"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3901"
|
||||
x="403.75"
|
||||
y="489.36218">Use this one.</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="403.75"
|
||||
y="494.36218"
|
||||
id="tspan3903">Select it and the area around with box select.</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="403.75"
|
||||
y="499.36218"
|
||||
id="tspan3905">should be exactly 25x41 at 90dpi</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||
x="408.70773"
|
||||
y="563.7514"
|
||||
id="text3901"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3904"
|
||||
x="408.70773"
|
||||
y="563.7514"
|
||||
style="font-size:4px">How to do the inset border:</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="568.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3908">Delete the existing inset border. Select the background, duplicate.</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="573.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3910">Path, Dynamic offset.</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="578.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3912">Fill: None, Stroke Paint: RGBA #ffffff1f </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="583.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3916">Zoom down to the top and grab the diamond, drag it down and fiddle it untill it looks in line</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="588.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3918">with the main color layers border.</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="593.7514"
|
||||
style="font-size:4px"
|
||||
id="tspan3914" /><tspan
|
||||
sodipodi:role="line"
|
||||
x="408.70773"
|
||||
y="598.7514"
|
||||
id="tspan3906"
|
||||
style="font-size:4px" /></text>
|
||||
<path
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-1.09294"
|
||||
inkscape:original="M 416.53125 503.625 C 409.95868 503.625 404.5 509.29393 404.5 515.46875 C 404.5 518.24668 406.05726 521.78106 407.1875 524.21875 L 416.5 542.09375 L 425.75 524.21875 C 426.88024 521.78106 428.5 518.42346 428.5 515.46875 C 428.5 509.29393 423.10382 503.625 416.53125 503.625 z M 416.53125 510.78125 C 419.11574 510.79795 421.21875 512.88037 421.21875 515.46875 C 421.21875 518.05715 419.11574 520.13969 416.53125 520.15625 C 413.94676 520.13975 411.875 518.05715 411.875 515.46875 C 411.875 512.88038 413.94676 510.79802 416.53125 510.78125 z "
|
||||
style="fill:none;stroke:#ffffff;stroke-width:1.10000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.12156863;stroke-dasharray:none"
|
||||
id="path3792"
|
||||
d="m 416.53125,504.71875 c -5.94412,0 -10.9375,5.2193 -10.9375,10.75 0,2.35872 1.44272,5.83174 2.5625,8.25 0.005,0.011 0.0262,0.0203 0.0312,0.0312 L 416.5,539.71875 424.75,523.75 c 0.005,-0.0113 0.026,-0.0199 0.0312,-0.0312 1.13492,-2.44805 2.625,-5.70649 2.625,-8.25 0,-5.53807 -4.93088,-10.75 -10.875,-10.75 z m 0,4.96875 c 3.1677,0.0205 5.78125,2.60087 5.78125,5.78125 0,3.18039 -2.61348,5.76095 -5.78125,5.78125 -3.16786,-0.0202 -5.75,-2.60966 -5.75,-5.78125 0,-3.17157 2.58227,-5.7607 5.75,-5.78125 z"
|
||||
inkscape:export-filename="C:\Users\dave.STK\Desktop\git\Leaflet\Leaflet\dist\images\marker-icon@2x.png"
|
||||
inkscape:export-xdpi="180"
|
||||
inkscape:export-ydpi="180" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 15 KiB |
@ -1,52 +1,69 @@
|
||||
/*
|
||||
* L.FeatureGroup extends L.LayerGroup by introducing mouse events and bindPopup method shared between a group of layers.
|
||||
* L.FeatureGroup extends L.LayerGroup by introducing mouse events and additional methods
|
||||
* shared between a group of interactive layers (like vectors or markers).
|
||||
*/
|
||||
|
||||
L.FeatureGroup = L.LayerGroup.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
statics: {
|
||||
EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu'
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
if (this._layers[L.Util.stamp(layer)]) {
|
||||
if (this._layers[L.stamp(layer)]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
layer.on('click dblclick mouseover mouseout mousemove contextmenu', this._propagateEvent, this);
|
||||
layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
|
||||
|
||||
L.LayerGroup.prototype.addLayer.call(this, layer);
|
||||
|
||||
if (this._popupContent && layer.bindPopup) {
|
||||
layer.bindPopup(this._popupContent);
|
||||
layer.bindPopup(this._popupContent, this._popupOptions);
|
||||
}
|
||||
|
||||
return this;
|
||||
return this.fire('layeradd', {layer: layer});
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
layer.off('click dblclick mouseover mouseout mousemove contextmenu', this._propagateEvent, this);
|
||||
layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this);
|
||||
|
||||
L.LayerGroup.prototype.removeLayer.call(this, layer);
|
||||
|
||||
|
||||
if (this._popupContent) {
|
||||
return this.invoke('unbindPopup');
|
||||
} else {
|
||||
return this;
|
||||
this.invoke('unbindPopup');
|
||||
}
|
||||
|
||||
return this.fire('layerremove', {layer: layer});
|
||||
},
|
||||
|
||||
bindPopup: function (content) {
|
||||
bindPopup: function (content, options) {
|
||||
this._popupContent = content;
|
||||
return this.invoke('bindPopup', content);
|
||||
this._popupOptions = options;
|
||||
return this.invoke('bindPopup', content, options);
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
return this.invoke('setStyle', style);
|
||||
},
|
||||
|
||||
bringToFront: function () {
|
||||
return this.invoke('bringToFront');
|
||||
},
|
||||
|
||||
bringToBack: function () {
|
||||
return this.invoke('bringToBack');
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var bounds = new L.LatLngBounds();
|
||||
|
||||
this.eachLayer(function (layer) {
|
||||
bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());
|
||||
}, this);
|
||||
});
|
||||
|
||||
return bounds;
|
||||
},
|
||||
|
||||
|
@ -1,6 +1,11 @@
|
||||
/*
|
||||
* L.GeoJSON turns any GeoJSON data into a Leaflet layer.
|
||||
*/
|
||||
|
||||
L.GeoJSON = L.FeatureGroup.extend({
|
||||
|
||||
initialize: function (geojson, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._layers = {};
|
||||
|
||||
@ -10,41 +15,63 @@ L.GeoJSON = L.FeatureGroup.extend({
|
||||
},
|
||||
|
||||
addData: function (geojson) {
|
||||
var features = geojson instanceof Array ? geojson : geojson.features,
|
||||
var features = L.Util.isArray(geojson) ? geojson : geojson.features,
|
||||
i, len;
|
||||
|
||||
if (features) {
|
||||
for (i = 0, len = features.length; i < len; i++) {
|
||||
this.addData(features[i]);
|
||||
// Only add this if geometry or geometries are set and not null
|
||||
if (features[i].geometries || features[i].geometry) {
|
||||
this.addData(features[i]);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
var options = this.options,
|
||||
style = options.style;
|
||||
var options = this.options;
|
||||
|
||||
if (options.filter && !options.filter(geojson)) { return; }
|
||||
|
||||
var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer);
|
||||
layer.feature = geojson;
|
||||
|
||||
if (style) {
|
||||
if (typeof style === 'function') {
|
||||
style = style(geojson);
|
||||
}
|
||||
if (layer.setStyle) {
|
||||
layer.setStyle(style);
|
||||
}
|
||||
}
|
||||
layer.defaultOptions = layer.options;
|
||||
this.resetStyle(layer);
|
||||
|
||||
if (options.onEachFeature) {
|
||||
options.onEachFeature(geojson, layer);
|
||||
}
|
||||
|
||||
return this.addLayer(layer);
|
||||
},
|
||||
|
||||
resetStyle: function (layer) {
|
||||
var style = this.options.style;
|
||||
if (style) {
|
||||
// reset any custom styles
|
||||
L.Util.extend(layer.options, layer.defaultOptions);
|
||||
|
||||
this._setLayerStyle(layer, style);
|
||||
}
|
||||
},
|
||||
|
||||
setStyle: function (style) {
|
||||
this.eachLayer(function (layer) {
|
||||
this._setLayerStyle(layer, style);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_setLayerStyle: function (layer, style) {
|
||||
if (typeof style === 'function') {
|
||||
style = style(layer.feature);
|
||||
}
|
||||
if (layer.setStyle) {
|
||||
layer.setStyle(style);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
L.Util.extend(L.GeoJSON, {
|
||||
L.extend(L.GeoJSON, {
|
||||
geometryToLayer: function (geojson, pointToLayer) {
|
||||
var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
|
||||
coords = geometry.coordinates,
|
||||
@ -76,13 +103,17 @@ L.Util.extend(L.GeoJSON, {
|
||||
latlngs = this.coordsToLatLngs(coords, 1);
|
||||
return new L.MultiPolyline(latlngs);
|
||||
|
||||
case "MultiPolygon":
|
||||
case 'MultiPolygon':
|
||||
latlngs = this.coordsToLatLngs(coords, 2);
|
||||
return new L.MultiPolygon(latlngs);
|
||||
|
||||
case "GeometryCollection":
|
||||
case 'GeometryCollection':
|
||||
for (i = 0, len = geometry.geometries.length; i < len; i++) {
|
||||
layer = this.geometryToLayer(geometry.geometries[i], pointToLayer);
|
||||
layer = this.geometryToLayer({
|
||||
geometry: geometry.geometries[i],
|
||||
type: 'Feature',
|
||||
properties: geojson.properties
|
||||
}, pointToLayer);
|
||||
layers.push(layer);
|
||||
}
|
||||
return new L.FeatureGroup(layers);
|
||||
@ -96,7 +127,7 @@ L.Util.extend(L.GeoJSON, {
|
||||
var lat = parseFloat(coords[reverse ? 0 : 1]),
|
||||
lng = parseFloat(coords[reverse ? 1 : 0]);
|
||||
|
||||
return new L.LatLng(lat, lng, true);
|
||||
return new L.LatLng(lat, lng);
|
||||
},
|
||||
|
||||
coordsToLatLngs: function (coords, levelsDeep, reverse) { // (Array, Number, Boolean) -> Array
|
||||
@ -106,8 +137,8 @@ L.Util.extend(L.GeoJSON, {
|
||||
|
||||
for (i = 0, len = coords.length; i < len; i++) {
|
||||
latlng = levelsDeep ?
|
||||
this.coordsToLatLngs(coords[i], levelsDeep - 1, reverse) :
|
||||
this.coordsToLatLng(coords[i], reverse);
|
||||
this.coordsToLatLngs(coords[i], levelsDeep - 1, reverse) :
|
||||
this.coordsToLatLng(coords[i], reverse);
|
||||
|
||||
latlngs.push(latlng);
|
||||
}
|
||||
@ -118,4 +149,4 @@ L.Util.extend(L.GeoJSON, {
|
||||
|
||||
L.geoJson = function (geojson, options) {
|
||||
return new L.GeoJSON(geojson, options);
|
||||
};
|
||||
};
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* L.ImageOverlay is used to overlay images over the map (to specific geographical bounds).
|
||||
*/
|
||||
|
||||
L.ImageOverlay = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
@ -9,7 +13,7 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._url = url;
|
||||
this._bounds = L.latLngBounds(bounds);
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -79,33 +83,34 @@ L.ImageOverlay = L.Class.extend({
|
||||
this._updateOpacity();
|
||||
|
||||
//TODO createImage util method to remove duplication
|
||||
L.Util.extend(this._image, {
|
||||
L.extend(this._image, {
|
||||
galleryimg: 'no',
|
||||
onselectstart: L.Util.falseFn,
|
||||
onmousemove: L.Util.falseFn,
|
||||
onload: L.Util.bind(this._onImageLoad, this),
|
||||
onload: L.bind(this._onImageLoad, this),
|
||||
src: this._url
|
||||
});
|
||||
},
|
||||
|
||||
_animateZoom: function (e) {
|
||||
var map = this._map,
|
||||
image = this._image,
|
||||
image = this._image,
|
||||
scale = map.getZoomScale(e.zoom),
|
||||
nw = this._bounds.getNorthWest(),
|
||||
se = this._bounds.getSouthEast(),
|
||||
topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),
|
||||
size = map._latLngToNewLayerPoint(se, e.zoom, e.center).subtract(topLeft),
|
||||
currentSize = map.latLngToLayerPoint(se).subtract(map.latLngToLayerPoint(nw)),
|
||||
origin = topLeft.add(size.subtract(currentSize).divideBy(2));
|
||||
|
||||
image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
|
||||
topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),
|
||||
size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft),
|
||||
origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale)));
|
||||
|
||||
image.style[L.DomUtil.TRANSFORM] =
|
||||
L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
|
||||
},
|
||||
|
||||
_reset: function () {
|
||||
var image = this._image,
|
||||
topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
|
||||
size = this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(topLeft);
|
||||
size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);
|
||||
|
||||
L.DomUtil.setPosition(image, topLeft);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* L.LayerGroup is a class to combine several layers so you can manipulate the group (e.g. add/remove it) as one layer.
|
||||
* L.LayerGroup is a class to combine several layers into one so that
|
||||
* you can manipulate the group (e.g. add/remove it) as one layer.
|
||||
*/
|
||||
|
||||
L.LayerGroup = L.Class.extend({
|
||||
@ -16,7 +17,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
addLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[id] = layer;
|
||||
|
||||
@ -28,7 +29,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
removeLayer: function (layer) {
|
||||
var id = L.Util.stamp(layer);
|
||||
var id = L.stamp(layer);
|
||||
|
||||
delete this._layers[id];
|
||||
|
||||
@ -46,7 +47,7 @@ L.LayerGroup = L.Class.extend({
|
||||
|
||||
invoke: function (methodName) {
|
||||
var args = Array.prototype.slice.call(arguments, 1),
|
||||
i, layer;
|
||||
i, layer;
|
||||
|
||||
for (i in this._layers) {
|
||||
if (this._layers.hasOwnProperty(i)) {
|
||||
@ -82,6 +83,10 @@ L.LayerGroup = L.Class.extend({
|
||||
method.call(context, this._layers[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setZIndex: function (zIndex) {
|
||||
return this.invoke('setZIndex', zIndex);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
/*
|
||||
* L.Popup is used for displaying popups on the map.
|
||||
*/
|
||||
|
||||
L.Map.mergeOptions({
|
||||
closePopupOnClick: true
|
||||
@ -14,13 +17,15 @@ L.Popup = L.Class.extend({
|
||||
closeButton: true,
|
||||
offset: new L.Point(0, 6),
|
||||
autoPanPadding: new L.Point(5, 5),
|
||||
className: ''
|
||||
className: '',
|
||||
zoomAnimation: true
|
||||
},
|
||||
|
||||
initialize: function (options, source) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
|
||||
this._source = source;
|
||||
this._animated = L.Browser.any3d && this.options.zoomAnimation;
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -40,7 +45,7 @@ L.Popup = L.Class.extend({
|
||||
|
||||
map.on('viewreset', this._updatePosition, this);
|
||||
|
||||
if (L.Browser.any3d) {
|
||||
if (this._animated) {
|
||||
map.on('zoomanim', this._zoomAnimation, this);
|
||||
}
|
||||
|
||||
@ -102,25 +107,29 @@ L.Popup = L.Class.extend({
|
||||
map._popup = null;
|
||||
|
||||
map
|
||||
.removeLayer(this)
|
||||
.fire('popupclose', {popup: this});
|
||||
.removeLayer(this)
|
||||
.fire('popupclose', {popup: this});
|
||||
}
|
||||
},
|
||||
|
||||
_initLayout: function () {
|
||||
var prefix = 'leaflet-popup',
|
||||
container = this._container = L.DomUtil.create('div', prefix + ' ' + this.options.className + ' leaflet-zoom-animated'),
|
||||
containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' +
|
||||
(this._animated ? 'animated' : 'hide'),
|
||||
container = this._container = L.DomUtil.create('div', containerClass),
|
||||
closeButton;
|
||||
|
||||
if (this.options.closeButton) {
|
||||
closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container);
|
||||
closeButton = this._closeButton =
|
||||
L.DomUtil.create('a', prefix + '-close-button', container);
|
||||
closeButton.href = '#close';
|
||||
closeButton.innerHTML = '×';
|
||||
|
||||
L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);
|
||||
}
|
||||
|
||||
var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container);
|
||||
var wrapper = this._wrapper =
|
||||
L.DomUtil.create('div', prefix + '-content-wrapper', container);
|
||||
L.DomEvent.disableClickPropagation(wrapper);
|
||||
|
||||
this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
|
||||
@ -160,7 +169,7 @@ L.Popup = L.Class.extend({
|
||||
|
||||
_updateLayout: function () {
|
||||
var container = this._contentNode,
|
||||
style = container.style;
|
||||
style = container.style;
|
||||
|
||||
style.width = '';
|
||||
style.whiteSpace = 'nowrap';
|
||||
@ -175,8 +184,8 @@ L.Popup = L.Class.extend({
|
||||
style.height = '';
|
||||
|
||||
var height = container.offsetHeight,
|
||||
maxHeight = this.options.maxHeight,
|
||||
scrolledClass = 'leaflet-popup-scrolled';
|
||||
maxHeight = this.options.maxHeight,
|
||||
scrolledClass = 'leaflet-popup-scrolled';
|
||||
|
||||
if (maxHeight && height > maxHeight) {
|
||||
style.height = maxHeight + 'px';
|
||||
@ -189,16 +198,18 @@ L.Popup = L.Class.extend({
|
||||
},
|
||||
|
||||
_updatePosition: function () {
|
||||
var pos = this._map.latLngToLayerPoint(this._latlng),
|
||||
is3d = L.Browser.any3d,
|
||||
offset = this.options.offset;
|
||||
if (!this._map) { return; }
|
||||
|
||||
if (is3d) {
|
||||
var pos = this._map.latLngToLayerPoint(this._latlng),
|
||||
animated = this._animated,
|
||||
offset = this.options.offset;
|
||||
|
||||
if (animated) {
|
||||
L.DomUtil.setPosition(this._container, pos);
|
||||
}
|
||||
|
||||
this._containerBottom = -offset.y - (is3d ? 0 : pos.y);
|
||||
this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (is3d ? 0 : pos.x);
|
||||
this._containerBottom = -offset.y - (animated ? 0 : pos.y);
|
||||
this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x);
|
||||
|
||||
//Bottom position the popup in case the height of the popup changes (images loading etc)
|
||||
this._container.style.bottom = this._containerBottom + 'px';
|
||||
@ -215,20 +226,20 @@ L.Popup = L.Class.extend({
|
||||
if (!this.options.autoPan) { return; }
|
||||
|
||||
var map = this._map,
|
||||
containerHeight = this._container.offsetHeight,
|
||||
containerWidth = this._containerWidth,
|
||||
containerHeight = this._container.offsetHeight,
|
||||
containerWidth = this._containerWidth,
|
||||
|
||||
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
|
||||
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
|
||||
|
||||
if (L.Browser.any3d) {
|
||||
if (this._animated) {
|
||||
layerPos._add(L.DomUtil.getPosition(this._container));
|
||||
}
|
||||
|
||||
var containerPos = map.layerPointToContainerPoint(layerPos),
|
||||
padding = this.options.autoPanPadding,
|
||||
size = map.getSize(),
|
||||
dx = 0,
|
||||
dy = 0;
|
||||
padding = this.options.autoPanPadding,
|
||||
size = map.getSize(),
|
||||
dx = 0,
|
||||
dy = 0;
|
||||
|
||||
if (containerPos.x < 0) {
|
||||
dx = containerPos.x - padding.x;
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon)
|
||||
* to use with L.Marker.
|
||||
*/
|
||||
|
||||
L.DivIcon = L.Icon.extend({
|
||||
options: {
|
||||
iconSize: new L.Point(12, 12), // also can be set through CSS
|
||||
@ -20,7 +25,7 @@ L.DivIcon = L.Icon.extend({
|
||||
|
||||
if (options.bgPos) {
|
||||
div.style.backgroundPosition =
|
||||
(-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
|
||||
(-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
|
||||
}
|
||||
|
||||
this._setIconStyles(div, 'icon');
|
||||
|
@ -1,9 +1,12 @@
|
||||
/*
|
||||
* L.Icon.Default is the blue marker icon used by default in Leaflet.
|
||||
*/
|
||||
|
||||
L.Icon.Default = L.Icon.extend({
|
||||
|
||||
options: {
|
||||
iconSize: new L.Point(25, 41),
|
||||
iconAnchor: new L.Point(13, 41),
|
||||
iconAnchor: new L.Point(12, 41),
|
||||
popupAnchor: new L.Point(1, -34),
|
||||
|
||||
shadowSize: new L.Point(41, 41)
|
||||
@ -16,6 +19,10 @@ L.Icon.Default = L.Icon.extend({
|
||||
return this.options[key];
|
||||
}
|
||||
|
||||
if (L.Browser.retina && name === 'icon') {
|
||||
name += '@2x';
|
||||
}
|
||||
|
||||
var path = L.Icon.Default.imagePath;
|
||||
|
||||
if (!path) {
|
||||
|
@ -1,11 +1,17 @@
|
||||
/*
|
||||
* L.Icon is an image-based icon class that you can use with L.Marker for custom markers.
|
||||
*/
|
||||
|
||||
L.Icon = L.Class.extend({
|
||||
options: {
|
||||
/*
|
||||
iconUrl: (String) (required)
|
||||
iconRetinaUrl: (String) (optional, used for retina devices if detected)
|
||||
iconSize: (Point) (can be set through CSS)
|
||||
iconAnchor: (Point) (centered by default if size is specified, can be set in CSS with negative margins)
|
||||
iconAnchor: (Point) (centered by default, can be set in CSS with negative margins)
|
||||
popupAnchor: (Point) (if not specified, popup opens in the anchor point)
|
||||
shadowUrl: (Point) (no shadow by default)
|
||||
shadowRetinaUrl: (String) (optional, used for retina devices if detected)
|
||||
shadowSize: (Point)
|
||||
shadowAnchor: (Point)
|
||||
*/
|
||||
@ -13,7 +19,7 @@ L.Icon = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
createIcon: function () {
|
||||
@ -42,8 +48,8 @@ L.Icon = L.Class.extend({
|
||||
|
||||
_setIconStyles: function (img, name) {
|
||||
var options = this.options,
|
||||
size = L.point(options[name + 'Size']),
|
||||
anchor;
|
||||
size = L.point(options[name + 'Size']),
|
||||
anchor;
|
||||
|
||||
if (name === 'shadow') {
|
||||
anchor = L.point(options.shadowAnchor || options.iconAnchor);
|
||||
@ -76,12 +82,16 @@ L.Icon = L.Class.extend({
|
||||
el.src = src;
|
||||
} else {
|
||||
el = document.createElement('div');
|
||||
el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")';
|
||||
el.style.filter =
|
||||
'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")';
|
||||
}
|
||||
return el;
|
||||
},
|
||||
|
||||
_getIconUrl: function (name) {
|
||||
if (L.Browser.retina && this.options[name + 'RetinaUrl']) {
|
||||
return this.options[name + 'RetinaUrl'];
|
||||
}
|
||||
return this.options[name + 'Url'];
|
||||
}
|
||||
});
|
||||
|
@ -11,9 +11,9 @@ L.Handler.MarkerDrag = L.Handler.extend({
|
||||
var icon = this._marker._icon;
|
||||
if (!this._draggable) {
|
||||
this._draggable = new L.Draggable(icon, icon)
|
||||
.on('dragstart', this._onDragStart, this)
|
||||
.on('drag', this._onDrag, this)
|
||||
.on('dragend', this._onDragEnd, this);
|
||||
.on('dragstart', this._onDragStart, this)
|
||||
.on('drag', this._onDrag, this)
|
||||
.on('dragend', this._onDragEnd, this);
|
||||
}
|
||||
this._draggable.enable();
|
||||
},
|
||||
@ -26,30 +26,34 @@ L.Handler.MarkerDrag = L.Handler.extend({
|
||||
return this._draggable && this._draggable._moved;
|
||||
},
|
||||
|
||||
_onDragStart: function (e) {
|
||||
_onDragStart: function () {
|
||||
this._marker
|
||||
.closePopup()
|
||||
.fire('movestart')
|
||||
.fire('dragstart');
|
||||
.closePopup()
|
||||
.fire('movestart')
|
||||
.fire('dragstart');
|
||||
},
|
||||
|
||||
_onDrag: function (e) {
|
||||
_onDrag: function () {
|
||||
var marker = this._marker,
|
||||
shadow = marker._shadow,
|
||||
iconPos = L.DomUtil.getPosition(marker._icon),
|
||||
latlng = marker._map.layerPointToLatLng(iconPos);
|
||||
|
||||
// update shadow position
|
||||
var iconPos = L.DomUtil.getPosition(this._marker._icon);
|
||||
if (this._marker._shadow) {
|
||||
L.DomUtil.setPosition(this._marker._shadow, iconPos);
|
||||
if (shadow) {
|
||||
L.DomUtil.setPosition(shadow, iconPos);
|
||||
}
|
||||
|
||||
this._marker._latlng = this._marker._map.layerPointToLatLng(iconPos);
|
||||
marker._latlng = latlng;
|
||||
|
||||
this._marker
|
||||
.fire('move')
|
||||
.fire('drag');
|
||||
marker
|
||||
.fire('move', {latlng: latlng})
|
||||
.fire('drag');
|
||||
},
|
||||
|
||||
_onDragEnd: function () {
|
||||
this._marker
|
||||
.fire('moveend')
|
||||
.fire('dragend');
|
||||
.fire('moveend')
|
||||
.fire('dragend');
|
||||
}
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Popup extension to L.Marker, adding openPopup & bindPopup methods.
|
||||
* Popup extension to L.Marker, adding popup-related methods.
|
||||
*/
|
||||
|
||||
L.Marker.include({
|
||||
@ -28,10 +28,13 @@ L.Marker.include({
|
||||
anchor = anchor.add(options.offset);
|
||||
}
|
||||
|
||||
options = L.Util.extend({offset: anchor}, options);
|
||||
options = L.extend({offset: anchor}, options);
|
||||
|
||||
if (!this._popup) {
|
||||
this.on('click', this.openPopup, this);
|
||||
this
|
||||
.on('click', this.openPopup, this)
|
||||
.on('remove', this.closePopup, this)
|
||||
.on('move', this._movePopup, this);
|
||||
}
|
||||
|
||||
this._popup = new L.Popup(options, this)
|
||||
@ -43,8 +46,15 @@ L.Marker.include({
|
||||
unbindPopup: function () {
|
||||
if (this._popup) {
|
||||
this._popup = null;
|
||||
this.off('click', this.openPopup);
|
||||
this
|
||||
.off('click', this.openPopup)
|
||||
.off('remove', this.closePopup)
|
||||
.off('move', this._movePopup);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
_movePopup: function (e) {
|
||||
this._popup.setLatLng(e.latlng);
|
||||
}
|
||||
});
|
||||
|
@ -12,11 +12,13 @@ L.Marker = L.Class.extend({
|
||||
clickable: true,
|
||||
draggable: false,
|
||||
zIndexOffset: 0,
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
riseOnHover: false,
|
||||
riseOffset: 250
|
||||
},
|
||||
|
||||
initialize: function (latlng, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
this._latlng = L.latLng(latlng);
|
||||
},
|
||||
|
||||
@ -41,10 +43,7 @@ L.Marker = L.Class.extend({
|
||||
onRemove: function (map) {
|
||||
this._removeIcon();
|
||||
|
||||
// TODO move to Marker.Popup.js
|
||||
if (this.closePopup) {
|
||||
this.closePopup();
|
||||
}
|
||||
this.fire('remove');
|
||||
|
||||
map.off({
|
||||
'viewreset': this.update,
|
||||
@ -63,14 +62,14 @@ L.Marker = L.Class.extend({
|
||||
|
||||
this.update();
|
||||
|
||||
if (this._popup) {
|
||||
this._popup.setLatLng(latlng);
|
||||
}
|
||||
return this.fire('move', { latlng: this._latlng });
|
||||
},
|
||||
|
||||
setZIndexOffset: function (offset) {
|
||||
this.options.zIndexOffset = offset;
|
||||
this.update();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setIcon: function (icon) {
|
||||
@ -84,13 +83,17 @@ L.Marker = L.Class.extend({
|
||||
this._initIcon();
|
||||
this.update();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
update: function () {
|
||||
if (!this._icon) { return; }
|
||||
if (this._icon) {
|
||||
var pos = this._map.latLngToLayerPoint(this._latlng).round();
|
||||
this._setPos(pos);
|
||||
}
|
||||
|
||||
var pos = this._map.latLngToLayerPoint(this._latlng).round();
|
||||
this._setPos(pos);
|
||||
return this;
|
||||
},
|
||||
|
||||
_initIcon: function () {
|
||||
@ -111,7 +114,14 @@ L.Marker = L.Class.extend({
|
||||
needOpacityUpdate = (this.options.opacity < 1);
|
||||
|
||||
L.DomUtil.addClass(this._icon, classToAdd);
|
||||
|
||||
if (options.riseOnHover) {
|
||||
L.DomEvent
|
||||
.on(this._icon, 'mouseover', this._bringToFront, this)
|
||||
.on(this._icon, 'mouseout', this._resetZIndex, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._shadow) {
|
||||
this._shadow = options.icon.createShadow();
|
||||
|
||||
@ -137,6 +147,12 @@ L.Marker = L.Class.extend({
|
||||
_removeIcon: function () {
|
||||
var panes = this._map._panes;
|
||||
|
||||
if (this.options.riseOnHover) {
|
||||
L.DomEvent
|
||||
.off(this._icon, 'mouseover', this._bringToFront)
|
||||
.off(this._icon, 'mouseout', this._resetZIndex);
|
||||
}
|
||||
|
||||
panes.markerPane.removeChild(this._icon);
|
||||
|
||||
if (this._shadow) {
|
||||
@ -153,7 +169,13 @@ L.Marker = L.Class.extend({
|
||||
L.DomUtil.setPosition(this._shadow, pos);
|
||||
}
|
||||
|
||||
this._icon.style.zIndex = pos.y + this.options.zIndexOffset;
|
||||
this._zIndex = pos.y + this.options.zIndexOffset;
|
||||
|
||||
this._resetZIndex();
|
||||
},
|
||||
|
||||
_updateZIndex: function (offset) {
|
||||
this._icon.style.zIndex = this._zIndex + offset;
|
||||
},
|
||||
|
||||
_animateZoom: function (opt) {
|
||||
@ -163,12 +185,13 @@ L.Marker = L.Class.extend({
|
||||
},
|
||||
|
||||
_initInteraction: function () {
|
||||
if (!this.options.clickable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.options.clickable) { return; }
|
||||
|
||||
// TODO refactor into something shared with Map/Path/etc. to DRY it up
|
||||
|
||||
var icon = this._icon,
|
||||
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout'];
|
||||
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
||||
|
||||
L.DomUtil.addClass(icon, 'leaflet-clickable');
|
||||
L.DomEvent.on(icon, 'click', this._onMouseClick, this);
|
||||
@ -187,18 +210,32 @@ L.Marker = L.Class.extend({
|
||||
},
|
||||
|
||||
_onMouseClick: function (e) {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
if (this.dragging && this.dragging.moved()) { return; }
|
||||
if (this._map.dragging && this._map.dragging.moved()) { return; }
|
||||
var wasDragged = this.dragging && this.dragging.moved();
|
||||
|
||||
if (this.hasEventListeners(e.type) || wasDragged) {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
}
|
||||
|
||||
if (wasDragged) { return; }
|
||||
|
||||
if ((!this.dragging || !this.dragging._enabled) && this._map.dragging && this._map.dragging.moved()) { return; }
|
||||
|
||||
this.fire(e.type, {
|
||||
originalEvent: e
|
||||
});
|
||||
},
|
||||
|
||||
_fireMouseEvent: function (e) {
|
||||
|
||||
this.fire(e.type, {
|
||||
originalEvent: e
|
||||
});
|
||||
|
||||
// TODO proper custom event propagation
|
||||
// this line will always be called if marker is in a FeatureGroup
|
||||
if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {
|
||||
L.DomEvent.preventDefault(e);
|
||||
}
|
||||
if (e.type !== 'mousedown') {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
}
|
||||
@ -216,6 +253,14 @@ L.Marker = L.Class.extend({
|
||||
if (this._shadow) {
|
||||
L.DomUtil.setOpacity(this._shadow, this.options.opacity);
|
||||
}
|
||||
},
|
||||
|
||||
_bringToFront: function () {
|
||||
this._updateZIndex(this.options.riseOffset);
|
||||
},
|
||||
|
||||
_resetZIndex: function () {
|
||||
this._updateZIndex(0);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,17 +1,21 @@
|
||||
/*
|
||||
* L.TileLayer.Canvas is a class that you can use as a base for creating
|
||||
* dynamically drawn Canvas-based tile layers.
|
||||
*/
|
||||
|
||||
L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
options: {
|
||||
async: false
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
redraw: function () {
|
||||
var i,
|
||||
tiles = this._tiles;
|
||||
var tiles = this._tiles;
|
||||
|
||||
for (i in tiles) {
|
||||
for (var i in tiles) {
|
||||
if (tiles.hasOwnProperty(i)) {
|
||||
this._redrawTile(tiles[i]);
|
||||
}
|
||||
@ -19,15 +23,12 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
},
|
||||
|
||||
_redrawTile: function (tile) {
|
||||
this.drawTile(tile, tile._tilePoint, tile._zoom);
|
||||
this.drawTile(tile, tile._tilePoint, this._map._zoom);
|
||||
},
|
||||
|
||||
_createTileProto: function () {
|
||||
var proto = this._canvasProto = L.DomUtil.create('canvas', 'leaflet-tile');
|
||||
|
||||
var tileSize = this.options.tileSize;
|
||||
proto.width = tileSize;
|
||||
proto.height = tileSize;
|
||||
proto.width = proto.height = this.options.tileSize;
|
||||
},
|
||||
|
||||
_createTile: function () {
|
||||
@ -36,19 +37,18 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
return tile;
|
||||
},
|
||||
|
||||
_loadTile: function (tile, tilePoint, zoom) {
|
||||
_loadTile: function (tile, tilePoint) {
|
||||
tile._layer = this;
|
||||
tile._tilePoint = tilePoint;
|
||||
tile._zoom = zoom;
|
||||
|
||||
this.drawTile(tile, tilePoint, zoom);
|
||||
this._redrawTile(tile);
|
||||
|
||||
if (!this.options.async) {
|
||||
this.tileDrawn(tile);
|
||||
}
|
||||
},
|
||||
|
||||
drawTile: function (tile, tilePoint, zoom) {
|
||||
drawTile: function (/*tile, tilePoint*/) {
|
||||
// override with rendering code
|
||||
},
|
||||
|
||||
@ -60,4 +60,4 @@ L.TileLayer.Canvas = L.TileLayer.extend({
|
||||
|
||||
L.tileLayer.canvas = function (options) {
|
||||
return new L.TileLayer.Canvas(options);
|
||||
};
|
||||
};
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* L.TileLayer.WMS is used for putting WMS tile layers on the map.
|
||||
*/
|
||||
|
||||
L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
defaultWmsParams: {
|
||||
@ -14,7 +18,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this._url = url;
|
||||
|
||||
var wmsParams = L.Util.extend({}, this.defaultWmsParams);
|
||||
var wmsParams = L.extend({}, this.defaultWmsParams);
|
||||
|
||||
if (options.detectRetina && L.Browser.retina) {
|
||||
wmsParams.width = wmsParams.height = this.options.tileSize * 2;
|
||||
@ -31,7 +35,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
this.wmsParams = wmsParams;
|
||||
|
||||
L.Util.setOptions(this, options);
|
||||
L.setOptions(this, options);
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
@ -44,26 +48,28 @@ L.TileLayer.WMS = L.TileLayer.extend({
|
||||
|
||||
getTileUrl: function (tilePoint, zoom) { // (Point, Number) -> String
|
||||
|
||||
this._adjustTilePoint(tilePoint);
|
||||
|
||||
var map = this._map,
|
||||
crs = map.options.crs,
|
||||
tileSize = this.options.tileSize,
|
||||
crs = map.options.crs,
|
||||
tileSize = this.options.tileSize,
|
||||
|
||||
nwPoint = tilePoint.multiplyBy(tileSize),
|
||||
sePoint = nwPoint.add(new L.Point(tileSize, tileSize)),
|
||||
nwPoint = tilePoint.multiplyBy(tileSize),
|
||||
sePoint = nwPoint.add(new L.Point(tileSize, tileSize)),
|
||||
|
||||
nw = crs.project(map.unproject(nwPoint, zoom)),
|
||||
se = crs.project(map.unproject(sePoint, zoom)),
|
||||
nw = crs.project(map.unproject(nwPoint, zoom)),
|
||||
se = crs.project(map.unproject(sePoint, zoom)),
|
||||
|
||||
bbox = [nw.x, se.y, se.x, nw.y].join(','),
|
||||
bbox = [nw.x, se.y, se.x, nw.y].join(','),
|
||||
|
||||
url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)});
|
||||
url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)});
|
||||
|
||||
return url + L.Util.getParamString(this.wmsParams) + "&bbox=" + bbox;
|
||||
return url + L.Util.getParamString(this.wmsParams, url) + "&bbox=" + bbox;
|
||||
},
|
||||
|
||||
setParams: function (params, noRedraw) {
|
||||
|
||||
L.Util.extend(this.wmsParams, params);
|
||||
L.extend(this.wmsParams, params);
|
||||
|
||||
if (!noRedraw) {
|
||||
this.redraw();
|
||||
|
@ -28,7 +28,7 @@ L.TileLayer = L.Class.extend({
|
||||
},
|
||||
|
||||
initialize: function (url, options) {
|
||||
options = L.Util.setOptions(this, options);
|
||||
options = L.setOptions(this, options);
|
||||
|
||||
// detecting retina displays, adjusting tileSize and zoom levels
|
||||
if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {
|
||||
@ -81,7 +81,7 @@ L.TileLayer = L.Class.extend({
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
map._panes.tilePane.removeChild(this._container);
|
||||
this._container.parentNode.removeChild(this._container);
|
||||
|
||||
map.off({
|
||||
'viewreset': this._resetCallback,
|
||||
@ -166,11 +166,11 @@ L.TileLayer = L.Class.extend({
|
||||
|
||||
_setAutoZIndex: function (pane, compare) {
|
||||
|
||||
var layers = pane.getElementsByClassName('leaflet-layer'),
|
||||
edgeZIndex = -compare(Infinity, -Infinity), // -Ifinity for max, Infinity for min
|
||||
zIndex;
|
||||
var layers = pane.children,
|
||||
edgeZIndex = -compare(Infinity, -Infinity), // -Infinity for max, Infinity for min
|
||||
zIndex, i, len;
|
||||
|
||||
for (var i = 0, len = layers.length; i < len; i++) {
|
||||
for (i = 0, len = layers.length; i < len; i++) {
|
||||
|
||||
if (layers[i] !== this._container) {
|
||||
zIndex = parseInt(layers[i].style.zIndex, 10);
|
||||
@ -181,7 +181,8 @@ L.TileLayer = L.Class.extend({
|
||||
}
|
||||
}
|
||||
|
||||
this._container.style.zIndex = isFinite(edgeZIndex) ? edgeZIndex + compare(1, -1) : '';
|
||||
this.options.zIndex = this._container.style.zIndex =
|
||||
(isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1);
|
||||
},
|
||||
|
||||
_updateOpacity: function () {
|
||||
@ -189,7 +190,7 @@ L.TileLayer = L.Class.extend({
|
||||
|
||||
// stupid webkit hack to force redrawing of tiles
|
||||
var i,
|
||||
tiles = this._tiles;
|
||||
tiles = this._tiles;
|
||||
|
||||
if (L.Browser.webkit) {
|
||||
for (i in tiles) {
|
||||
@ -221,10 +222,9 @@ L.TileLayer = L.Class.extend({
|
||||
},
|
||||
|
||||
_reset: function (clearOldContainer) {
|
||||
var key,
|
||||
tiles = this._tiles;
|
||||
var tiles = this._tiles;
|
||||
|
||||
for (key in tiles) {
|
||||
for (var key in tiles) {
|
||||
if (tiles.hasOwnProperty(key)) {
|
||||
this.fire('tileunload', {tile: tiles[key]});
|
||||
}
|
||||
@ -244,11 +244,12 @@ L.TileLayer = L.Class.extend({
|
||||
this._initContainer();
|
||||
},
|
||||
|
||||
_update: function (e) {
|
||||
if (this._map._panTransition && this._map._panTransition._inProgress) { return; }
|
||||
_update: function () {
|
||||
|
||||
var bounds = this._map.getPixelBounds(),
|
||||
zoom = this._map.getZoom(),
|
||||
if (!this._map) { return; }
|
||||
|
||||
var bounds = this._map.getPixelBounds(),
|
||||
zoom = this._map.getZoom(),
|
||||
tileSize = this.options.tileSize;
|
||||
|
||||
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
|
||||
@ -256,12 +257,14 @@ L.TileLayer = L.Class.extend({
|
||||
}
|
||||
|
||||
var nwTilePoint = new L.Point(
|
||||
Math.floor(bounds.min.x / tileSize),
|
||||
Math.floor(bounds.min.y / tileSize)),
|
||||
seTilePoint = new L.Point(
|
||||
Math.floor(bounds.max.x / tileSize),
|
||||
Math.floor(bounds.max.y / tileSize)),
|
||||
tileBounds = new L.Bounds(nwTilePoint, seTilePoint);
|
||||
Math.floor(bounds.min.x / tileSize),
|
||||
Math.floor(bounds.min.y / tileSize)),
|
||||
|
||||
seTilePoint = new L.Point(
|
||||
Math.floor(bounds.max.x / tileSize),
|
||||
Math.floor(bounds.max.y / tileSize)),
|
||||
|
||||
tileBounds = new L.Bounds(nwTilePoint, seTilePoint);
|
||||
|
||||
this._addTilesFromCenterOut(tileBounds);
|
||||
|
||||
@ -272,7 +275,7 @@ L.TileLayer = L.Class.extend({
|
||||
|
||||
_addTilesFromCenterOut: function (bounds) {
|
||||
var queue = [],
|
||||
center = bounds.getCenter();
|
||||
center = bounds.getCenter();
|
||||
|
||||
var j, i, point;
|
||||
|
||||
@ -353,11 +356,13 @@ L.TileLayer = L.Class.extend({
|
||||
if (this.options.reuseTiles) {
|
||||
L.DomUtil.removeClass(tile, 'leaflet-tile-loaded');
|
||||
this._unusedTiles.push(tile);
|
||||
|
||||
} else if (tile.parentNode === this._container) {
|
||||
this._container.removeChild(tile);
|
||||
}
|
||||
|
||||
if (!L.Browser.android) { //For https://github.com/CloudMade/Leaflet/issues/137
|
||||
// for https://github.com/CloudMade/Leaflet/issues/137
|
||||
if (!L.Browser.android) {
|
||||
tile.src = L.Util.emptyImageUrl;
|
||||
}
|
||||
|
||||
@ -370,10 +375,15 @@ L.TileLayer = L.Class.extend({
|
||||
// get unused tile - or create a new tile
|
||||
var tile = this._getTile();
|
||||
|
||||
// Chrome 20 layouts much faster with top/left (Verify with timeline, frames), Safari 5.1.7, iOS 5.1.1,
|
||||
// android browser (4.0) have display issues with top/left and requires transform instead
|
||||
// (other browsers don't currently care) - see debug/hacks/jitter.html for an example
|
||||
L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);
|
||||
/*
|
||||
Chrome 20 layouts much faster with top/left (verify with timeline, frames)
|
||||
Android 4 browser has display issues with top/left and requires transform instead
|
||||
Android 3 browser not tested
|
||||
Android 2 browser requires top/left or tiles disappear on load or first drag
|
||||
(reappear after zoom) https://github.com/CloudMade/Leaflet/issues/866
|
||||
(other browsers don't currently care) - see debug/hacks/jitter.html for an example
|
||||
*/
|
||||
L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome || L.Browser.android23);
|
||||
|
||||
this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
|
||||
|
||||
@ -387,7 +397,7 @@ L.TileLayer = L.Class.extend({
|
||||
_getZoomForUrl: function () {
|
||||
|
||||
var options = this.options,
|
||||
zoom = this._map.getZoom();
|
||||
zoom = this._map.getZoom();
|
||||
|
||||
if (options.zoomReverse) {
|
||||
zoom = options.maxZoom - zoom;
|
||||
@ -398,7 +408,7 @@ L.TileLayer = L.Class.extend({
|
||||
|
||||
_getTilePos: function (tilePoint) {
|
||||
var origin = this._map.getPixelOrigin(),
|
||||
tileSize = this.options.tileSize;
|
||||
tileSize = this.options.tileSize;
|
||||
|
||||
return tilePoint.multiplyBy(tileSize).subtract(origin);
|
||||
},
|
||||
@ -408,7 +418,7 @@ L.TileLayer = L.Class.extend({
|
||||
getTileUrl: function (tilePoint) {
|
||||
this._adjustTilePoint(tilePoint);
|
||||
|
||||
return L.Util.template(this._url, L.Util.extend({
|
||||
return L.Util.template(this._url, L.extend({
|
||||
s: this._getSubdomain(tilePoint),
|
||||
z: this._getZoomForUrl(),
|
||||
x: tilePoint.x,
|
||||
@ -442,11 +452,8 @@ L.TileLayer = L.Class.extend({
|
||||
|
||||
_createTileProto: function () {
|
||||
var img = this._tileImg = L.DomUtil.create('img', 'leaflet-tile');
|
||||
img.style.width = img.style.height = this.options.tileSize + 'px';
|
||||
img.galleryimg = 'no';
|
||||
|
||||
var tileSize = this.options.tileSize;
|
||||
img.style.width = tileSize + 'px';
|
||||
img.style.height = tileSize + 'px';
|
||||
},
|
||||
|
||||
_getTile: function () {
|
||||
@ -458,9 +465,8 @@ L.TileLayer = L.Class.extend({
|
||||
return this._createTile();
|
||||
},
|
||||
|
||||
_resetTile: function (tile) {
|
||||
// Override if data stored on a tile needs to be cleaned up before reuse
|
||||
},
|
||||
// Override if data stored on a tile needs to be cleaned up before reuse
|
||||
_resetTile: function (/*tile*/) {},
|
||||
|
||||
_createTile: function () {
|
||||
var tile = this._tileImg.cloneNode(false);
|
||||
@ -483,7 +489,7 @@ L.TileLayer = L.Class.extend({
|
||||
}
|
||||
},
|
||||
|
||||
_tileOnLoad: function (e) {
|
||||
_tileOnLoad: function () {
|
||||
var layer = this._layer;
|
||||
|
||||
//Only if we are loading an actual image
|
||||
@ -499,7 +505,7 @@ L.TileLayer = L.Class.extend({
|
||||
layer._tileLoaded();
|
||||
},
|
||||
|
||||
_tileOnError: function (e) {
|
||||
_tileOnError: function () {
|
||||
var layer = this._layer;
|
||||
|
||||
layer.fire('tileerror', {
|
||||
|
@ -26,21 +26,19 @@ L.Circle = L.Path.extend({
|
||||
|
||||
projectLatlngs: function () {
|
||||
var lngRadius = this._getLngRadius(),
|
||||
latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius, true),
|
||||
point2 = this._map.latLngToLayerPoint(latlng2);
|
||||
latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius),
|
||||
point2 = this._map.latLngToLayerPoint(latlng2);
|
||||
|
||||
this._point = this._map.latLngToLayerPoint(this._latlng);
|
||||
this._radius = Math.max(Math.round(this._point.x - point2.x), 1);
|
||||
},
|
||||
|
||||
getBounds: function () {
|
||||
var map = this._map,
|
||||
delta = this._radius * Math.cos(Math.PI / 4),
|
||||
point = map.project(this._latlng),
|
||||
swPoint = new L.Point(point.x - delta, point.y + delta),
|
||||
nePoint = new L.Point(point.x + delta, point.y - delta),
|
||||
sw = map.unproject(swPoint),
|
||||
ne = map.unproject(nePoint);
|
||||
var lngRadius = this._getLngRadius(),
|
||||
latRadius = (this._mRadius / 40075017) * 360,
|
||||
latlng = this._latlng,
|
||||
sw = new L.LatLng(latlng.lat - latRadius, latlng.lng - lngRadius),
|
||||
ne = new L.LatLng(latlng.lat + latRadius, latlng.lng + lngRadius);
|
||||
|
||||
return new L.LatLngBounds(sw, ne);
|
||||
},
|
||||
@ -51,7 +49,7 @@ L.Circle = L.Path.extend({
|
||||
|
||||
getPathString: function () {
|
||||
var p = this._point,
|
||||
r = this._radius;
|
||||
r = this._radius;
|
||||
|
||||
if (this._checkIfEmpty()) {
|
||||
return '';
|
||||
@ -59,8 +57,8 @@ L.Circle = L.Path.extend({
|
||||
|
||||
if (L.Browser.svg) {
|
||||
return "M" + p.x + "," + (p.y - r) +
|
||||
"A" + r + "," + r + ",0,1,1," +
|
||||
(p.x - 0.1) + "," + (p.y - r) + " z";
|
||||
"A" + r + "," + r + ",0,1,1," +
|
||||
(p.x - 0.1) + "," + (p.y - r) + " z";
|
||||
} else {
|
||||
p._round();
|
||||
r = Math.round(r);
|
||||
@ -72,11 +70,14 @@ L.Circle = L.Path.extend({
|
||||
return this._mRadius;
|
||||
},
|
||||
|
||||
_getLngRadius: function () {
|
||||
var equatorLength = 40075017,
|
||||
hLength = equatorLength * Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);
|
||||
// TODO Earth hardcoded, move into projection code!
|
||||
|
||||
return (this._mRadius / hLength) * 360;
|
||||
_getLatRadius: function () {
|
||||
return (this._mRadius / 40075017) * 360;
|
||||
},
|
||||
|
||||
_getLngRadius: function () {
|
||||
return this._getLatRadius() / Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);
|
||||
},
|
||||
|
||||
_checkIfEmpty: function () {
|
||||
@ -84,11 +85,11 @@ L.Circle = L.Path.extend({
|
||||
return false;
|
||||
}
|
||||
var vp = this._map._pathViewport,
|
||||
r = this._radius,
|
||||
p = this._point;
|
||||
r = this._radius,
|
||||
p = this._point;
|
||||
|
||||
return p.x - r > vp.max.x || p.y - r > vp.max.y ||
|
||||
p.x + r < vp.min.x || p.y + r < vp.min.y;
|
||||
p.x + r < vp.min.x || p.y + r < vp.min.y;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -16,6 +16,11 @@ L.CircleMarker = L.Circle.extend({
|
||||
projectLatlngs: function () {
|
||||
this._point = this._map.latLngToLayerPoint(this._latlng);
|
||||
},
|
||||
|
||||
_updateStyle : function () {
|
||||
L.Circle.prototype._updateStyle.call(this);
|
||||
this.setRadius(this.options.radius);
|
||||
},
|
||||
|
||||
setRadius: function (radius) {
|
||||
this._radius = radius;
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
(function () {
|
||||
function createMulti(Klass) {
|
||||
|
||||
return L.FeatureGroup.extend({
|
||||
|
||||
initialize: function (latlngs, options) {
|
||||
this._layers = {};
|
||||
this._options = options;
|
||||
@ -12,7 +14,8 @@
|
||||
},
|
||||
|
||||
setLatLngs: function (latlngs) {
|
||||
var i = 0, len = latlngs.length;
|
||||
var i = 0,
|
||||
len = latlngs.length;
|
||||
|
||||
this.eachLayer(function (layer) {
|
||||
if (i < len) {
|
||||
|
@ -1,30 +1,46 @@
|
||||
/*
|
||||
* Popup extension to L.Path (polylines, polygons, circles), adding bindPopup method.
|
||||
* Popup extension to L.Path (polylines, polygons, circles), adding popup-related methods.
|
||||
*/
|
||||
|
||||
L.Path.include({
|
||||
|
||||
bindPopup: function (content, options) {
|
||||
|
||||
if (!this._popup || this._popup.options !== options) {
|
||||
if (!this._popup || options) {
|
||||
this._popup = new L.Popup(options, this);
|
||||
}
|
||||
|
||||
this._popup.setContent(content);
|
||||
|
||||
if (!this._openPopupAdded) {
|
||||
this.on('click', this._openPopup, this);
|
||||
this._openPopupAdded = true;
|
||||
if (!this._popupHandlersAdded) {
|
||||
this
|
||||
.on('click', this._openPopup, this)
|
||||
.on('remove', this.closePopup, this);
|
||||
|
||||
this._popupHandlersAdded = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
unbindPopup: function () {
|
||||
if (this._popup) {
|
||||
this._popup = null;
|
||||
this
|
||||
.off('click', this._openPopup)
|
||||
.off('remove', this.closePopup);
|
||||
|
||||
this._popupHandlersAdded = false;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
openPopup: function (latlng) {
|
||||
|
||||
if (this._popup) {
|
||||
// open the popup from one of the path's points if not specified
|
||||
latlng = latlng || this._latlng ||
|
||||
this._latlngs[Math.floor(this._latlngs.length / 2)];
|
||||
this._latlngs[Math.floor(this._latlngs.length / 2)];
|
||||
|
||||
this._openPopup({latlng: latlng});
|
||||
}
|
||||
@ -32,6 +48,13 @@ L.Path.include({
|
||||
return this;
|
||||
},
|
||||
|
||||
closePopup: function () {
|
||||
if (this._popup) {
|
||||
this._popup._close();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
_openPopup: function (e) {
|
||||
this._popup.setLatLng(e.latlng);
|
||||
this._map.openPopup(this._popup);
|
||||
|