Merge branch 'master' into gh-pages-master

This commit is contained in:
Vladimir Agafonkin 2013-01-16 17:17:07 +02:00
commit 1e5d10c5e7
97 changed files with 2675 additions and 1021 deletions

View File

@ -7,72 +7,123 @@ 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
* 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/CloudMade/Leaflet/pull/1076) [#871](https://github.com/CloudMade/Leaflet/issues/871)
##### 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 **zoom control design** to look better, be more design-neutral and in line with other controls, making it easier to fit different website designs. Replaced +/- images with text.
* Improved **dragging cursors** in Chrome, Safari and Firefox (now grabbing hand cursors are used).
* Improved zoom control to zoom by 3 levels if you hold shift while clicking on a button.
* Improved scroll wheel zoom to be more responsive.
* **Improved dragging cursors** in Chrome, Safari and Firefox (now grabbing hand cursors are used).
* Improved zoom animation curve for a better feel overall.
* Improved fallback control styles for IE6-8.
* Improved scroll wheel zoom to be more responsive.
* Improved panning animation performance in IE6-8.
* Improved vectors updating/removing performance on Canvas backend even more (by [@danzel](https://github.com/danzel)). [#961](https://github.com/CloudMade/Leaflet/pull/961)
##### 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/CloudMade/Leaflet/pull/972)
* 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/CloudMade/Leaflet/issues/834) [#1033](https://github.com/CloudMade/Leaflet/pull/1033)
* 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` `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/CloudMade/Leaflet/pull/914) [#920](https://github.com/CloudMade/Leaflet/issues/920)
* 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 `Map` `whenReady` method (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1063](https://github.com/CloudMade/Leaflet/pull/1063)
* Added `FeatureGroup` `layeradd` and `layerremove` events (by [@jacobtoye](https://github.com/jacobtoye)). [#1122](https://github.com/CloudMade/Leaflet/issues/1122)
* Added `Control.Layers` `baselayerchange` event (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1064](https://github.com/CloudMade/Leaflet/pull/1064)
* Improved `Control.Layers` to support HTML in layer names (by [@aparshin](https://github.com/aparshin)). [#1055](https://github.com/CloudMade/Leaflet/pull/1055) [#1099](https://github.com/CloudMade/Leaflet/issues/1099)
* Removed `Browser` `ua`, `ie`, `gecko`, `opera` properties (no longer needed).
* Added `CRS.Simple` to the list of built-in CRS. It was added earlier but not included in the build.
* 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/CloudMade/Leaflet/pull/1099) [#1095](https://github.com/CloudMade/Leaflet/issues/1095)
* 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 with shift-clicking on a zoom button leading to unexpected result.
* 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/CloudMade/Leaflet/pull/963) [#959](https://github.com/CloudMade/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/CloudMade/Leaflet/issues/965) [#968](https://github.com/CloudMade/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/CloudMade/Leaflet/issues/1022) [#1023](https://github.com/CloudMade/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/CloudMade/Leaflet/pull/1027)
* Fixed `Circle` `getBounds` to return correct bounds and work without adding the circle to a map. [#1068](https://github.com/CloudMade/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/CloudMade/Leaflet/pull/1098) [#1094](https://github.com/CloudMade/Leaflet/issues/1094)
* 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 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/CloudMade/Leaflet/issues/892) [#893](https://github.com/CloudMade/Leaflet/pull/893)
* Fixed compatibility with SmoothWheel extension for Firefox (by [@waldir](https://github.com/waldir)). [#1011](https://github.com/CloudMade/Leaflet/pull/1011)
* Fixed a bug with popup layout in IE6-7 (by [@danzel](https://github.com/danzel)). [#1117](https://github.com/CloudMade/Leaflet/issues/1117)
* Fixed a bug with incorrect box zoom opacity in IE6-7 (by [@jacobtoye](https://github.com/jacobtoye)). [#1072](https://githubcom/CloudMade/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/CloudMade/Leaflet/pull/1071)
* 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)
## 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/CloudMade/Leaflet/pull/1007)
* Fixed a bug with **wonky zoom animation in Chrome 23+** (by [@danzel](https://github.com/danzel)). [#1060](https://github.com/CloudMade/Leaflet/pull/1060) [#1056](https://github.com/CloudMade/Leaflet/issues/1056)
* 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)
@ -82,26 +133,26 @@ An in-progress version being developed on the master branch.
* 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/CloudMade/Leaflet/pull/857)
* 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/CloudMade/Leaflet/pull/868)
* 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/CloudMade/Leaflet/issues/869)
* 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)
@ -116,26 +167,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
@ -173,100 +224,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)
@ -279,15 +330,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).
@ -295,37 +346,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
@ -341,54 +392,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.
@ -408,14 +459,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`.
@ -437,40 +488,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)

View File

@ -8,37 +8,59 @@ Contributing to Leaflet
## 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/CloudMade/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.
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/CloudMade/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.
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:
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.
* *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.
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/CloudMade/Leaflet/issues) or [Leaflet UserVoice](http://leaflet.uservoice.com/)), and then ask yourself two questions:
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?
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).
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:
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
@ -50,23 +72,36 @@ You can build minified Leaflet by running `jake` (it will be built from source i
### 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 &mdash; it will get you started quickly.
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 &mdash; 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 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.
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 problems merging the pull request. These files are only commited in the `master` branch of the main Leaflet repository.
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 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/CloudMade/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.
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:
@ -75,10 +110,15 @@ If you need to make edits in a local repository to see how it looks in the proce
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.
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.
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, &mdash; helping Leaflet and its community actually makes you AWESOME. Join [this approved list of awesome people](https://github.com/CloudMade/Leaflet/graphs/contributors) and help us push the limits of what's possible with online maps!
Not only are we grateful for any contributions, &mdash; 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!

View File

@ -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://leafletjs.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
View File

@ -1,22 +1,23 @@
Copyright (c) 2012, 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.

View File

@ -1,20 +1,28 @@
<img src="http://leafletjs.com/docs/images/logo.png" alt="Leaflet" />
Leaflet is a modern open-source JavaScript library for **mobile-friendly interactive maps**. It is developed by [Vladimir Agafonkin][] of [CloudMade][] 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.
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.
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.
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.
For more information, check out the [official website][].
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!
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!
[Vladimir Agafonkin]: http://agafonkin.com/en
[CloudMade]: http://cloudmade.com
[contributors]: https://github.com/CloudMade/Leaflet/graphs/contributors
[contributors]: https://github.com/Leaflet/Leaflet/graphs/contributors
[features]: http://leafletjs.com/features.html
[plugins]: http://leafletjs.com/plugins.html
[well-documented]: reference.html "Leaflet API reference"
[source code]: https://github.com/CloudMade/Leaflet "Leaflet GitHub repository"
[hosted on GitHub]: http://github.com/CloudMade/Leaflet
[contribute]: https://github.com/CloudMade/Leaflet/blob/master/CONTRIBUTING.md "A guide to contributing to Leaflet"
[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

View File

@ -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.replace(/\r\n?/g, '\n').length - oldContent.replace(/\r\n?/g, '\n').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);
}
};

View File

@ -54,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.'
},
@ -65,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).'
},
@ -83,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'
},
@ -100,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.'
},

View File

@ -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;
};

View File

@ -38,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',
@ -128,3 +129,7 @@ function getRandomLatLng(map) {
southWest.lat + latSpan * Math.random(),
southWest.lng + lngSpan * Math.random());
}
function logEvent(e) {
console.log(e.type);
}

View 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
View 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 &copy; 2011 OpenStreetMap contributors, Imagery &copy; 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>

View 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>

View 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>

View 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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
dist/images/marker-icon@2x.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

907
dist/leaflet-src.js vendored

File diff suppressed because it is too large Load Diff

81
dist/leaflet.css vendored
View File

@ -15,6 +15,7 @@
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
@ -184,23 +185,58 @@
/* 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-control-zoom {
.leaflet-container .leaflet-control-zoom {
margin-left: 13px;
margin-top: 12px;
box-shadow: 0 0 8px #666;
border: 1px solid #777;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.leaflet-control-zoom a {
width: 23px;
height: 23px;
background-color: rgba(255, 255, 255, 0.8);
width: 22px;
height: 22px;
text-align: center;
text-decoration: none;
color: black;
@ -216,15 +252,15 @@
color: #777;
}
.leaflet-control-zoom-in {
border-bottom: 1px solid #aaa;
font: bold 18px/23px Arial, Helvetica, sans-serif;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
font: bold 18px/24px Arial, Helvetica, sans-serif;
}
.leaflet-control-zoom-out {
font: bold 25px/20px Tahoma, Verdana, sans-serif;
-webkit-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
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-touch .leaflet-control-zoom a {
@ -243,7 +279,7 @@
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 7px #999;
box-shadow: 0 1px 7px rgba(0,0,0,0.4);
background: #f8f8f9;
-webkit-border-radius: 8px;
border-radius: 8px;
@ -311,16 +347,20 @@
border: 2px solid #777;
border-top: none;
color: black;
line-height: 1;
line-height: 1.1;
padding: 2px 5px 1px;
font-size: 10px;
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;
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;
@ -333,7 +373,7 @@
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-control-zoom {
border: 3px solid #999;
border: 4px solid rgba(0,0,0,0.3);
}
@ -393,6 +433,7 @@
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover {
color: #999;

10
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,11 +11,13 @@ describe("Control.Layers", function () {
layers = L.control.layers(baseLayers).addTo(map),
spy = jasmine.createSpy();
map.on('baselayerchange', spy);
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
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"]);
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 () {
@ -29,4 +31,37 @@ describe("Control.Layers", function () {
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();
});
});
});

View File

@ -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
});
});

View File

@ -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
});
});

View File

@ -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 longitude 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 longitude 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);
});
})
});

View File

@ -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);
});
});
});
});
});

View File

@ -10,7 +10,7 @@ describe("Map", function () {
map.setView([0, 0], 1);
expect(spy).toHaveBeenCalled();
})
});
});
describe("when the map has already been loaded", function () {
@ -27,7 +27,8 @@ describe("Map", function () {
});
describe("#getBounds", function () {
it("is safe to call from within a moveend callback during initial load (#1027)", 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);
@ -38,4 +39,16 @@ describe("Map", function () {
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);
});
});
});

View File

@ -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 + '') {

View File

@ -1,3 +1,7 @@
/*
* L.Control.Attribution is used for displaying attribution on the map (added by default).
*/
L.Control.Attribution = L.Control.extend({
options: {
position: 'bottomright',

View File

@ -1,3 +1,7 @@
/*
* L.Control.Layers is a control to allow users to switch between different layers on the map.
*/
L.Control.Layers = L.Control.extend({
options: {
collapsed: true,
@ -10,6 +14,7 @@ L.Control.Layers = L.Control.extend({
this._layers = {};
this._lastZIndex = 0;
this._handlingClick = false;
for (var i in baseLayers) {
if (baseLayers.hasOwnProperty(i)) {
@ -28,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();
@ -56,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);
}
@ -132,6 +148,14 @@ 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) {
@ -173,6 +197,8 @@ L.Control.Layers = L.Control.extend({
var container = obj.overlay ? this._overlaysList : this._baseLayersList;
container.appendChild(label);
return label;
},
_onInputClick: function () {
@ -181,6 +207,8 @@ L.Control.Layers = L.Control.extend({
inputsLen = inputs.length,
baseLayer;
this._handlingClick = true;
for (i = 0; i < inputsLen; i++) {
input = inputs[i];
obj = this._layers[input.layerId];
@ -196,8 +224,11 @@ L.Control.Layers = L.Control.extend({
}
if (baseLayer) {
this._map.setZoom(this._map.getZoom());
this._map.fire('baselayerchange', {layer: baseLayer});
}
this._handlingClick = false;
},
_expand: function () {

View File

@ -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',

View File

@ -1,20 +1,41 @@
/*
* 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._map = map;
this._createButton('+', 'Zoom in', className + '-in', container, this._zoomIn, this);
this._createButton('-', 'Zoom out', className + '-out', container, this._zoomOut, this);
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;
},
onRemove: function (map) {
map.off('zoomend', this._updateDisabled, this);
},
_zoomIn: function (e) {
this._map.zoomIn(e.shiftKey ? 3 : 1);
},
@ -29,14 +50,31 @@ L.Control.Zoom = L.Control.extend({
link.href = '#';
link.title = title;
var stop = L.DomEvent.stopPropagation;
L.DomEvent
.on(link, 'click', L.DomEvent.stopPropagation)
.on(link, 'mousedown', L.DomEvent.stopPropagation)
.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);
}
}
});

View File

@ -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: {

4
src/copyright.js Normal file
View File

@ -0,0 +1,4 @@
/*
Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
(c) 2010-2013, Vladimir Agafonkin, CloudMade
*/

View File

@ -1,23 +1,26 @@
/*
* L.Browser handles different browser and feature detections for internal Leaflet use.
*/
(function () {
var ie = !!window.ActiveXObject,
// http://tanalin.com/en/articles/ie-version-js/
ie6 = ie && !window.XMLHttpRequest,
ie7 = ie && !document.querySelector,
// terrible browser detection to work around Safari / iOS / Android browser bugs
// see TileLayer._addTile and debug/hacks/jitter.html
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,
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)").matches)),
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),
@ -57,6 +60,7 @@
L.Browser = {
ie: ie,
ie6: ie6,
ie7: ie7,
webkit: webkit,

View File

@ -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
@ -49,6 +57,25 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ {
// mix given properties into the prototype
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;
};
@ -58,6 +85,19 @@ L.Class.include = function (props) {
L.extend(this.prototype, props);
};
// merge new default options to the Class
L.Class.mergeOptions = function (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);
};

View File

@ -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';

View File

@ -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) {

View File

@ -1,5 +1,5 @@
/*
* L.Util is a namespace for various utility functions.
* L.Util contains various utility functions used throughout Leaflet code.
*/
L.Util = {
@ -77,14 +77,14 @@ L.Util = {
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) {
@ -97,6 +97,10 @@ L.Util = {
});
},
isArray: function (obj) {
return (Object.prototype.toString.call(obj) === '[object Array]');
},
emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
};

View File

@ -1,3 +1,7 @@
/*
* Extends the event handling code with double tap support for mobile browsers.
*/
L.extend(L.DomEvent, {
_touchstart: L.Browser.msTouch ? 'MSPointerDown' : 'touchstart',
@ -33,7 +37,9 @@ L.extend(L.DomEvent, {
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) {
@ -47,14 +53,13 @@ L.extend(L.DomEvent, {
//Work around .type being readonly with MSPointer* events
var newTouch = { },
prop;
for (var i in touch) {
if (true) { //Make JSHint happy, we want to copy all properties
prop = touch[i];
if (typeof prop === 'function') {
newTouch[i] = prop.bind(touch);
} else {
newTouch[i] = prop;
}
prop = touch[i];
if (typeof prop === 'function') {
newTouch[i] = prop.bind(touch);
} else {
newTouch[i] = prop;
}
}
touch = newTouch;

View File

@ -1,3 +1,7 @@
/*
* Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
*/
L.extend(L.DomEvent, {
_msTouches: [],

View File

@ -18,10 +18,12 @@ L.DomEvent = {
if (L.Browser.msTouch && type.indexOf('touch') === 0) {
return this.addMsTouchListener(obj, type, handler, id);
} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
return this.addDoubleTapListener(obj, handler, id);
}
if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
this.addDoubleTapListener(obj, handler, id);
}
} else if ('addEventListener' in obj) {
if ('addEventListener' in obj) {
if (type === 'mousewheel') {
obj.addEventListener('DOMMouseScroll', handler, false);
@ -99,8 +101,11 @@ L.DomEvent = {
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);
},
@ -160,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;
@ -176,7 +180,6 @@ L.DomEvent = {
}
return e;
}
/*jshint noarg:false */
};
L.DomEvent.on = L.DomEvent.addListener;

View File

@ -35,6 +35,11 @@ L.DomUtil = {
do {
top += el.offsetTop || 0;
left += el.offsetLeft || 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; }
@ -100,7 +105,7 @@ L.DomUtil = {
document.selection.empty();
}
if (!this._onselectstart) {
this._onselectstart = document.onselectstart;
this._onselectstart = document.onselectstart || null;
document.onselectstart = L.Util.falseFn;
}
},
@ -221,8 +226,11 @@ L.DomUtil = {
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(
['transition', 'webkitTransition', 'OTransition', 'MozTransition', 'msTransition']);
['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);
L.DomUtil.TRANSITION_END =
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?

View File

@ -6,9 +6,17 @@ 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
},
@ -21,14 +29,18 @@ L.Draggable = L.Class.extend({
enable: function () {
if (this._enabled) { return; }
L.DomEvent.on(this._dragStartTarget, L.Draggable.START, this._onDown, this);
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
}
this._enabled = true;
},
disable: function () {
if (!this._enabled) { return; }
L.DomEvent.off(this._dragStartTarget, L.Draggable.START, this._onDown);
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
}
this._enabled = false;
this._moved = false;
},
@ -76,8 +88,8 @@ L.Draggable = L.Class.extend({
}, this), 1000);
}
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) {
@ -138,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

View File

@ -1,8 +1,8 @@
/*
L.LatLng represents a geographical point with latitude and longitude 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);
@ -10,11 +10,6 @@ L.LatLng = function (rawLat, rawLng, noWrap) { // (Number, Number[, Boolean])
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 longitude into -180..180
}
this.lat = lat;
this.lng = lng;
};
@ -31,17 +26,21 @@ 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 (precision) { // -> String
toString: function (precision) { // (Number) -> String
return 'LatLng(' +
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);
@ -57,19 +56,30 @@ L.LatLng.prototype = {
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);
};

View File

@ -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);
@ -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
@ -128,7 +128,7 @@ L.LatLngBounds = L.Class.extend({
isValid: function () {
return !!(this._southWest && this._northEast);
}
});
};
//TODO International date line?

View File

@ -1,3 +1,7 @@
/*
* L.CRS.EPSG3857 (Spherical Mercator) is the most common CRS for web mapping
* and is used by Leaflet by default.
*/
L.CRS.EPSG3857 = L.extend({}, L.CRS, {
code: 'EPSG:3857',

View File

@ -1,3 +1,6 @@
/*
* L.CRS.EPSG4326 is a CRS popular among advanced GIS specialists.
*/
L.CRS.EPSG4326 = L.extend({}, L.CRS, {
code: 'EPSG:4326',

View File

@ -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.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);
}
});

View File

@ -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

View File

@ -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);
}
};

View File

@ -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,
@ -47,6 +51,6 @@ L.Projection.Mercator = {
phi += dphi;
}
return new L.LatLng(phi * d, lng, true);
return new L.LatLng(phi * d, lng);
}
};

View File

@ -1,3 +1,6 @@
/*
* Spherical Mercator is the most popular map projection, used by EPSG:3857 CRS used by default.
*/
L.Projection.SphericalMercator = {
MAX_LATITUDE: 85.0511287798,
@ -19,7 +22,6 @@ L.Projection.SphericalMercator = {
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);
}
};

View File

@ -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);
@ -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;
@ -82,7 +85,7 @@ L.Bounds = L.Class.extend({
isValid: function () {
return !!(this.min && this.max);
}
});
};
L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[])
if (!a || a instanceof L.Bounds) {

View File

@ -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.
@ -94,16 +96,11 @@ 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,
codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
codeB = this._getBitCode(b, bounds),
codeOut, p, newCode;
@ -169,8 +166,6 @@ 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,

View File

@ -84,6 +84,11 @@ L.Point.prototype = {
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) + ', ' +
@ -95,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)) {

View File

@ -11,9 +11,7 @@ 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,
var clippedPoints,
edges = [1, 4, 2, 8],
i, j, k,
a, b,
@ -55,5 +53,3 @@ L.PolyUtil.clipPolygon = function (points, bounds) {
return points;
};
/*jshint bitwise:true */

View File

@ -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);
}
});
};

344
src/images/marker.svg Normal file
View 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

View File

@ -1,5 +1,6 @@
/*
* 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({
@ -19,7 +20,7 @@ L.FeatureGroup = L.LayerGroup.extend({
L.LayerGroup.prototype.addLayer.call(this, layer);
if (this._popupContent && layer.bindPopup) {
layer.bindPopup(this._popupContent);
layer.bindPopup(this._popupContent, this._popupOptions);
}
return this.fire('layeradd', {layer: layer});
@ -38,9 +39,10 @@ L.FeatureGroup = L.LayerGroup.extend({
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) {

View File

@ -1,4 +1,9 @@
/*
* L.GeoJSON turns any GeoJSON data into a Leaflet layer.
*/
L.GeoJSON = L.FeatureGroup.extend({
initialize: function (geojson, options) {
L.setOptions(this, options);
@ -10,12 +15,15 @@ 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;
}
@ -27,6 +35,7 @@ L.GeoJSON = L.FeatureGroup.extend({
var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer);
layer.feature = geojson;
layer.defaultOptions = layer.options;
this.resetStyle(layer);
if (options.onEachFeature) {
@ -39,6 +48,9 @@ L.GeoJSON = L.FeatureGroup.extend({
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);
}
},
@ -91,13 +103,17 @@ L.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);
@ -111,7 +127,7 @@ L.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

View File

@ -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,
@ -97,8 +101,7 @@ L.ImageOverlay = L.Class.extend({
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));
origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale)));
image.style[L.DomUtil.TRANSFORM] =
L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
@ -107,7 +110,7 @@ L.ImageOverlay = L.Class.extend({
_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);

View File

@ -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({
@ -82,6 +83,10 @@ L.LayerGroup = L.Class.extend({
method.call(context, this._layers[i]);
}
}
},
setZIndex: function (zIndex) {
return this.invoke('setZIndex', zIndex);
}
});

View File

@ -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.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);
}
@ -109,7 +114,8 @@ L.Popup = L.Class.extend({
_initLayout: function () {
var prefix = 'leaflet-popup',
containerClass = 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;
@ -195,15 +201,15 @@ L.Popup = L.Class.extend({
if (!this._map) { return; }
var pos = this._map.latLngToLayerPoint(this._latlng),
is3d = L.Browser.any3d,
animated = this._animated,
offset = this.options.offset;
if (is3d) {
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';
@ -225,7 +231,7 @@ L.Popup = L.Class.extend({
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
if (L.Browser.any3d) {
if (this._animated) {
layerPos._add(L.DomUtil.getPosition(this._container));
}

View File

@ -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

View File

@ -1,3 +1,6 @@
/*
* L.Icon.Default is the blue marker icon used by default in Leaflet.
*/
L.Icon.Default = L.Icon.extend({
@ -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) {

View File

@ -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, 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)
*/
@ -83,6 +89,9 @@ L.Icon = L.Class.extend({
},
_getIconUrl: function (name) {
if (L.Browser.retina && this.options[name + 'RetinaUrl']) {
return this.options[name + 'RetinaUrl'];
}
return this.options[name + 'Url'];
}
});

View File

@ -26,14 +26,14 @@ L.Handler.MarkerDrag = L.Handler.extend({
return this._draggable && this._draggable._moved;
},
_onDragStart: function (e) {
_onDragStart: function () {
this._marker
.closePopup()
.fire('movestart')
.fire('dragstart');
},
_onDrag: function (e) {
_onDrag: function () {
var marker = this._marker,
shadow = marker._shadow,
iconPos = L.DomUtil.getPosition(marker._icon),

View File

@ -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({

View File

@ -62,12 +62,14 @@ L.Marker = L.Class.extend({
this.update();
this.fire('move', { latlng: this._latlng });
return this.fire('move', { latlng: this._latlng });
},
setZIndexOffset: function (offset) {
this.options.zIndexOffset = offset;
this.update();
return this;
},
setIcon: function (icon) {
@ -81,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 () {
@ -179,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);
@ -204,20 +211,31 @@ L.Marker = L.Class.extend({
_onMouseClick: function (e) {
var wasDragged = this.dragging && this.dragging.moved();
if (this.hasEventListeners(e.type) || wasDragged) {
L.DomEvent.stopPropagation(e);
}
if (wasDragged) { return; }
if (this._map.dragging && this._map.dragging.moved()) { 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);
}

View File

@ -1,3 +1,8 @@
/*
* 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
@ -43,7 +48,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({
}
},
drawTile: function (tile, tilePoint) {
drawTile: function (/*tile, tilePoint*/) {
// override with rendering code
},

View File

@ -1,3 +1,7 @@
/*
* L.TileLayer.WMS is used for putting WMS tile layers on the map.
*/
L.TileLayer.WMS = L.TileLayer.extend({
defaultWmsParams: {
@ -44,6 +48,8 @@ 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,
@ -58,7 +64,7 @@ L.TileLayer.WMS = L.TileLayer.extend({
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) {

View File

@ -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,7 +166,7 @@ L.TileLayer = L.Class.extend({
_setAutoZIndex: function (pane, compare) {
var layers = pane.getElementsByClassName('leaflet-layer'),
var layers = pane.children,
edgeZIndex = -compare(Infinity, -Infinity), // -Infinity for max, Infinity for min
zIndex, i, len;
@ -244,7 +244,7 @@ L.TileLayer = L.Class.extend({
this._initContainer();
},
_update: function (e) {
_update: function () {
if (!this._map) { return; }
@ -465,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);
@ -490,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
@ -506,7 +505,7 @@ L.TileLayer = L.Class.extend({
layer._tileLoaded();
},
_tileOnError: function (e) {
_tileOnError: function () {
var layer = this._layer;
layer.fire('tileerror', {

View File

@ -26,7 +26,7 @@ L.Circle = L.Path.extend({
projectLatlngs: function () {
var lngRadius = this._getLngRadius(),
latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius, true),
latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius),
point2 = this._map.latLngToLayerPoint(latlng2);
this._point = this._map.latLngToLayerPoint(this._latlng);

View File

@ -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;

View File

@ -1,5 +1,5 @@
/*
* 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({
@ -27,7 +27,7 @@ L.Path.include({
if (this._popup) {
this._popup = null;
this
.off('click', this.openPopup)
.off('click', this._openPopup)
.off('remove', this.closePopup);
this._popupHandlersAdded = false;

View File

@ -1,3 +1,7 @@
/*
* Extends L.Path with SVG-specific rendering code.
*/
L.Path.SVG_NS = 'http://www.w3.org/2000/svg';
L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect);
@ -159,13 +163,12 @@ L.Map.include({
}
},
_animatePathZoom: function (opt) {
var scale = this.getZoomScale(opt.zoom),
offset = this._getCenterOffset(opt.center),
translate = offset.multiplyBy(-scale)._add(this._pathViewport.min);
_animatePathZoom: function (e) {
var scale = this.getZoomScale(e.zoom),
offset = this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min);
this._pathRoot.style[L.DomUtil.TRANSFORM] =
L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') ';
L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') ';
this._pathZooming = true;
},

View File

@ -74,11 +74,15 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
stroke.weight = options.weight + 'px';
stroke.color = options.color;
stroke.opacity = options.opacity;
if (options.dashArray) {
stroke.dashStyle = options.dashArray.replace(/ *, */g, ' ');
stroke.dashStyle = options.dashArray instanceof Array ?
options.dashArray.join(' ') :
options.dashArray.replace(/ *, */g, ' ');
} else {
stroke.dashStyle = '';
}
} else if (stroke) {
container.removeChild(stroke);
this._stroke = null;
@ -91,6 +95,7 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
}
fill.color = options.fillColor || options.color;
fill.opacity = options.fillOpacity;
} else if (fill) {
container.removeChild(fill);
this._fill = null;

View File

@ -47,6 +47,8 @@ L.Path = L.Class.extend({
this._map._pathRoot.appendChild(this._container);
}
this.fire('add');
map.on({
'viewreset': this.projectLatlngs,
'moveend': this._updatePath
@ -61,6 +63,8 @@ L.Path = L.Class.extend({
onRemove: function (map) {
map._pathRoot.removeChild(this._container);
// Need to fire remove event before we set _map to null as the event hooks might need the object
this.fire('remove');
this._map = null;
if (L.Browser.vml) {
@ -69,8 +73,6 @@ L.Path = L.Class.extend({
this._fill = null;
}
this.fire('remove');
map.off({
'viewreset': this.projectLatlngs,
'moveend': this._updatePath

View File

@ -10,7 +10,7 @@ L.Polygon = L.Polyline.extend({
initialize: function (latlngs, options) {
L.Polyline.prototype.initialize.call(this, latlngs, options);
if (latlngs && (latlngs[0] instanceof Array) && (typeof latlngs[0][0] !== 'number')) {
if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) {
this._latlngs = this._convertLatLngs(latlngs[0]);
this._holes = latlngs.slice(1);
}
@ -25,7 +25,7 @@ L.Polygon = L.Polyline.extend({
if (!this._holes) { return; }
var i, j, len, len2, hole;
var i, j, len, len2;
for (i = 0, len = this._holes.length; i < len; i++) {
this._holePoints[i] = [];

View File

@ -1,3 +1,7 @@
/*
* L.Handler.PolyEdit is an editing handler for polylines and polygons.
*/
L.Handler.PolyEdit = L.Handler.extend({
options: {
icon: new L.DivIcon({
@ -220,3 +224,26 @@ L.Handler.PolyEdit = L.Handler.extend({
return map.layerPointToLatLng(p1._add(p2)._divideBy(2));
}
});
L.Polyline.addInitHook(function () {
if (L.Handler.PolyEdit) {
this.editing = new L.Handler.PolyEdit(this);
if (this.options.editable) {
this.editing.enable();
}
}
this.on('add', function () {
if (this.editing && this.editing.enabled()) {
this.editing.addHooks();
}
});
this.on('remove', function () {
if (this.editing && this.editing.enabled()) {
this.editing.removeHooks();
}
});
});

View File

@ -1,17 +1,12 @@
/*
* L.Polygon is used to display polylines on a map.
*/
L.Polyline = L.Path.extend({
initialize: function (latlngs, options) {
L.Path.prototype.initialize.call(this, options);
this._latlngs = this._convertLatLngs(latlngs);
// TODO refactor: move to Polyline.Edit.js
if (L.Handler.PolyEdit) {
this.editing = new L.Handler.PolyEdit(this);
if (this.options.editable) {
this.editing.enable();
}
}
},
options: {
@ -50,7 +45,7 @@ L.Polyline = L.Path.extend({
return this.redraw();
},
spliceLatLngs: function (index, howMany) {
spliceLatLngs: function () { // (Number index, Number howMany)
var removed = [].splice.apply(this._latlngs, arguments);
this._convertLatLngs(this._latlngs);
this.redraw();
@ -90,27 +85,10 @@ L.Polyline = L.Path.extend({
return bounds;
},
// TODO refactor: move to Polyline.Edit.js
onAdd: function (map) {
L.Path.prototype.onAdd.call(this, map);
if (this.editing && this.editing.enabled()) {
this.editing.addHooks();
}
},
onRemove: function (map) {
if (this.editing && this.editing.enabled()) {
this.editing.removeHooks();
}
L.Path.prototype.onRemove.call(this, map);
},
_convertLatLngs: function (latlngs) {
var i, len;
for (i = 0, len = latlngs.length; i < len; i++) {
if (latlngs[i] instanceof Array && typeof latlngs[i][0] !== 'number') {
if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {
return;
}
latlngs[i] = L.latLng(latlngs[i]);

View File

@ -1,5 +1,5 @@
/*
* L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds
* L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.
*/
L.Rectangle = L.Polygon.extend({
@ -17,8 +17,7 @@ L.Rectangle = L.Polygon.extend({
latLngBounds.getSouthWest(),
latLngBounds.getNorthWest(),
latLngBounds.getNorthEast(),
latLngBounds.getSouthEast(),
latLngBounds.getSouthWest()
latLngBounds.getSouthEast()
];
}
});

View File

@ -1,5 +1,5 @@
/*
* Circle canvas specific drawing parts.
* Extends L.Circle with Canvas-specific code.
*/
L.Circle.include(!L.Path.CANVAS ? {} : {

View File

@ -36,6 +36,10 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
.off('viewreset', this.projectLatlngs, this)
.off('moveend', this._updatePath, this);
if (this.options.clickable) {
this._map.off('click', this._onClick, this);
}
this._requestUpdate();
this._map = null;
@ -103,16 +107,12 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
this._updateStyle();
if (options.fill) {
if (options.fillOpacity < 1) {
ctx.globalAlpha = options.fillOpacity;
}
ctx.globalAlpha = options.fillOpacity;
ctx.fill();
}
if (options.stroke) {
if (options.opacity < 1) {
ctx.globalAlpha = options.opacity;
}
ctx.globalAlpha = options.opacity;
ctx.stroke();
}
@ -131,7 +131,12 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
_onClick: function (e) {
if (this._containsPoint(e.layerPoint)) {
this.fire('click', e);
this.fire('click', {
latlng: e.latlng,
layerPoint: e.layerPoint,
containerPoint: e.containerPoint,
originalEvent: e
});
}
}
});

View File

@ -1,3 +1,6 @@
/*
* Extends L.Polygon to be able to manually detect clicks on Canvas-rendered polygons.
*/
L.Polygon.include(!L.Path.CANVAS ? {} : {
_containsPoint: function (p) {

View File

@ -1,3 +1,6 @@
/*
* Extends L.Polyline to be able to manually detect clicks on Canvas-rendered polylines.
*/
L.Polyline.include(!L.Path.CANVAS ? {} : {
_containsPoint: function (p, closed) {

View File

@ -25,7 +25,7 @@ L.Map = L.Class.extend({
this._initContainer(id);
this._initLayout();
this._initHooks();
this.callInitHooks();
this._initEvents();
if (options.maxBounds) {
@ -148,11 +148,9 @@ L.Map = L.Class.extend({
this._layers[id] = layer;
// TODO getMaxZoom, getMinZoom in ILayer (instead of options)
if (layer.options && !isNaN(layer.options.maxZoom)) {
this._layersMaxZoom = Math.max(this._layersMaxZoom || 0, layer.options.maxZoom);
}
if (layer.options && !isNaN(layer.options.minZoom)) {
this._layersMinZoom = Math.min(this._layersMinZoom || Infinity, layer.options.minZoom);
if (layer.options && (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom))) {
this._zoomBoundLayers[id] = layer;
this._updateZoomLevels();
}
// TODO looks ugly, refactor!!!
@ -178,6 +176,10 @@ L.Map = L.Class.extend({
layer.onRemove(this);
delete this._layers[id];
if (this._zoomBoundLayers[id]) {
delete this._zoomBoundLayers[id];
this._updateZoomLevels();
}
// TODO looks ugly, refactor
if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) {
@ -415,7 +417,6 @@ L.Map = L.Class.extend({
_initLayout: function () {
var container = this._container;
container.innerHTML = '';
L.DomUtil.addClass(container, 'leaflet-container');
if (L.Browser.touch) {
@ -464,19 +465,11 @@ L.Map = L.Class.extend({
return L.DomUtil.create('div', className, container || this._panes.objectsPane);
},
_initializers: [],
_initHooks: function () {
var i, len;
for (i = 0, len = this._initializers.length; i < len; i++) {
this._initializers[i].call(this);
}
},
_initLayers: function (layers) {
layers = layers ? (layers instanceof Array ? layers : [layers]) : [];
layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : [];
this._layers = {};
this._zoomBoundLayers = {};
this._tileLayersNum = 0;
var i, len;
@ -535,6 +528,30 @@ L.Map = L.Class.extend({
L.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset));
},
_updateZoomLevels: function () {
var i,
minZoom = Infinity,
maxZoom = -Infinity;
for (i in this._zoomBoundLayers) {
if (this._zoomBoundLayers.hasOwnProperty(i)) {
var layer = this._zoomBoundLayers[i];
if (!isNaN(layer.options.minZoom)) {
minZoom = Math.min(minZoom, layer.options.minZoom);
}
if (!isNaN(layer.options.maxZoom)) {
maxZoom = Math.max(maxZoom, layer.options.maxZoom);
}
}
}
if (i === undefined) { // we have no tilelayers
this._layersMaxZoom = this._layersMinZoom = undefined;
} else {
this._layersMaxZoom = maxZoom;
this._layersMinZoom = minZoom;
}
},
// map events
@ -655,16 +672,6 @@ L.Map = L.Class.extend({
}
});
L.Map.addInitHook = function (fn) {
var args = Array.prototype.slice.call(arguments, 1);
var init = typeof fn === 'function' ? fn : function () {
this[fn].apply(this, args);
};
this.prototype._initializers.push(init);
};
L.map = function (id, options) {
return new L.Map(id, options);
};

View File

@ -1,3 +1,6 @@
/*
* Extends L.Map to handle panning animations.
*/
L.Map.include({
@ -49,7 +52,7 @@ L.Map.include({
L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');
var newPos = L.DomUtil.getPosition(this._mapPane).subtract(offset);
var newPos = L.DomUtil.getPosition(this._mapPane).subtract(offset)._round();
this._panAnim.run(this._mapPane, newPos, duration || 0.25, easeLinearity);
return this;

View File

@ -1,3 +1,7 @@
/*
* Extends L.Map to handle zoom animations.
*/
L.Map.mergeOptions({
zoomAnimation: L.DomUtil.TRANSITION && !L.Browser.android23 && !L.Browser.mobileOpera
});
@ -41,7 +45,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
return true;
},
_catchTransitionEnd: function (e) {
_catchTransitionEnd: function () {
if (this._animatingZoom) {
this._onZoomTransitionEnd();
}
@ -139,11 +143,11 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
_onZoomTransitionEnd: function () {
this._restoreTileFront();
L.Util.falseFn(this._tileBg.offsetWidth); // force reflow
this._resetView(this._animateToCenter, this._animateToZoom, true, true);
L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim');
L.Util.falseFn(this._tileBg.offsetWidth); // force reflow
this._animatingZoom = false;
this._resetView(this._animateToCenter, this._animateToZoom, true, true);
if (L.Draggable) {
L.Draggable._disabled = false;

View File

@ -1,3 +1,7 @@
/*
* Adds control-related methods to L.Map.
*/
L.Map.include({
addControl: function (control) {
control.addTo(this);

View File

@ -1,5 +1,5 @@
/*
* Provides L.Map with convenient shortcuts for W3C geolocation.
* Provides L.Map with convenient shortcuts for using browser geolocation features.
*/
L.Map.include({

View File

@ -1,3 +1,6 @@
/*
* Adds popup-related methods to L.Map.
*/
L.Map.include({
openPopup: function (popup) {

View File

@ -1,5 +1,6 @@
/*
* L.Handler.ShiftDragZoom is used internally by L.Map to add shift-drag zoom (zoom to a selected bounding box).
* L.Handler.ShiftDragZoom is used to add shift-drag zoom interaction to the map
* (zoom to a selected bounding box), enabled by default.
*/
L.Map.mergeOptions({
@ -71,9 +72,11 @@ L.Map.BoxZoom = L.Handler.extend({
.off(document, 'mouseup', this._onMouseUp);
var map = this._map,
layerPoint = map.mouseEventToLayerPoint(e),
layerPoint = map.mouseEventToLayerPoint(e);
bounds = new L.LatLngBounds(
if (this._startLayerPoint.equals(layerPoint)) { return; }
var bounds = new L.LatLngBounds(
map.layerPointToLatLng(this._startLayerPoint),
map.layerPointToLatLng(layerPoint));

View File

@ -1,5 +1,5 @@
/*
* L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming.
* L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.
*/
L.Map.mergeOptions({
@ -20,4 +20,4 @@ L.Map.DoubleClickZoom = L.Handler.extend({
}
});
L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);

View File

@ -1,5 +1,5 @@
/*
* L.Handler.MapDrag is used internally by L.Map to make the map draggable.
* L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.
*/
L.Map.mergeOptions({
@ -14,7 +14,7 @@ L.Map.mergeOptions({
longPress: true,
// TODO refactor, move to CRS
worldCopyJump: true
worldCopyJump: false
});
L.Map.Drag = L.Handler.extend({
@ -83,6 +83,7 @@ L.Map.Drag = L.Handler.extend({
},
_onViewReset: function () {
// TODO fix hardcoded Earth values
var pxCenter = this._map.getSize()._divideBy(2),
pxWorldCenter = this._map.latLngToLayerPoint(new L.LatLng(0, 0));
@ -92,8 +93,7 @@ L.Map.Drag = L.Handler.extend({
_onPreDrag: function () {
// TODO refactor to be able to adjust map pane position after zoom
var map = this._map,
worldWidth = this._worldWidth,
var worldWidth = this._worldWidth,
halfWidth = Math.round(worldWidth / 2),
dx = this._initialWorldOffset,
x = this._draggable._newPos.x,
@ -109,9 +109,7 @@ L.Map.Drag = L.Handler.extend({
options = map.options,
delay = +new Date() - this._lastTime,
noInertia = !options.inertia ||
delay > options.inertiaThreshold ||
!this._positions[0];
noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
if (noInertia) {
map.fire('moveend');
@ -120,18 +118,19 @@ L.Map.Drag = L.Handler.extend({
var direction = this._lastPos.subtract(this._positions[0]),
duration = (this._lastTime + delay - this._times[0]) / 1000,
ease = options.easeLinearity,
speedVector = direction.multiplyBy(options.easeLinearity / duration),
speedVector = direction.multiplyBy(ease / duration),
speed = speedVector.distanceTo(new L.Point(0, 0)),
limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),
limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),
decelerationDuration = limitedSpeed / (options.inertiaDeceleration * options.easeLinearity),
decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),
offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
L.Util.requestAnimFrame(function () {
map.panBy(offset, decelerationDuration, options.easeLinearity);
map.panBy(offset, decelerationDuration, ease);
});
}

View File

@ -1,3 +1,7 @@
/*
* L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
*/
L.Map.mergeOptions({
keyboard: true,
keyboardPanOffset: 80,
@ -6,7 +10,6 @@ L.Map.mergeOptions({
L.Map.Keyboard = L.Handler.extend({
// list of e.keyCode values for particular actions
keyCodes: {
left: [37],
right: [39],
@ -32,9 +35,9 @@ L.Map.Keyboard = L.Handler.extend({
}
L.DomEvent
.addListener(container, 'focus', this._onFocus, this)
.addListener(container, 'blur', this._onBlur, this)
.addListener(container, 'mousedown', this._onMouseDown, this);
.on(container, 'focus', this._onFocus, this)
.on(container, 'blur', this._onBlur, this)
.on(container, 'mousedown', this._onMouseDown, this);
this._map
.on('focus', this._addHooks, this)
@ -47,9 +50,9 @@ L.Map.Keyboard = L.Handler.extend({
var container = this._map._container;
L.DomEvent
.removeListener(container, 'focus', this._onFocus, this)
.removeListener(container, 'blur', this._onBlur, this)
.removeListener(container, 'mousedown', this._onMouseDown, this);
.off(container, 'focus', this._onFocus, this)
.off(container, 'blur', this._onBlur, this)
.off(container, 'mousedown', this._onMouseDown, this);
this._map
.off('focus', this._addHooks, this)
@ -105,21 +108,26 @@ L.Map.Keyboard = L.Handler.extend({
},
_addHooks: function () {
L.DomEvent.addListener(document, 'keydown', this._onKeyDown, this);
L.DomEvent.on(document, 'keydown', this._onKeyDown, this);
},
_removeHooks: function () {
L.DomEvent.removeListener(document, 'keydown', this._onKeyDown, this);
L.DomEvent.off(document, 'keydown', this._onKeyDown, this);
},
_onKeyDown: function (e) {
var key = e.keyCode;
var key = e.keyCode,
map = this._map;
if (this._panKeys.hasOwnProperty(key)) {
this._map.panBy(this._panKeys[key]);
map.panBy(this._panKeys[key]);
if (map.options.maxBounds) {
map.panInsideBounds(map.options.maxBounds);
}
} else if (this._zoomKeys.hasOwnProperty(key)) {
this._map.setZoom(this._map.getZoom() + this._zoomKeys[key]);
map.setZoom(map.getZoom() + this._zoomKeys[key]);
} else {
return;

View File

@ -3,7 +3,7 @@
*/
L.Map.mergeOptions({
scrollWheelZoom: !L.Browser.touch || L.Browser.msTouch
scrollWheelZoom: true
});
L.Map.ScrollWheelZoom = L.Handler.extend({
@ -37,9 +37,10 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
_performZoom: function () {
var map = this._map,
delta = Math.round(this._delta),
delta = this._delta,
zoom = map.getZoom();
delta = delta > 0 ? Math.ceil(delta) : Math.round(delta);
delta = Math.max(Math.min(delta, 4), -4);
delta = map._limitZoom(zoom + delta) - zoom;

View File

@ -92,7 +92,7 @@ L.Map.TouchZoom = L.Handler.extend({
L.DomUtil.getScaleString(this._scale, this._startCenter);
},
_onTouchEnd: function (e) {
_onTouchEnd: function () {
if (!this._moved || !this._zooming) { return; }
var map = this._map;