remove all non-website files
This commit is contained in:
parent
a6ab9277cc
commit
c91d47e9e7
917
CHANGELOG.md
917
CHANGELOG.md
@ -1,917 +0,0 @@
|
||||
Leaflet Changelog
|
||||
=================
|
||||
|
||||
(all changes without author notice are by [@mourner](https://github.com/mourner))
|
||||
|
||||
## 0.7.2 (January 17, 2013)
|
||||
|
||||
* Fixed a bug that appeared with **Chrome 32 update** that made all **mouse events shifted on scrolled pages**. [#2352](https://github.com/Leaflet/Leaflet/issues/2352)
|
||||
* Fixed a bug that could break tile loading when using non-standard tile sizes. [#2288](https://github.com/Leaflet/Leaflet/issues/2288)
|
||||
* Fixed a bug where `maxNativeZoom` option didn't work with TMS tile layers (by [@perliedman](https://github.com/perliedman)). [#2321](https://github.com/Leaflet/Leaflet/issues/2321) [#2314](https://github.com/Leaflet/Leaflet/issues/2314)
|
||||
|
||||
## 0.7.1 (December 6, 2013)
|
||||
|
||||
* Fixed a bug where pinch-zooming quickly could occasionally leave the map at a fractional zoom thus breaking tile loading (by [@danzel](https://github.com/danzel)). [#2269](https://github.com/Leaflet/Leaflet/pull/2269) [#2255](https://github.com/Leaflet/Leaflet/issues/2255) [#1934](https://github.com/Leaflet/Leaflet/issues/1934)
|
||||
* Fixed tile flickering issues on some old Android 2/3 devices by disabling buggy hardware accelerated CSS there (by [@danzel](https://github.com/danzel)). [#2216](https://github.com/Leaflet/Leaflet/pull/2216) [#2198](https://github.com/Leaflet/Leaflet/issues/2198)
|
||||
* Fixed a regression that sometimes led to an error when you started pinch-zoom as the first action on the map (by [@danzel](https://github.com/danzel)). [#2259](https://github.com/Leaflet/Leaflet/pull/2259) [#2256](https://github.com/Leaflet/Leaflet/issues/2256)
|
||||
* Reverted `L.Util.template` optimizations to allow Leaflet to be used in eval-banning environments like browser extensions (performance gain was insignificant anyway) (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#2217](https://github.com/Leaflet/Leaflet/issues/2217) [#2209](https://github.com/Leaflet/Leaflet/issues/2209) [#1968](https://github.com/Leaflet/Leaflet/issues/1968)
|
||||
* Fixed a regression where `Map` `invalidateSize` could lead to unexpected results when called before map initialization (by [@Zverik](https://github.com/Zverik)). [#2250](https://github.com/Leaflet/Leaflet/issues/2250) [#2249](https://github.com/Leaflet/Leaflet/issues/2249)
|
||||
* Fixed a regression where `FeatureGroup` containing other group overwrote original `e.layer` value in mouse events (by [@gumballhead](https://github.com/gumballhead)). [#2253](https://github.com/Leaflet/Leaflet/pull/2253) [#2252](https://github.com/Leaflet/Leaflet/issues/2252)
|
||||
* Fixed a regression where `CircleMarker` `setLatLngs` didn't return `this` (by [@radicalbiscuit](https://github.com/radicalbiscuit)). [#2206](https://github.com/Leaflet/Leaflet/pull/2206)
|
||||
|
||||
## 0.7 (November 18, 2013)
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
* Added **support for IE11 touch devices** (by [@danzel](https://github.com/danzel), [@DanielX2](https://github.com/DanielX2) and [@fnicollet](https://github.com/fnicollet)). [#2039](https://github.com/Leaflet/Leaflet/pull/2039) [#2066](https://github.com/Leaflet/Leaflet/pull/2066) [#2037](https://github.com/Leaflet/Leaflet/issues/2037) [#2102](https://github.com/Leaflet/Leaflet/issues/2102)
|
||||
* Added shift-double-click to zoom out shortcut. [#2185](https://github.com/Leaflet/Leaflet/issues/2185)
|
||||
* Significantly improved **controls design on mobile** devices. [#1868](https://github.com/Leaflet/Leaflet/issues/1868) [#2012](https://github.com/Leaflet/Leaflet/issues/2012)
|
||||
* Fixed and improved IE7-8 control and popup styles.
|
||||
* Made subtle improvements to control styles on desktop browsers.
|
||||
* Improved keyboard nav support so that map doesn't loose focus when you click on a control (by [@jacobtoye](https://github.com/jacobtoye)). [#2150](https://github.com/Leaflet/Leaflet/issues/2150) [#2148](https://github.com/Leaflet/Leaflet/issues/2148)
|
||||
* Improved `maxBounds` behavior: now it doesn't force higher minimal zoom, and anchors to max bounds edges properly when zooming (by [@kapouer](https://github.com/kapouer) and [@mourner](https://github.com/mourner)). [#2187](https://github.com/Leaflet/Leaflet/pull/2187) [#1946](https://github.com/Leaflet/Leaflet/pull/1946) [#2081](https://github.com/Leaflet/Leaflet/issues/2081) [#2168](https://github.com/Leaflet/Leaflet/issues/2168) [#1908](https://github.com/Leaflet/Leaflet/issues/1908)
|
||||
|
||||
#### Map API improvements
|
||||
|
||||
* Made `Map` `setView` `zoom` argument optional. [#2056](https://github.com/Leaflet/Leaflet/issues/2056)
|
||||
* Added `maxZoom` option to `Map` `fitBounds`. [#2101](https://github.com/Leaflet/Leaflet/issues/2101)
|
||||
* Added `Map` `bounceAtZoomLimits` option that makes the map bounce when you pinch-zoom past limits (it worked like this before, but now you can disable this) (by [@trevorpowell](https://github.com/trevorpowell)). [#1864](https://github.com/Leaflet/Leaflet/issues/1864) [#2072](https://github.com/Leaflet/Leaflet/pull/2072)
|
||||
* Added `distance` property to `Map` and `Marker` `dragend` events. [#2158](https://github.com/Leaflet/Leaflet/issues/2158) [#872](https://github.com/Leaflet/Leaflet/issues/872)
|
||||
* Added optional support for center-oriented scroll and double-click zoom (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1939](https://github.com/Leaflet/Leaflet/issues/1939)
|
||||
* Added `timestamp` to `Map` `locationfound` event. [#584](https://github.com/Leaflet/Leaflet/pull/584)
|
||||
* Improved `Map` `invalidateSize` to call `moveend` immediately unless given `debounceMoveend: true` option (by [@jfirebaugh](https://github.com/jfirebaugh)). [#2181](https://github.com/Leaflet/Leaflet/issues/2181)
|
||||
|
||||
#### TileLayer API improvements
|
||||
|
||||
* Added `TileLayer` `maxNativeZoom` option that allows displaying tile layers on zoom levels above their maximum by **upscaling tiles**. [#1802](https://github.com/Leaflet/Leaflet/issues/1802) [#1798](https://github.com/Leaflet/Leaflet/issues/1798)
|
||||
* Added `TileLayer` `tileloadstart` event (by [@tmcw](https://github.com/tmcw)). [#2142](https://github.com/Leaflet/Leaflet/pull/2142) [#2140](https://github.com/Leaflet/Leaflet/issues/2140)
|
||||
* Improved `TileLayer` world size (used for wrapping and limiting tiles) to be derived from CRS instead of hardcoded, making it easier to use with custom projections (by [@perliedman](https://github.com/perliedman)). [#2160](https://github.com/Leaflet/Leaflet/pull/2160)
|
||||
|
||||
#### Marker API improvements
|
||||
|
||||
* Added CSS classes to draggable markers for easier customization (by [@snkashis](https://github.com/snkashis)). [#1902](https://github.com/Leaflet/Leaflet/issues/1902) [#1916](https://github.com/Leaflet/Leaflet/issues/1916)
|
||||
* Added `Marker` `add` event (by [@tohaocean](https://github.com/tohaocean)). [#1942](https://github.com/Leaflet/Leaflet/issues/1942)
|
||||
* Added `Marker` `getPopup` method (by [@scottharvey](https://github.com/scottharvey)). [#618](https://github.com/Leaflet/Leaflet/issues/618) [#1197](https://github.com/Leaflet/Leaflet/pull/1197)
|
||||
* Added `Marker` `alt` option for adding `alt` text to markers (by [@jimmytidey](https://github.com/jimmytidey)). [#2112](https://github.com/Leaflet/Leaflet/pull/2112)
|
||||
|
||||
#### Vector layers API improvements
|
||||
|
||||
* Added `Path` `className` option for adding custom class names to vector layers.
|
||||
* Added `Path` `lineCap` and `lineJoin` options (by [@palewire](https://github.com/palewire)). [#1843](https://github.com/Leaflet/Leaflet/issues/1843) [#1863](https://github.com/Leaflet/Leaflet/issues/1863) [#1881](https://github.com/Leaflet/Leaflet/issues/1881)
|
||||
* Added ability to pass vector options to `GeoJSON` (by [@kapouer](https://github.com/kapouer)). [#2075](https://github.com/Leaflet/Leaflet/pull/2075)
|
||||
* Improved `Polygon` `setLatLngs` to also accept holes (by [@aparshin](https://github.com/aparshin)). [#2095](https://github.com/Leaflet/Leaflet/pull/2095) [#1518](https://github.com/Leaflet/Leaflet/issues/1518)
|
||||
* Added `GeoJSON` 3D format support and optional `altitude` argument to `LatLng` constructor (by [@Starefossen](https://github.com/Starefossen)). [#1822](https://github.com/Leaflet/Leaflet/pull/1822)
|
||||
* Added `MultiPolygon` and `MultiPolyline` `openPopup` method. [#2046](https://github.com/Leaflet/Leaflet/issues/2046)
|
||||
|
||||
#### Popup API improvements
|
||||
|
||||
* Added `Popup` `update` method. [#1959](https://github.com/Leaflet/Leaflet/issues/1959)
|
||||
* Added `Popup` `autoPanPaddingTopLeft` and `autoPanPaddingBottomRight` options (by [@albburtsev](https://github.com/albburtsev)). [#1972](https://github.com/Leaflet/Leaflet/issues/1972) [#1588](https://github.com/Leaflet/Leaflet/issues/1588)
|
||||
* Added `Popup` `getContent` method. [#2100](https://github.com/Leaflet/Leaflet/issues/2100)
|
||||
* Added `Popup` `getLatLng` method (by [@AndreyGeonya](https://github.com/AndreyGeonya)). [#2097](https://github.com/Leaflet/Leaflet/pull/2097)
|
||||
|
||||
#### Misc API improvements
|
||||
|
||||
* Added `ImageOverlay` `setUrl` and `getAttribution` methods and `attribution` option (by [@stsydow](https://github.com/stsydow)). [#1957](https://github.com/Leaflet/Leaflet/issues/1957) [#1958](https://github.com/Leaflet/Leaflet/issues/1958)
|
||||
* Added localization support for the zoom control (by [@Danielku15](https://github.com/Danielku15)). [#1953](https://github.com/Leaflet/Leaflet/issues/1953) [#1643](https://github.com/Leaflet/Leaflet/issues/1643) [#1953](https://github.com/Leaflet/Leaflet/pull/1953)
|
||||
* Significantly improved `L.Util.template` performance (affects `L.TileLayer`) by introducing cached template compilation (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#1969](https://github.com/Leaflet/Leaflet/issues/1969) [#1968](https://github.com/Leaflet/Leaflet/issues/1968) [#1554](https://github.com/Leaflet/Leaflet/issues/1554)
|
||||
* Added `CRS` `getSize` for getting the world size in pixels (by [@perliedman](https://github.com/perliedman)). [#2160](https://github.com/Leaflet/Leaflet/pull/2160)
|
||||
* Added `leaflet-drag-target` CSS class to an element under cursor when dragging for more flexible customization. [#2164](https://github.com/Leaflet/Leaflet/issues/2164) [#1902](https://github.com/Leaflet/Leaflet/issues/1902)
|
||||
* Improved `L.DomUtil` `addClass`, `removeClass`, `hasClass` methods performance and fixed it to work with SVG elements. [#2164](https://github.com/Leaflet/Leaflet/issues/2164)
|
||||
|
||||
#### Dev workflow improvements
|
||||
|
||||
* Added an [official FAQ](https://github.com/Leaflet/Leaflet/blob/master/FAQ.md).
|
||||
* Cleaned up and moved old IE styles to `leaflet.css` and removed `leaflet.ie.css`, so **no need for IE conditional comment** when including Leaflet now. [#2159](https://github.com/Leaflet/Leaflet/issues/2159)
|
||||
* Added `leaflet-oldie` CSS class to map container in IE7-8 for easier styling. [#2159](https://github.com/Leaflet/Leaflet/issues/2159)
|
||||
* Officially **dropped support for IE6**. Nobody cares anyway, and Leaflet should still be accessible on it. [#2159](https://github.com/Leaflet/Leaflet/issues/2159)
|
||||
* Improved the build system to check JS errors in spec files. [#2151](https://github.com/Leaflet/Leaflet/issues/2151)
|
||||
* Fixed `jake` command to run tests before building the source. [#2151](https://github.com/Leaflet/Leaflet/issues/2151)
|
||||
* Switched the main file in `package.json` to unminified version for NPM/Browserify (by [@icetan](https://github.com/icetan)). [#2109](https://github.com/Leaflet/Leaflet/pull/2109)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
#### 0.6 regression fixes
|
||||
|
||||
* Fixed a **memory leak in iOS7** that could crash Safari when handling lots of objects (e.g. 1000 markers) (by [@danzel](https://github.com/danzel)). [#2149](https://github.com/Leaflet/Leaflet/pull/2149) [#2122](https://github.com/Leaflet/Leaflet/issues/2122)
|
||||
* Fixed a bug that caused lag at the beginning of panning in Chrome (by [@jfirebaugh](https://github.com/jfirebaugh)). [#2163](https://github.com/Leaflet/Leaflet/issues/2163)
|
||||
* Fixed a regression that made the layers control unscrollable in Firefox. [#2029](https://github.com/Leaflet/Leaflet/issues/2029)
|
||||
* Fixed a regression that broke `worldCopyJump: true` option (by [@fastrde](https://github.com/fastrde)). [#1904](https://github.com/Leaflet/Leaflet/issues/1904) [#1831](https://github.com/Leaflet/Leaflet/issues/1831) [#1982](https://github.com/Leaflet/Leaflet/issues/1982)
|
||||
* Fixed a regression where a first map click after popup close button click was ignored (by [@fastrde](https://github.com/fastrde)). [#1537](https://github.com/Leaflet/Leaflet/issues/1537) [#1963](https://github.com/Leaflet/Leaflet/issues/1963) [#1925](https://github.com/Leaflet/Leaflet/issues/1925)
|
||||
* Fixed a regression where `L.DomUtil.getMousePosition` would throw an error if container argument not provided (by [@scooterw](https://github.com/scooterw)). [#1826](https://github.com/Leaflet/Leaflet/issues/1826) [#1928](https://github.com/Leaflet/Leaflet/issues/1928) [#1926](https://github.com/Leaflet/Leaflet/issues/1926)
|
||||
* Fixed a regression with vector layers positioning when zooming on IE10+ touch devices (by [@danzel](https://github.com/danzel)). [#2002](https://github.com/Leaflet/Leaflet/issues/2002) [#2000](https://github.com/Leaflet/Leaflet/issues/2000)
|
||||
* Fixed a regression with `maxBounds` behaving weirdly on panning inertia out of bounds. [#2168](https://github.com/Leaflet/Leaflet/issues/2168)
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed a bug where the map could freeze if centered and immediately recentered on initialization. [#2071](https://github.com/Leaflet/Leaflet/issues/2071)
|
||||
* Fixed a bug where all maps except the first one on a page didn't track window resize. [#1980](https://github.com/Leaflet/Leaflet/issues/1980)
|
||||
* Fixed a bug where tiles in `EPSG:3395` projection were shifted (by [@aparshin](https://github.com/aparshin)). [#2020](https://github.com/Leaflet/Leaflet/issues/2020)
|
||||
* Fixed a bug where scale control displayed wrong scale when on pages with `box-sizing: border-box`.
|
||||
* Fixed a bug where zoom control button didn't appear as disabled if map was initialized at the zoom limit. [#2083](https://github.com/Leaflet/Leaflet/issues/2083)
|
||||
* Fixed a bug where box zoom also triggered a map click event (by [@fastrde](https://github.com/fastrde)). [#1951](https://github.com/Leaflet/Leaflet/issues/1951) [#1884](https://github.com/Leaflet/Leaflet/issues/1884)
|
||||
* Fixed a bug where shift-clicking on a map immediately after a drag didn't trigger a click event (by [@fastrde](https://github.com/fastrde)). [#1952](https://github.com/Leaflet/Leaflet/issues/1952) [#1950](https://github.com/Leaflet/Leaflet/issues/1950)
|
||||
* Fixed a bug where content was updated twice when opening a popup. [#2137](https://github.com/Leaflet/Leaflet/issues/2137)
|
||||
* Fixed a bug that could sometimes cause infinite panning loop when using `maxBounds` (by [@kapouer](https://github.com/kapouer) and [@mourner](https://github.com/mourner)). [#2187](https://github.com/Leaflet/Leaflet/pull/2187) [#1946](https://github.com/Leaflet/Leaflet/pull/1946) [#2081](https://github.com/Leaflet/Leaflet/issues/2081) [#2168](https://github.com/Leaflet/Leaflet/issues/2168) [#1908](https://github.com/Leaflet/Leaflet/issues/1908)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug where keyboard `+` no longer zoomed the map on FF 22+ (by [@fastrde](https://github.com/fastrde)). [#1943](https://github.com/Leaflet/Leaflet/issues/1943) [#1981](https://github.com/Leaflet/Leaflet/issues/1981)
|
||||
* Fixed a bug where calling `Map` `remove` throwed an error in IE6-8. [#2015](https://github.com/Leaflet/Leaflet/issues/2015)
|
||||
* Fixed a bug where `isArray` didn't work in rare cases in IE9. [#2077](https://github.com/Leaflet/Leaflet/issues/2077)
|
||||
* Fixed a bug where FF sometimes produced console warnings when animating markers. [#2090](https://github.com/Leaflet/Leaflet/issues/2090)
|
||||
* Fixed a bug where mouse wasn't handled correctly on RTL pages in some cases (by [@danzel](https://github.com/danzel)). [#1986](https://github.com/Leaflet/Leaflet/issues/1986) [#2136](https://github.com/Leaflet/Leaflet/pull/2136)
|
||||
|
||||
#### Mobile bugfixes
|
||||
|
||||
* Fixed a bug where tiles could **disappear after zooming on Chrome 30+ for Android** (by [@danzel](https://github.com/danzel)). [#2152](https://github.com/Leaflet/Leaflet/pull/2152) [#2078](https://github.com/Leaflet/Leaflet/issues/2078)
|
||||
* Fixed a bug on IE10+ touch where pinch-zoom also caused click (by [@danzel](https://github.com/danzel)). [#2117](https://github.com/Leaflet/Leaflet/pull/2117) [#2094](https://github.com/Leaflet/Leaflet/issues/2094)
|
||||
* Fixed a bug on IE10+ touch where controls didn't loose the pressed state after tapping (by [@danzel](https://github.com/danzel)). [#2111](https://github.com/Leaflet/Leaflet/pull/2111) [#2103](https://github.com/Leaflet/Leaflet/issues/2103)
|
||||
* Fixed a bug where clicking on layers control labels on iOS throwed an error (by [@olemarkus](https://github.com/olemarkus) and [@dagjomar](https://github.com/dagjomar)). [#1984](https://github.com/Leaflet/Leaflet/issues/1984) [#1989](https://github.com/Leaflet/Leaflet/issues/1989)
|
||||
|
||||
#### Map API bugfixes
|
||||
|
||||
* Fixed a bug where `Map` `getCenter` returned old result after map container size changed (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1940](https://github.com/Leaflet/Leaflet/issues/1940) [#1919](https://github.com/Leaflet/Leaflet/issues/1919)
|
||||
* Fixed `Map` `invalidateSize` rounding issues when changing map size by an odd pixel amount (by [@russelldavis](https://github.com/russelldavis)). [#1931](https://github.com/Leaflet/Leaflet/issues/1931)
|
||||
* Fixed a bug where `Map` `removeLayer` didn't return `this` in a corner case (by [@jfirebaugh](https://github.com/jfirebaugh)).
|
||||
* Fixed a bug where calling `Map` `setZoom` before `setView` would throw an error. [#1449](https://github.com/Leaflet/Leaflet/issues/1449)
|
||||
|
||||
#### Layers API bugfixes
|
||||
|
||||
* Fixed a bug where `Popup` `setLatLng` unnecessarily reset content and updated layout; works much faster now. [#2167](https://github.com/Leaflet/Leaflet/issues/2167)
|
||||
* Fixed a bug where `toGeoJSON` of layers originated from GeoJSON GeometryCollection and MultiPoint didn't work properly (wasn't round-tripped). [#1956](https://github.com/Leaflet/Leaflet/issues/1956)
|
||||
* Fixed `GeoJSON` dependencies in build configuration that could lead to a broken custom build in some situations (by [@alubchuk](https://github.com/alubchuk)). [#1909](https://github.com/Leaflet/Leaflet/issues/1909)
|
||||
* Fixed a bug where `CircleMarker` popup placement wasn't updated after calling `setLatLng` (by [@snkashis](https://github.com/snkashis)). [#1921](https://github.com/Leaflet/Leaflet/issues/1921) [#1927](https://github.com/Leaflet/Leaflet/issues/1927)
|
||||
* Fixed a bug where popup anchor wasn't updated on `Marker` `setIcon` (by [@snkashis](https://github.com/snkashis)). [#1874](https://github.com/Leaflet/Leaflet/issues/1874) [#1891](https://github.com/Leaflet/Leaflet/issues/1891)
|
||||
* Fixed a bug with GeoJSON not throwing a descriptive error if a polygon has zero length inner ring (by [@snkashis](https://github.com/snkashis)). [#1917](https://github.com/Leaflet/Leaflet/issues/1917) [#1918](https://github.com/Leaflet/Leaflet/issues/1918)
|
||||
* Fixed a bug where `FeatureGroup` would break when using non-evented children layers (by [@tmcw](https://github.com/tmcw)). [#2032](https://github.com/Leaflet/Leaflet/pull/2032) [#1962](https://github.com/Leaflet/Leaflet/issues/1962)
|
||||
* Fixed a bug where `CircleMarker` `getRadius` would always return `null`. [#2016](https://github.com/Leaflet/Leaflet/issues/2016) [#2017](https://github.com/Leaflet/Leaflet/pull/2017)
|
||||
* Fixed a bug where `TileLayer.WMS` didn't work with WMS 1.3 & EPSG4326 projection (by [@Bobboya](https://github.com/Bobboya)). [#1897](https://github.com/Leaflet/Leaflet/pull/1897)
|
||||
* Fixed a bug where `FeatureGroup` events `e.layer` was sometimes empty in old IE. [#1938](https://github.com/Leaflet/Leaflet/issues/1938)
|
||||
|
||||
#### Misc API bugfixes
|
||||
|
||||
* Fixed a bug where `L.latLngBounds` didn't accept simple object `LatLng` form (by [@Gnurfos](https://github.com/Gnurfos)). [#2025](https://github.com/Leaflet/Leaflet/issues/2025) [#1915](https://github.com/Leaflet/Leaflet/issues/1915)
|
||||
* Fixed a bug where `L.Util.tempalate` wouldn't work with double quotes in the string (by [@jieter](https://github.com/jieter)). [#1968](https://github.com/Leaflet/Leaflet/issues/1968) [#2121](https://github.com/Leaflet/Leaflet/pull/2121) [#2120](https://github.com/Leaflet/Leaflet/issues/2120)
|
||||
* Fixed a bug where attribution control that was added to a map after attributed layers didn't have the corresponding attributions (by [@snkashis](https://github.com/snkashis)). [#2177](https://github.com/Leaflet/Leaflet/issues/2177) [#2178](https://github.com/Leaflet/Leaflet/pull/2178)
|
||||
|
||||
|
||||
## 0.6.4 (July 25, 2013)
|
||||
|
||||
* Fixed a regression where `fitBounds` and `setMaxBounds` could freeze the browser in some situations. [#1895](https://github.com/Leaflet/Leaflet/issues/1895) [1866](https://github.com/Leaflet/Leaflet/issues/1866)
|
||||
* Fixed a bug where click on a map on a page with horizontal scroll caused the page to scroll right (by [@mstrelan](https://github.com/mstrelan)). [#1901](https://github.com/Leaflet/Leaflet/issues/1901)
|
||||
|
||||
## 0.6.3 (July 17, 2013)
|
||||
|
||||
### Regression fixes
|
||||
|
||||
* Fixed a regression where mouse interaction had incorrect coordinates in some map positioning cases (by [@scooterw](https://github.com/scooterw)). [#1826](https://github.com/Leaflet/Leaflet/issues/1826) [#1684](https://github.com/Leaflet/Leaflet/issues/1684) [#1745](https://github.com/Leaflet/Leaflet/issues/1745) [#1](https://github.com/Leaflet/Leaflet/issues/1)
|
||||
* Fixed a regression that prevented the map from responding to drag on areas covered with `ImageOverlay` (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1821](https://github.com/Leaflet/Leaflet/issues/1821)
|
||||
* Fixed a regression where `layerremove` and `layeradd` were fired before the corresponding action finishes (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1846](https://github.com/Leaflet/Leaflet/issues/1846)
|
||||
* Fixed a regression with `worldCopyJump: true` breaking the map on small zoom levels (by [@danzel](https://github.com/danzel)). [#1831](https://github.com/Leaflet/Leaflet/issues/1831)
|
||||
* Fixed a regression where `Marker` shadow didn't animate on zoom after using `setIcon`. [#1768](https://github.com/Leaflet/Leaflet/issues/1768)
|
||||
* Fixed a regression where the map would stuck when trying to animate zoom before any tile layers are added to the map. [#1484](https://github.com/Leaflet/Leaflet/issues/1484) [#1845](https://github.com/Leaflet/Leaflet/issues/1845)
|
||||
* Fixed a regression with the layers control and popups closing on inside click in IE < 9. [#1850](https://github.com/Leaflet/Leaflet/issues/1850)
|
||||
* Fixed a regression where scrolled popup content woudln't scroll in FF (by [@jfirebaugh](https://github.com/jfirebaugh)).
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* Fixed vector feature flickering on Safari Mac for screen < 2000px. [#902](https://github.com/Leaflet/Leaflet/issues/902)
|
||||
* Fixed a bug where `GeoJSON` ignored non-feature geometries passed in an array. [#1840](https://github.com/Leaflet/Leaflet/issues/1840)
|
||||
* Fixed a bug where `Map` `minZoom` and `maxZoom` didn't always override values derived from the added tile layers. [1848](https://github.com/Leaflet/Leaflet/issues/1848)
|
||||
* Fixed a bug where `TileLayer.Canvas` wasn't immediately redrawn when `redraw` is called (by [@tofferrosen](https://github.com/tofferrosen)). [#1797](https://github.com/Leaflet/Leaflet/issues/1797) [#1817](https://github.com/Leaflet/Leaflet/issues/1817)
|
||||
* Fixed a bug where `FeatureGroup` still fired `layerremove` event on `removeLayer` even if the given layer wan't present in the group (by (by [@danzel](https://github.com/danzel))). [#1847](https://github.com/Leaflet/Leaflet/issues/1847) [#1858](https://github.com/Leaflet/Leaflet/issues/1858)
|
||||
* Fixed a bug where `Marker` `setOpacity` wasn't returning the marker (by [@freepius44](https://github.com/freepius44)). [#1851](https://github.com/Leaflet/Leaflet/issues/1851)
|
||||
* Fixed a bug where removing the map element from the DOM before panning transition has finished could keep a setInterval loop running forever (by [@rutkovsky](https://github.com/rutkovsky)). [#1825](https://github.com/Leaflet/Leaflet/issues/1825) [#1856](https://github.com/Leaflet/Leaflet/issues/1856)
|
||||
* Fixed mobile styles to apply to `leaflet-bar` elements.
|
||||
|
||||
### Improvements
|
||||
|
||||
* Added ability to pass zoom/pan animation options to `setMaxBounds` (by [@davidjb](http://git.io/djb)). [#1834](https://github.com/Leaflet/Leaflet/pull/1834)
|
||||
* Added `MultiPolyline` and `MultiPolygon` `getLatLngs` method. [#1839](https://github.com/Leaflet/Leaflet/issues/1839)
|
||||
|
||||
### Dev Workflow improvements
|
||||
|
||||
* Leaflet builds (*.js files in the `dist` folder) were removed from the repo and are now done automatically on each commit for `master` and `stable` branches by [Travis CI](travis-ci.org/Leaflet/Leaflet). The download links are on the [Leafet download page](http://leafletjs.com/download.html).
|
||||
|
||||
## 0.6.2 (June 28, 2013)
|
||||
|
||||
* Fixed a bug that caused wrong tile layers stacking order when using opacity < 1 (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1804](https://github.com/Leaflet/Leaflet/issues/1804) [#1790](https://github.com/Leaflet/Leaflet/issues/1790) [#1667](https://github.com/Leaflet/Leaflet/issues/1667)
|
||||
* Fixed a regression that caused tiles selection when double-clicking absolutely positioned maps with vector layers in it in Firefox (WTF!) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1807](https://github.com/Leaflet/Leaflet/issues/1807)
|
||||
* Fixed a regression with a wrong cursor when dragging a map with vector layers, and tiles becoming selected on double click (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1800](https://github.com/Leaflet/Leaflet/issues/1800)
|
||||
* Fixed a regression that caused flickering of tiles near map border on zoom animation in Chrome.
|
||||
|
||||
## 0.6.1 (June 27, 2013)
|
||||
|
||||
* Fixed a regression with mouse wheel zooming too fast on Firefox (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1788](https://github.com/Leaflet/Leaflet/issues/1788)
|
||||
* Fixed a regression with broken zooming on maps with EPSG3395 projection. [#1796](https://github.com/Leaflet/Leaflet/issues/1796)
|
||||
* Fixed a bug where zoom buttons inherited Bootstrap link hover styles. [#1791](https://github.com/Leaflet/Leaflet/issues/1791)
|
||||
|
||||
## 0.6 (June 26, 2013)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Moved polyline editing code into [Leaflet.draw](https://github.com/Leaflet/Leaflet.draw) plugin (where it fits much better along with all other editing and drawing handlers). The API remains the same.
|
||||
* Dropped support for environments that augment `Object.prototype` (luckily it's a thing of the past nowadays).
|
||||
* `Map` `invalidateSize` no longer fires `move` and `moveend` events if the map size didn't change. [#1819](https://github.com/Leaflet/Leaflet/issues/1819)
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability and performance improvements
|
||||
|
||||
* **Improved zoom control design** - cleaner, simpler, more accessible (mostly by [@jacobtoye](https://github.com/jacobtoye)). [#1313](https://github.com/Leaflet/Leaflet/issues/1313)
|
||||
* Updated `Control.Layers` icon (designed by Volker Kinkelin), added retina version and SVG source. [#1739](https://github.com/Leaflet/Leaflet/issues/1739)
|
||||
* Added keyboard accessibility to markers (you can now tab to them and press enter for click behavior). [#1355](https://github.com/Leaflet/Leaflet/issues/1355)
|
||||
* Improved `TileLayer` zoom animation to eliminate flickering in case one tile layer on top of another or when zooming several times quickly (by [@mourner](https://github.com/mourner) with lots of fixes from [@danzel](https://github.com/danzel)). [#1140](https://github.com/Leaflet/Leaflet/issues/1140) [#1437](https://github.com/Leaflet/Leaflet/issues/1437) [#52](https://github.com/Leaflet/Leaflet/issues/52)
|
||||
* Subtly improved default popup styles
|
||||
* Improved attribution control to be much less obtrusive (no "powered by", just a Leaflet link). You can still remove the prefix with `map.attributionControl.setPrefix('')` if you need.
|
||||
* Improved zoom behavior so that there's no drift of coordinates when you change zoom back and forth without panning. [#426](https://github.com/Leaflet/Leaflet/issues/426)
|
||||
* Improved double click behavior to zoom while keeping the clicked point fixed (by [@ansis](https://github.com/ansis)). [#1582](https://github.com/Leaflet/Leaflet/issues/1582)
|
||||
* Improved dragging behavior to not get stuck if mouse moved outside of an iframe containing the map (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1277](https://github.com/Leaflet/Leaflet/issues/1277) [#1782](https://github.com/Leaflet/Leaflet/issues/1782) [#1786](https://github.com/Leaflet/Leaflet/issues/1786)
|
||||
* Improved box zoom to be cancelable by pressing Escape (by [@yohanboniface](https://github.com/yohanboniface)). [#1438](https://github.com/Leaflet/Leaflet/issues/1438)
|
||||
* Improved `Marker` popups to close on marker click if opened (by [@popox](https://github.com/popox)). [#1761](https://github.com/Leaflet/Leaflet/issues/1761)
|
||||
* Significantly improved mass layer removal performance (by [@jfgirard](https://github.com/jfgirard) with fixes from [@danzel](https://github.com/danzel)). [#1141](https://github.com/Leaflet/Leaflet/pull/1141) [#1514](https://github.com/Leaflet/Leaflet/pull/1514)
|
||||
|
||||
#### API improvements
|
||||
|
||||
##### Layers API improvements
|
||||
|
||||
* Added `toGeoJSON` method to various layer types, allowing you to **save your Leaflet layers as GeoJSON**. (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1462](https://github.com/Leaflet/Leaflet/issues/1462) [#712](https://github.com/Leaflet/Leaflet/issues/712) [#1779](https://github.com/Leaflet/Leaflet/issues/1779)
|
||||
* Added `GeoJSON` `coordsToLatLng` option for dealing with GeoJSON that has non-WGS84 coords (thanks to [@moonlite](https://github.com/moonlite)). [#888](https://github.com/Leaflet/Leaflet/issues/888) [#886](https://github.com/Leaflet/Leaflet/issues/886)
|
||||
* Improved `Marker` to reuse icon DOM elements when changing icons on the fly (e.g. fixes problems when changing icon on mouse hover) (by [@robpvn](https://github.com/robpvn) & [@danzel](https://github.com/danzel)). [#1726](https://github.com/Leaflet/Leaflet/issues/1726) [#561](https://github.com/Leaflet/Leaflet/issues/561) [#1753](https://github.com/Leaflet/Leaflet/issues/1753) [#1754](https://github.com/Leaflet/Leaflet/pull/1754)
|
||||
* Added `latlng` property to `Marker` mouse event data. [#1613](https://github.com/Leaflet/Leaflet/issues/1613)
|
||||
* Added `LayerGroup` `hasLayer` method (by [@rvlasveld](https://github.com/rvlasveld)). [#1282](https://github.com/Leaflet/Leaflet/issues/1282) [#1300](https://github.com/Leaflet/Leaflet/pull/1300)
|
||||
* Added `LayerGroup` `getLayers` method (by [@tmcw](https://github.com/tmcw)). [#1469](https://github.com/Leaflet/Leaflet/pull/1469)
|
||||
* Added `LayerGroup` `getLayer` method (by [@gumballhead](https://github.com/gumballhead)). [#1650](https://github.com/Leaflet/Leaflet/pull/1650)
|
||||
* Improved `LayerGroup` `removeLayer` method to also accept layer `id` (by [@gumballhead](https://github.com/gumballhead)). [#1642](https://github.com/Leaflet/Leaflet/pull/1642)
|
||||
* Added `Path` `pointerEvents` option for setting pointer-events on SVG-powered vector layers (by [@inpursuit](https://github.com/inpursuit)). [#1053](https://github.com/Leaflet/Leaflet/pull/1053)
|
||||
* Improved `Polygon` to filter out last point if it's equal to the first one (to fix GeoJSON polygon issues) (by [@snkashis](https://github.com/snkashis)). [#1153](https://github.com/Leaflet/Leaflet/pull/1153) [#1135](https://github.com/Leaflet/Leaflet/issues/1135)
|
||||
* Improved paths with `clickable: false` to allow mouse events to pass through to objects underneath (by [@snkashis](https://github.com/snkashis)). [#1384](https://github.com/Leaflet/Leaflet/pull/1384) [#1281](https://github.com/Leaflet/Leaflet/issues/1281)
|
||||
* Improved `L.Util.template` (and correspondingly url-related `TileLayer` options) to support functions for data values (by [@olegsmith](https://github.com/olegsmith)). [#1554](https://github.com/Leaflet/Leaflet/pull/1554)
|
||||
* Added `TileLayer` `getContainer` method (by [@tmcw](https://github.com/tmcw)). [#1433](https://github.com/Leaflet/Leaflet/pull/1433)
|
||||
* Fixed `TileLayer.Canvas` `redraw` method chaining (by [@jieter](https://github.com/jieter)). [#1287](https://github.com/Leaflet/Leaflet/pull/1287)
|
||||
* Added `TileLayer.WMS` `crs` option to be able to use WMS of CRS other than the map CRS (by [@kengu](https://github.com/kengu)). [#942](https://github.com/Leaflet/Leaflet/issues/942) [#945](https://github.com/Leaflet/Leaflet/issues/945)
|
||||
* Added `popupopen` and `popupclose` events to various layers (by [@Koc](https://github.com/Koc)). [#738](https://github.com/Leaflet/Leaflet/pull/738)
|
||||
* Added `Popup` `keepInView` option (thanks to [@lapo-luchini](https://github.com/lapo-luchini)) that prevents the popup from going off-screen while it's opened. [#1308](https://github.com/Leaflet/Leaflet/pull/1308) [#1052](https://github.com/Leaflet/Leaflet/issues/1052)
|
||||
* Added `Marker` `togglePopup` method (by [@popox](https://github.com/popox)). [#1761](https://github.com/Leaflet/Leaflet/issues/1761)
|
||||
* Added `Popup` `closeOnClick` option that overrides the same `Map` option for specific popups (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1669](https://github.com/Leaflet/Leaflet/issues/1669)
|
||||
* Improved `Marker` and `Path` `bindPopup` method to also accept `Popup` objects (by [@snkashis](https://github.com/snkashis)). [#1385](https://github.com/Leaflet/Leaflet/pull/1385) [#1208](https://github.com/Leaflet/Leaflet/issues/1208) [#1402](https://github.com/Leaflet/Leaflet/pull/1402)
|
||||
* Added `Marker` `setPopupContent` method (by [@snkashis](https://github.com/snkashis)). [#1373](https://github.com/Leaflet/Leaflet/pull/1373)
|
||||
|
||||
##### Map API improvements
|
||||
|
||||
* Improved all view changing methods of `Map` (`setView`, `panTo`, `setZoom`, `fitBounds`, etc.) to accept an options object, including the ability to precisely control zoom/pan animations they cause (force disable/enable, etc.). [#1617](https://github.com/Leaflet/Leaflet/pull/1617) [#1616](https://github.com/Leaflet/Leaflet/issues/1616) [#340](https://github.com/Leaflet/Leaflet/issues/340) [#483](https://github.com/Leaflet/Leaflet/issues/483) [#1164](https://github.com/Leaflet/Leaflet/issues/1164) [#1420](https://github.com/Leaflet/Leaflet/issues/1420)
|
||||
* Improved `Map` `fitBounds` method to accept `padding` (or `paddingTopLeft` and `paddingBottomRight`) options, allowing you to zoom to an area with a certain padding in pixels (usually left for controls). [#859](https://github.com/Leaflet/Leaflet/issues/859)
|
||||
* Improved `Map` `invalidateSize` to accept options object (`animate` and `pan`, the latter controls if it pans the map on size change). (by [@jacobtoye](https://github.com/jacobtoye) and [@mourner](https://github.com/mourner)). [#1766](https://github.com/Leaflet/Leaflet/issues/1766) [#1767](https://github.com/Leaflet/Leaflet/issues/1767)
|
||||
* Added `Map` `setZoomAround` method for zooming while keeping a certain point fixed (used by scroll and double-click zooming). [#1157](https://github.com/Leaflet/Leaflet/issues/1157)
|
||||
* Added `Map` `remove` method to properly destroy the map and clean up all events, and added corresponding `unload` event (by [@jfirebaugh](https://github.com/jfirebaugh) and [@mourner](https://github.com/mourner)). [#1434](https://github.com/Leaflet/Leaflet/issues/1434) [#1101](https://github.com/Leaflet/Leaflet/issues/1101) [#1621](https://github.com/Leaflet/Leaflet/issues/1621)
|
||||
* Added `Map` `tap` handler that now contains all mobile hacks for enabling quick taps and long holds and `tapTolerance` option specifying the number of pixels you can shift your finger for click to still fire.
|
||||
* Added `Map` `zoomAnimationThreshold` for setting the max zoom difference with which zoom animation can occur. [#1377](https://github.com/Leaflet/Leaflet/issues/1377)
|
||||
* Improved `Map` `openPopup` method to also accept `(content, latlng)` signature as a shortcut.
|
||||
* Improved `Map` `closePopup` method to optionally accept a popup object to close. [#1641](https://github.com/Leaflet/Leaflet/issues/1641)
|
||||
* Improved `Map` `stopLocate` method to abort resetting map view if calling `locate` with `setView` option. [#747](https://github.com/Leaflet/Leaflet/issues/747)
|
||||
* Improved `Map` to throw exception if the specified container id is not found (by [@tmcw](htts://github.com/tmcw)). [#1574](https://github.com/Leaflet/Leaflet/pull/1574)
|
||||
* Improved `Map` `locationfound` event to pass all location data (heading, speed, etc.). [#984](https://github.com/Leaflet/Leaflet/issues/984) [#584](https://github.com/Leaflet/Leaflet/issues/584) [#987](https://github.com/Leaflet/Leaflet/issues/987) [#1028](https://github.com/Leaflet/Leaflet/issues/1028)
|
||||
* Added `Map` `resize` event. [#1564](https://github.com/Leaflet/Leaflet/issues/1564)
|
||||
* Added `Map` `zoomlevelschange` event that triggers when the current zoom range (min/max) changes (by [@moonlite](https://github.com/moonlite)). [#1376](https://github.com/Leaflet/Leaflet/pull/1376)
|
||||
|
||||
##### Controls API improvements
|
||||
|
||||
* Added **generic toolbar classes** for reuse by plugin developers (used by zoom control).
|
||||
* Added `Map` `baselayerchange`, `overlayadd` and `overlayremove` events fired by `Control.Layers` (by [@calvinmetcalf](https://github.com/calvinmetcalf) and [@Xelio](https://github.com/Xelio)). [#1286](https://github.com/Leaflet/Leaflet/issues/1286) [#1634](https://github.com/Leaflet/Leaflet/issues/1634)
|
||||
* Added `Control` `getContainer` method. [#1409](https://github.com/Leaflet/Leaflet/issues/1409)
|
||||
|
||||
##### Misc API improvements
|
||||
|
||||
* Made Leaflet classes compatible with **CoffeeScript class inheritance** syntax (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#1345](https://github.com/Leaflet/Leaflet/pull/1345) [#1314](https://github.com/Leaflet/Leaflet/issues/1314)
|
||||
* Added `cleanAllEventListeners` method (aliased to `off` without arguments) to all events-enabled objects (by [@iirvine](https://github.com/iirvine)). [#1599](https://github.com/Leaflet/Leaflet/issues/1599)
|
||||
* Added `addOneTimeEventListener` method (aliased to `once`) to all events-enabled objects (by [@iirvine](https://github.com/iirvine)). [#473](https://github.com/Leaflet/Leaflet/issues/473) [#1596](https://github.com/Leaflet/Leaflet/issues/1596)
|
||||
* Added ability to pass coordinates as simple objects (`{lat: 50, lon: 30}` or `{lat: 50, lng: 30}`). [#1412](https://github.com/Leaflet/Leaflet/issues/1412)
|
||||
* Added `LatLngBounds` `getNorth`, `getEast`, `getSouth`, `getWest` methods (by [@yohanboniface](https://github.com/yohanboniface)). [#1318](https://github.com/Leaflet/Leaflet/issues/1318)
|
||||
* Added `AMD` support (Leaflet now registers itself as a `leaflet` AMD module) (with fixes from [@sheppard](https://github.com/sheppard)). [#1364](https://github.com/Leaflet/Leaflet/issues/1364) [#1778](https://github.com/Leaflet/Leaflet/issues/1778)
|
||||
* Added `L.Util.trim` function (by [@kristerkari](https://github.com/kristerkari)). [#1607](https://github.com/Leaflet/Leaflet/pull/1607)
|
||||
|
||||
#### Development workflow improvements
|
||||
|
||||
* Switched from Jasmine to [Mocha](http://visionmedia.github.io/mocha/) with Expect.js (matchers) and Sinon (spies) for tests (by [@tmcw](https://github.com/tmcw) & [@jfirebaugh](https://github.com/jfirebaugh)). [#1479](https://github.com/Leaflet/Leaflet/issues/1479)
|
||||
* Added [Karma](http://karma-runner.github.io) integration for running tests in a headless PhantomJS instance and code coverage reporting (by [@edjafarov](https://github.com/edjafarov)). [#1326](https://github.com/Leaflet/Leaflet/issues/1326) [#1340](https://github.com/Leaflet/Leaflet/pull/1340)
|
||||
* Added [Travis CI integration](https://travis-ci.org/Leaflet/Leaflet) for linting and running tests for each commit and pull request automatically (by [@edjafarov](https://github.com/edjafarov)). [#1336](https://github.com/Leaflet/Leaflet/issues/1336)
|
||||
* Significantly improved test coverage
|
||||
* Added compatibility with lazy evaluation scripts (by [@kristerkari](https://github.com/kristerkari)). [#1288](https://github.com/Leaflet/Leaflet/issues/1288) [#1607](https://github.com/Leaflet/Leaflet/issues/1607) [#1288](https://github.com/Leaflet/Leaflet/issues/1288)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed lots of issues with extent restriction by `Map` `maxBounds`. [#1491](https://github.com/Leaflet/Leaflet/issues/1491) [#1475](https://github.com/Leaflet/Leaflet/issues/1475) [#1194](https://github.com/Leaflet/Leaflet/issues/1194) [#900](https://github.com/Leaflet/Leaflet/issues/900) [#1333](https://github.com/Leaflet/Leaflet/issues/1333)
|
||||
* Fixed occasional crashes by disabling zoom animation if changing zoom level by more than 4 levels. [#1377](https://github.com/Leaflet/Leaflet/issues/1377)
|
||||
* Fixed a bug with that caused stuttery keyboard panning in some cases (by [@tmcw](https://github.com/tmcw)). [#1710](https://github.com/Leaflet/Leaflet/issues/1710)
|
||||
* Fixed a bug that caused unwanted scrolling of the page to the top of the map on focus. [#1228](https://github.com/Leaflet/Leaflet/issues/1228) [#1540](https://github.com/Leaflet/Leaflet/issues/1540)
|
||||
* Fixed a bug where clicking on a marker with an open popup caused the popup to faded in again (by [@snkashis](https://github.com/snkashis)). [#506](https://github.com/Leaflet/Leaflet/issues/560) [#1386](https://github.com/Leaflet/Leaflet/pull/1386)
|
||||
* Fixed a bug where zoom buttons disabled state didn't update on min/max zoom change (by [@snkashis](https://github.com/snkashis)). [#1372](https://github.com/Leaflet/Leaflet/pull/1372) [#1328](https://github.com/Leaflet/Leaflet/issues/1328)
|
||||
* Fixed a bug where scrolling slightly wouldn't always zoom out the map (by [@cschwarz](https://github.com/cschwarz)). [#1575](https://github.com/Leaflet/Leaflet/pull/1575)
|
||||
* Fixed popup close button to not leave an outline after clicking on it and reopening the popup (by [@dotCypress](https://github.com/dotCypress)). [#1537](https://github.com/Leaflet/Leaflet/pull/1537)
|
||||
* Fixed a bug that prevented tiles from loading during pan animation.
|
||||
* Fixed a bug with `contextmenu` events on popups falling through to map (by [@snkashis](https://github.com/snkashis)). [#1730](https://github.com/Leaflet/Leaflet/issues/1730) [#1732](https://github.com/Leaflet/Leaflet/issues/1732)
|
||||
* Fixed `404` tile loading errors when browsing the map off the world bounds.
|
||||
* Fixed shifted mouse events in some cases with map inside a relatively positioned parent (by [@scooterw](https://github.com/scooterw) and [@jec006](https://github.com/jec006)). [#1670](https://github.com/Leaflet/Leaflet/issues/1670) [#1684](https://github.com/Leaflet/Leaflet/issues/1684) [#1745](https://github.com/Leaflet/Leaflet/issues/1745) [#1744](https://github.com/Leaflet/Leaflet/issues/1744)
|
||||
* Fixed a bug where tile layer z-index order sometimes broke after view reset. [#1422](https://github.com/Leaflet/Leaflet/issues/1422)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug with undesirable page scrolling in Firefox 17+ when you zoom the map by scrolling (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1789](https://github.com/Leaflet/Leaflet/issues/1789) [#1788](https://github.com/Leaflet/Leaflet/issues/1788)
|
||||
* Fixed a bug where mouse coordinates where shifted in Firefox if the map was inside a positioned block on a scrolled page (by [@joschka](https://github.com/joschka)). [#1365](https://github.com/Leaflet/Leaflet/pull/1365) [#1322](https://github.com/Leaflet/Leaflet/issues/1322)
|
||||
* Fixed a bug where box zoom didn't work in some cases in Firefox 18+ (by [@fabriceds](https://github.com/fabriceds)). [#1405](https://github.com/Leaflet/Leaflet/pull/1405)
|
||||
* Fixed a bug where `TileLayer` opacity didn't work in IE 7-8 (by [@javisantana](https://github.com/javisantana) & [@danzel](https://gi
|
||||
.com/danzel)). [#1084](https://github.com/Leaflet/Leaflet/issues/1084) [#1396](https://github.com/Leaflet/Leaflet/pull/1396) [#1371](https://github.com/Leaflet/Leaflet/issues/1371)
|
||||
* Fixed Leaflet not working correctly in PhantomJS (by [@rassie](https://github.com/rassie)). [#1501](https://github.com/Leaflet/Leaflet/pull/1501)
|
||||
|
||||
#### Mobile bugfixes
|
||||
|
||||
* Fixed a bug with layers control on WinPhone8/IE10 Touch (by [@danzel](https://github.com/danzel)). [#1635](https://github.com/Leaflet/Leaflet/pull/1635) [#1539](https://github.com/Leaflet/Leaflet/issues/1539)
|
||||
* Fixed a bug with click sometimes firing twice on WinPhone8/IE10 Touch (by [@danzel](https://github.com/danzel)). [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
* Fixed a bug in Android where click was triggered twice on one tap (by [@jerel](https://github.com/jerel) & [@mourner](https://github.com/mourner)). [#1227](https://github.com/Leaflet/Leaflet/pull/1227) [#1263](https://github.com/Leaflet/Leaflet/issues/1263) [#1785](https://github.com/Leaflet/Leaflet/issues/1785) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
* Fixed a bug in Android where click on a collapsed layers control would immediately select one of the layers (by [@danzel](https://github.com/danzel)). [#1784](https://github.com/Leaflet/Leaflet/issues/1784) [#1694](https://github.com/Leaflet/Leaflet/issues/1694)
|
||||
|
||||
#### API bugfixes
|
||||
|
||||
##### General API bugfixes
|
||||
|
||||
* Fixed click mouse event inside popups **not propagating outside the map** (fixes issues with jQuery.live and some mobile frameworks that rely on document click listeners). [#301](https://github.com/Leaflet/Leaflet/issues/301)
|
||||
* Fixed a bug where event listener still fired even if it was removed on the same event in other listener (by [@spamdaemon](https://github.com/spamdaemon)). [#1661](https://github.com/Leaflet/Leaflet/issues/1661) [#1654](https://github.com/Leaflet/Leaflet/issues/1654)
|
||||
* Fixed a bug where `L.point` and `L.latLng` factories weren't passing `null` and `undefined` values through.
|
||||
* Fixed `DomEvent` `removeListener` function chaining (by [@pagameba](https://github.com/pagameba)).
|
||||
* Fixed a bug where `removeEventListener` would throw an error if no events are registered on the object (by [@tjoekbezoer](https://github.com/tjoekbezoer)). [#1632](https://github.com/Leaflet/Leaflet/pull/1632) [#1631](https://github.com/Leaflet/Leaflet/issues/1631)
|
||||
* Fixed a bug where `Point` `equals` and `contains` methods didn't accept points in array form.
|
||||
* Fixed a bug where `LatLngBounds` `extend` of an undefined object would cause an error (by [@korzhyk](https://github.com/korzhyk)). [#1688](https://github.com/Leaflet/Leaflet/issues/1688)
|
||||
* Fixed a bug where `Control.Attribution` `removeAttribution` of inexistant attribution corrupted the attribution text. [#1410](https://github.com/Leaflet/Leaflet/issues/1410)
|
||||
* Fixed a bug where `setView` on an invisible map caused an error (by [@jfire](https://github.com/jfire)). [#1707](https://github.com/Leaflet/Leaflet/issues/1707)
|
||||
* Fixed compatibility with Browserify (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1572](https://github.com/Leaflet/Leaflet/pull/1572)
|
||||
|
||||
##### Layers API bugfixes
|
||||
|
||||
* Fixed a bug where default marker icon path wasn't properly detected in some cases in IE6-7 (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#1294](https://github.com/Leaflet/Leaflet/pull/1294)
|
||||
* Fixed a bug where `TileLayer.WMS` param values weren't escaped in URLs (by [@yohanboniface](https://github.com/yohanboniface)). [#1317](https://github.com/Leaflet/Leaflet/issues/1317)
|
||||
* Fixed a bug where layers that belong to multiple feature groups didn't propagate events correctly (by [@danzel](https://github.com/danzel)). [#1359](https://github.com/Leaflet/Leaflet/pull/1359)
|
||||
* Fixed a bug where `TileLayer.WMS` `tileSize` option was ignored (by [@brianhatchl](https://github.com/brianhatchl)). [#1080](https://github.com/brianhatchl)
|
||||
* Fixed a bug where `Polyline` constructor could overwrite the source array (by [@snkashis](https://github.com/snkashis) and [@danzel](https://github.com/danzel)). [#1439](https://github.com/Leaflet/Leaflet/pull/1439) [#1092](https://github.com/Leaflet/Leaflet/issues/1092) [#1246](https://github.com/Leaflet/Leaflet/issues/1246) [#1426](https://github.com/Leaflet/Leaflet/issues/1426)
|
||||
* Fixed a bug where marker dragging disabling/enabling wouldn't always work correctly (by [@snkashis](https://github.com/snkashis) and [@escaped](https://github.com/escaped)). [#1471](https://github.com/Leaflet/Leaflet/pull/1471) [#1551](https://github.com/Leaflet/Leaflet/pull/1551)
|
||||
* Fixed `TileLayer` to prevent incorrect subdomain in case of negative tile coordinates (by [@malexeev](https://github.com/malexeev)). [#1532](https://github.com/Leaflet/Leaflet/pull/1532)
|
||||
* Fixed polygons to normalize holes (remove last point if it's equal to the first one) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#](https://github.com/Leaflet/Leaflet/pull/1467) [#1459](https://github.com/Leaflet/Leaflet/issues/1459)
|
||||
* Fixed `DivIcon` `html` option to accept `0` as a value (by [@stuporglue](https://github.com/stuporglue)). [#1633](https://github.com/Leaflet/Leaflet/pull/1633)
|
||||
* Fixed a bug with Canvas-based paths throwing an error on `mousemove` in certain conditions. [#1615](https://github.com/Leaflet/Leaflet/issues/1615)
|
||||
* Fixed a bug where copies of the world wouldn't load if you set `TileLayer` `bounds` (by [@ansis](https://github.com/ansis)). [#1618](https://github.com/Leaflet/Leaflet/issues/1618)
|
||||
* Fixed a bug where `TileLayer` `load` event wouldn't always fire correctly. [#1565](https://github.com/Leaflet/Leaflet/issues/1565)
|
||||
* Fixed `TileLayer.WMS` compatibility with some old servers that only accepted request parameters in uppercase. [#1751](https://github.com/Leaflet/Leaflet/issues/1751)
|
||||
* Fixed a bug with incorrect `L.Icon.Default.imagePath` detection in some cases. [#1657](https://github.com/Leaflet/Leaflet/issues/1657)
|
||||
* Fixed a bug where layer `onRemove` was still called even if it was never added (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1729](https://github.com/Leaflet/Leaflet/issues/1729)
|
||||
* Fixed a bug where calling `setRadius` on a Canvas-powered `CircleMarker` would cause an infinite loop (by [@snkashis](https://github.com/snkashis)). [#1712](https://github.com/Leaflet/Leaflet/issues/1712) [#1713](https://github.com/Leaflet/Leaflet/issues/1713) [#1728](https://github.com/Leaflet/Leaflet/issues/1728)
|
||||
* Renamed `marker-icon@2x.png` to `marker-icon-2x.png` to fix compatibility with Google AppEngine. [#1552](https://github.com/Leaflet/Leaflet/issues/1552) [#1553](https://github.com/Leaflet/Leaflet/issues/1553)
|
||||
* Fixed a bug where `popupclose` and `popupopen` events weren't fired for multipolygons and multipolylines (by [@tmcw](https://github.com/tmcw)). [#1681](https://github.com/Leaflet/Leaflet/issues/1681)
|
||||
|
||||
##### Map API bugfixes
|
||||
|
||||
* Fixed a bug where `Map` `fitBounds` wouldn't work correctly with large bounds (thanks to [@MaZderMind](https://github.com/MaZderMind)). [#1069](https://github.com/Leaflet/Leaflet/issues/1069)
|
||||
* Fixed a bug where `Map` `hasLayer` wasn't handling `null` objects (by [@rvlasveld](https://github.com/rvlasveld)). [#1282](https://github.com/Leaflet/Leaflet/issues/1282) [#1302](https://github.com/Leaflet/Leaflet/pull/1302)
|
||||
* Fixed a bug where `Map` `moveend` fired before `dragend` on drag (by [@oslek](https://github.com/oslek)). [#1374](https://github.com/Leaflet/Leaflet/pull/1374)
|
||||
* Fixed a bug where panning with inertia produced an excessive `Map` `movestart` event on inertia start (by [@oslek](https://github.com/oslek)). [#1374](https://github.com/Leaflet/Leaflet/pull/1374)
|
||||
* Fixed a bug where `Map` `moveend` fired repeatedly on window resize even if the actual map size didn't change (by [@oslek](https://github.com/oslek)). [#1374](https://github.com/Leaflet/Leaflet/pull/1374)
|
||||
* Fixed a bug where `Map` `moveend` sometimes wasn't fired after drag (particularly often when dragging with a trackpad).
|
||||
* Fixed a bug that would cause an error when trying to get the state of the map in a `Map` `load` event listener. [#962](https://github.com/Leaflet/Leaflet/issues/962)
|
||||
* Added `Map` `autopanstart` event back (it was removed occasionally in previous version). [#1375](https://github.com/Leaflet/Leaflet/issues/1375)
|
||||
* Fixed a bug with removing previously set `Map` `maxBounds` (by [@jec006](https://github.com/jec006)). [#1749](https://github.com/Leaflet/Leaflet/issues/1749) [#1750](https://github.com/Leaflet/Leaflet/issues/1750)
|
||||
|
||||
|
||||
## 0.5.1 (February 6, 2013)
|
||||
|
||||
* Fixed a regression with `GeoJSON` not accepting arrays of `FeatureCollection` (by [@snkashis](https://github.com/snkashis)). [#1299](https://github.com/Leaflet/Leaflet/pull/1299) [#1298](https://github.com/Leaflet/Leaflet/issues/1298)
|
||||
* Fixed a regression with `CirleMarker` `setRadius` not working if called before adding the layer to the map (by [@danzel](https://github.com/danzel)). [#1342](https://github.com/Leaflet/Leaflet/issues/1342) [#1297](https://github.com/Leaflet/Leaflet/issues/1297)
|
||||
|
||||
## 0.5 (January 17, 2013)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Be sure to read through these changes to avoid any issues when upgrading from older versions:
|
||||
|
||||
* Removed default `LatLng` wrapping/clamping of coordinates (`-180, -90` to `180, 90`), wrapping moved to an explicit method (`LatLng` `wrap`).
|
||||
* Disabled `Map` `worldCopyJump` option by default (jumping back to the original world copy when panning out of it). Enable it explicitly if you need it.
|
||||
* Changed styles for the zoom control (you may need to update your custom styles for it).
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
##### Interaction
|
||||
|
||||
* Added touch zoom, pan and double tap support for **IE10 touch devices and Metro apps** (by [@danzel](https://github.com/danzel) and [@veproza](https://github.com/veproza) with help from [@oliverheilig](https://github.com/oliverheilig)). [#1076](https://github.com/Leaflet/Leaflet/pull/1076) [#871](https://github.com/Leaflet/Leaflet/issues/871)
|
||||
* **Improved panning inertia** to be much more natural and smooth.
|
||||
* **Improved dragging cursors** in Chrome, Safari and Firefox (now grabbing hand cursors are used).
|
||||
* Improved zoom animation curve for a better feel overall.
|
||||
* Improved scroll wheel zoom to be more responsive.
|
||||
* Improved panning animation performance in IE6-8.
|
||||
|
||||
##### Controls
|
||||
|
||||
* **Improved zoom control design** to look better, more neutral and in line with other controls, making it easier to customize and fit different website designs. Replaced +/- images with text.
|
||||
* Improved zoom control to zoom by 3 levels if you hold shift while clicking on a button.
|
||||
* Improved zoom control buttons to become visually disabled when min/max zoom is reached. [#917](https://github.com/Leaflet/Leaflet/issues/917)
|
||||
* Improved scale control styles.
|
||||
* Improved fallback control styles for IE6-8.
|
||||
|
||||
##### Other
|
||||
|
||||
* Added **retina support for markers** (through `Icon` `iconRetinaUrl` and `shadowRetinaUrl` options) (by [@danzel](https://github.com/danzel)). [#1048](https://github.com/Leaflet/Leaflet/issues/1048) [#1174](https://github.com/Leaflet/Leaflet/pull/1174)
|
||||
* Added retina-sized default marker icon in addition to standard one (along with its SVG source and with some subtle design improvements) (by [@danzel](https://github.com/danzel)). [#1048](https://github.com/Leaflet/Leaflet/issues/1048) [#1174](https://github.com/Leaflet/Leaflet/pull/1174)
|
||||
* Improved vectors updating/removing performance on Canvas backend (by [@danzel](https://github.com/danzel)). [#961](https://github.com/Leaflet/Leaflet/pull/961)
|
||||
* Cut total images size from 10KB to 3.2KB with [Yahoo Smush.it](http://www.smushit.com/ysmush.it/). Thanks to Peter Rounce for suggestion.
|
||||
|
||||
#### API improvements
|
||||
|
||||
* Replaced `L.Transition` with a much better and simpler `L.PosAnimation`.
|
||||
* Added `Class` `addInitHook` method for **adding constructor hooks to any classes** (great extension point for plugin authors). [#1123](https://github.com/Leaflet/Leaflet/issues/1123)
|
||||
* Added `Map` `whenReady` method (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1063](https://github.com/Leaflet/Leaflet/pull/1063)
|
||||
* Added optional `delta` argument to `Map` `zoomIn` and `zoomOut` (1 by default).
|
||||
* Added `isValid` method to `LatLngBounds` and `Bounds` (by [@domoritz](https://github.com/domoritz)). [#972](https://github.com/Leaflet/Leaflet/pull/972)
|
||||
* Added `Point` `equals` method.
|
||||
* Added `Bounds` `getSize` method.
|
||||
* Improved markers and vectors click event so that it propagates to map if no one is listening to it (by [@danzel](https://github.com/danzel)). [#834](https://github.com/Leaflet/Leaflet/issues/834) [#1033](https://github.com/Leaflet/Leaflet/pull/1033)
|
||||
* Added `Path` `unbindPopup` and `closePopup` methods.
|
||||
* Added `Path` `add` and `remove` event.
|
||||
* Added `Marker` `riseOnHover` and `riseOffset` options (for bringing markers to front on hover, disabled by default) (by [jacobtoye](https://github.com/jacobtoye)). [#914](https://github.com/Leaflet/Leaflet/pull/914) [#920](https://github.com/Leaflet/Leaflet/issues/920)
|
||||
* Added `Marker` `move` and `remove` events.
|
||||
* Added `Marker` `contextmenu` event. [#223](https://github.com/Leaflet/Leaflet/issues/223)
|
||||
* Added `Popup` `zoomAnimation` option (useful to disable when displaying flash content inside popups [#999](https://github.com/Leaflet/Leaflet/issues/999)).
|
||||
* Added `FeatureGroup` `layeradd` and `layerremove` events (by [@jacobtoye](https://github.com/jacobtoye)). [#1122](https://github.com/Leaflet/Leaflet/issues/1122)
|
||||
* Added `Control.Layers` `baselayerchange` event (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1064](https://github.com/Leaflet/Leaflet/pull/1064)
|
||||
* Improved `Control.Layers` to support HTML in layer names (by [@aparshin](https://github.com/aparshin)). [#1055](https://github.com/Leaflet/Leaflet/pull/1055) [#1099](https://github.com/Leaflet/Leaflet/issues/1099)
|
||||
* Added `CRS.Simple` to the list of built-in CRS and improved it to be more usable out of the box (it has different default scaling and transformation now), see `debug/map/simple-proj.html` for an example.
|
||||
* Removed `Browser` `ua`, `gecko`, `opera` properties (no longer needed).
|
||||
* Added `L.extend`, `L.bind`, `L.stamp`, `L.setOptions` shortcuts for corresponding `L.Util` methods.
|
||||
* Disabled clearing of map container contents on map initialization (as a result of fixing [#278](https://github.com/Leaflet/Leaflet/issues/278)).
|
||||
* Added `L.Util.isArray` function (by [@oslek](https://github.com/oslek)). [#1279](https://github.com/Leaflet/Leaflet/pull/1279)
|
||||
* Added `mouseover` and `mouseout` events to canvas-based vector layers (by [@snkashis](https://github.com/snkashis)). [#1403](https://github.com/Leaflet/Leaflet/pull/1403)
|
||||
* Added `Map` `eachLayer` to iterate over all layers added to the map (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1457](https://github.com/Leaflet/Leaflet/pull/1457)
|
||||
* Added `TileLayer` `bounds` option to limit tile loading to a specific region (by [@adimitrov](https://github.com/adimitrov)). [#991](https://github.com/Leaflet/Leaflet/pull/991)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* Fixed broken tiles and zooming in RTL layouts (by [@danzel](https://github.com/danzel)). [#1099](https://github.com/Leaflet/Leaflet/pull/1099) [#1095](https://github.com/Leaflet/Leaflet/issues/1095)
|
||||
* Fixed a bug with pan animation where it jumped to its end position if you tried to drag the map.
|
||||
* Fixed a bug where shift-clicking on a map would zoom it to the max zoom level.
|
||||
* Fixed a glitch with zooming in while panning animation is running.
|
||||
* Fixed a glitch with dragging the map while zoom animation is running.
|
||||
* Fixed a bug where slight touchpad scrolling or one-wheel scrolling wouln't always perform zooming. [#1039](https://github.com/Leaflet/Leaflet/issues/1039)
|
||||
* Fixed a bug where `panBy` wouldn't round the offset values (so it was possible to make the map blurry with it). [#1085](https://github.com/Leaflet/Leaflet/issues/1085)
|
||||
* Fixed a bug where you couldn't scroll the layers control with a mouse wheel.
|
||||
* Fixed a regression where WMS tiles wouldn't wrap on date lines. [#970](https://github.com/Leaflet/Leaflet/issues/970)
|
||||
* Fixed a bug where mouse interaction was affected by map container border width (by [@mohlendo](https://github.com/mohlendo)). [#1204](https://github.com/Leaflet/Leaflet/issues/1205) [#1205](https://github.com/Leaflet/Leaflet/pull/1205)
|
||||
* Fixed a bug with weird vector zoom animation when using Canvas for rendering (by [@danzel](https://github.com/danzel)). [#1187](https://github.com/Leaflet/Leaflet/issues/1187) [#1188](https://github.com/Leaflet/Leaflet/pull/1188)
|
||||
* Fixed a bug where max bounds limitation didn't work when navigating the map with a keyboard (by [@snkashis](https://github.com/snkashis)). [#989](https://github.com/Leaflet/Leaflet/issues/989) [#1221](https://github.com/Leaflet/Leaflet/pull/1221)
|
||||
|
||||
#### API bugfixes
|
||||
|
||||
* Fixed a bug where `TileLayer` `bringToBack` didn't work properly in some cases (by [@danzel](https://github.com/danzel)). [#963](https://github.com/Leaflet/Leaflet/pull/963) [#959](https://github.com/Leaflet/Leaflet/issues/959)
|
||||
* Fixed a bug where removing a tile layer while dragging would throw an error (by [@danzel](https://github.com/danzel)). [#965](https://github.com/Leaflet/Leaflet/issues/965) [#968](https://github.com/Leaflet/Leaflet/pull/968)
|
||||
* Fixed a bug where middle marker wasn't removed after deleting 2 end nodes from a polyline (by [@Svad](https://github.com/Svad)). [#1022](https://github.com/Leaflet/Leaflet/issues/1022) [#1023](https://github.com/Leaflet/Leaflet/pull/1023)
|
||||
* Fixed a bug where `Map` `load` event happened too late (after `moveend`, etc.) (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1027](https://github.com/Leaflet/Leaflet/pull/1027)
|
||||
* Fixed `Circle` `getBounds` to return correct bounds and work without adding the circle to a map. [#1068](https://github.com/Leaflet/Leaflet/issues/1068)
|
||||
* Fixed a bug where removing `Popup` on `viewreset` throwed an error (by [fnicollet](https://github.com/fnicollet) and [@danzel](https://github.com/danzel)). [#1098](https://github.com/Leaflet/Leaflet/pull/1098) [#1094](https://github.com/Leaflet/Leaflet/issues/1094)
|
||||
* Fixed a bug where `TileLayer.Canvas` `drawTile` didn't receive tile zoom level in arguments.
|
||||
* Fixed a bug where `GeoJSON` `resetStyle` would not fully reset a layer to its default style. [#1112](https://github.com/Leaflet/Leaflet/issues/1112)
|
||||
* Fixed a bug that caused infinite recursion when using `latLngBounds` factory with coordinates as string values. [#933](https://github.com/Leaflet/Leaflet/issues/933)
|
||||
* Fixed chaining on `Marker` `setIcon`, `setZIndexOffset`, `update` methods. [#1176](https://github.com/Leaflet/Leaflet/issues/1176)
|
||||
* Fixed a bug with mouse interaction when the map container contained children with position other than absolute. [#278](https://github.com/Leaflet/Leaflet/issues/278)
|
||||
* Fixed a bug with fill/stroke opacity conflicts when using Canvas for rendering (by [@danzel](https://github.com/danzel)). [#1186](https://github.com/Leaflet/Leaflet/issues/1186) [#1889](https://github.com/Leaflet/Leaflet/pull/1189)
|
||||
* Fixed a bug where `FeatureGroup` `bindPopup` didn't take options into account.
|
||||
* Fixed a bug where Canvas-based vector layers didn't cleanup click event on removal properly (by [@snkashis](https://github.com/snkashis)). [#1006](https://github.com/Leaflet/Leaflet/issues/1006) [#1273](https://github.com/Leaflet/Leaflet/pull/1273)
|
||||
* Fixed a bug where `CircleMarker` `setStyle` didn't take `radius` into account (by [@fdlk](https://github.com/fdlk)). [#1012](https://github.com/Leaflet/Leaflet/issues/1012) [#1013](https://github.com/Leaflet/Leaflet/pull/1013)
|
||||
* Fixed a bug where null GeoJSON geometries would throw an error instead of skipping (by [@brianherbert](https://github.com/brianherbert)). [#1240](https://github.com/Leaflet/Leaflet/pull/1240)
|
||||
* Fixed a bug where Canvas-based vector layers passed incorrect `layer` event property on click (by [@snkashis](https://github.com/snkashis)). [#1215](https://github.com/Leaflet/Leaflet/issues/1215) [#1243](https://github.com/Leaflet/Leaflet/pull/1243)
|
||||
* Fixed a bug where `TileLayer.WMS` didn't work correctly if the base URL contained query parameters (by [@snkashis](https://github.com/snkashis)). [#973](https://github.com/Leaflet/Leaflet/issues/973) [#1231](https://github.com/Leaflet/Leaflet/pull/1231)
|
||||
* Fixed a bug where removing a polyline in editing state wouldn't clean up the editing handles (by [@mehmeta](https://github.com/mehmeta)). [#1233](https://github.com/Leaflet/Leaflet/pull/1233)
|
||||
* Fixed a bug where removing a vector layer with a bound popup wouldn't clean up its click event properly (by [@yohanboniface](https://github.com/yohanboniface)). [#1229](https://github.com/Leaflet/Leaflet/pull/1229)
|
||||
* Fixed a bug where `GeoJSON` features with `GeometryCollection` didn't pass properties to `pointToLayer` function (by [@calvinmetcalf](https://github.com/calvinmetcalf)). [#1097](https://github.com/Leaflet/Leaflet/pull/1097)
|
||||
* Fixed `FeatureGroup` `eachLayer` chaining. [#1452](https://github.com/Leaflet/Leaflet/issues/1452)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* Fixed a bug with map **freezing after zoom on Android 4.1**. [#1182](https://github.com/Leaflet/Leaflet/issues/1182)
|
||||
* Fixed a bug where "Not implemented" error sometimes appeared in IE6-8 (by [@bryguy](https://github.com/bryguy) and [@lookfirst](https://github.com/lookfirst)). [#892](https://github.com/Leaflet/Leaflet/issues/892) [#893](https://github.com/Leaflet/Leaflet/pull/893)
|
||||
* Fixed compatibility with SmoothWheel extension for Firefox (by [@waldir](https://github.com/waldir)). [#1011](https://github.com/Leaflet/Leaflet/pull/1011)
|
||||
* Fixed a bug with popup layout in IE6-7 (by [@danzel](https://github.com/danzel)). [#1117](https://github.com/Leaflet/Leaflet/issues/1117)
|
||||
* Fixed a bug with incorrect box zoom opacity in IE6-7 (by [@jacobtoye](https://github.com/jacobtoye)). [#1072](https://githubcom/Leaflet/Leaflet/pull/1072)
|
||||
* Fixed a bug with box zoom throwing a JS error in IE6-7 (by [@danzel](https://github.com/danzel)). [#1071](https://github.com/Leaflet/Leaflet/pull/1071)
|
||||
* Fixed a bug where `TileLayer` `bringToFront/Back()` throwed an error in IE6-8. [#1168](https://github.com/Leaflet/Leaflet/issues/1168)
|
||||
* Fixed array type checking in the code to be more consistent in a cross-frame environment (by [@oslek](https://github.com/oslek)). [#1279](https://github.com/Leaflet/Leaflet/pull/1279)
|
||||
* Fixed a bug with `-` key not working in Firefox 15+ (thanks to [@mattesCZ](https://github.com/mattesCZ)). [#869](https://github.com/Leaflet/Leaflet/issues/869)
|
||||
|
||||
## 0.4.5 (October 25, 2012)
|
||||
|
||||
* Fixed a bug with **wonky zoom animation in IE10** (by [@danzel](https://github.com/danzel)). [#1007](https://github.com/Leaflet/Leaflet/pull/1007)
|
||||
* Fixed a bug with **wonky zoom animation in Chrome 23+** (by [@danzel](https://github.com/danzel)). [#1060](https://github.com/Leaflet/Leaflet/pull/1060) [#1056](https://github.com/Leaflet/Leaflet/issues/1056)
|
||||
|
||||
## 0.4.4 (August 7, 2012)
|
||||
|
||||
### Improvements
|
||||
|
||||
* Improved `GeoJSON` `setStyle` to also accept function (like the corresponding option).
|
||||
* Added `GeoJSON` `resetStyle(layer)`, useful for resetting hover state.
|
||||
* Added `feature` property to layers created with `GeoJSON` (containing the GeoJSON feature data).
|
||||
* Added `FeatureGroup` `bringToFront` and `bringToBack` methods (so that they would work for multipolys).
|
||||
* Added optional `animate` argument to `Map` `invalidateSize` (by [@ajbeaven](https://github.com/ajbeaven)). [#857](https://github.com/Leaflet/Leaflet/pull/857)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fixed a bug where tiles sometimes disappeared on initial map load on Android 2/3 (by [@danzel](https://github.com/danzel)). [#868](https://github.com/Leaflet/Leaflet/pull/868)
|
||||
* Fixed a bug where map would occasionally flicker near the border on zoom or pan on Chrome.
|
||||
* Fixed a bug where `Path` `bringToFront` and `bringToBack` didn't return `this`.
|
||||
* Removed zoom out on Win/Meta key binding (since it interferes with global keyboard shortcuts). [#869](https://github.com/Leaflet/Leaflet/issues/869)
|
||||
|
||||
## 0.4.2 (August 1, 2012)
|
||||
|
||||
* Fixed a bug where layers control radio buttons would not work correctly in IE7 (by [@danzel](https://github.com/danzel)). [#862](https://github.com/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/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)
|
||||
|
||||
### API simplification
|
||||
|
||||
Leaflet 0.4 contains several API improvements that allow simpler, jQuery-like syntax ([example](https://gist.github.com/3038879)) while being backwards compatible with the previous approach (so you can use both styles):
|
||||
|
||||
* Improved most methods and options to accept `LatLng`, `LatLngBounds`, `Point` and `Bounds` values in an array form (e.g. `map.panTo([lat, lng])` will be the same as `map.panTo(new L.LatLng(lat, lng))`)
|
||||
* Added `addTo` method to all layer classes, e.g. `marker.addTo(map)` is equivalent to `map.addLayer(marker)`
|
||||
* Added factory methods to most classes to be able to write code without `new` keyword, named the same as classes but starting with a lowercase letter, e.g. `L.map('map')` is the same as `new L.Map('map')`
|
||||
|
||||
### 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/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/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/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/Leaflet/Leaflet/pull/586)
|
||||
|
||||
#### GeoJSON API changes
|
||||
|
||||
GeoJSON API was improved to be simpler and more flexible ([example](https://gist.github.com/3062900)). The changes are not backwards-compatible, so be sure to update your old code.
|
||||
|
||||
* Added `style` option for styling vector layers, passed either as an object or as a function (to style vector layers according to GeoJSON properties).
|
||||
* Added `filter` option to leave out features that don't correspond to a certain criteria (e.g. based on properties).
|
||||
* Added `onEachFeature` option to execute certain code on each feature layer based on its properties (binding popups, etc).
|
||||
* Changed `pointToLayer` function signature to provide `geojson` in addition to `latlng` when creating point features for more flexibility.
|
||||
|
||||
#### Icon API changes
|
||||
|
||||
Icon API was improved to be more flexible, but one of the changes is backwards-incompatible: you now need to pass different icon properties (like `iconUrl`) inside an options object ([example](https://gist.github.com/3076084)).
|
||||
|
||||
* Converted `Icon` properties to options, changed constructor signature to `Icon(options)`.
|
||||
* Moved default marker icon options to `L.Icon.Default` class (which extends from `L.Icon`).
|
||||
* Added `Icon` `className` option to assign a custom class to an icon.
|
||||
* Added `Icon` `shadowAnchor` option to set the anchor of the shadow.
|
||||
* Made all `Icon` options except `iconUrl` optional (if not specified, they'll be chosen automatically or implemented using CSS). Anchor is centered by default (if size is specified), and otherwise can be set through CSS using negative margins.
|
||||
|
||||
#### Control API changes
|
||||
|
||||
* Added `setPosition` and `getPosition` to all controls, as well as ability to pass certain position as an option when creating a control.
|
||||
* Made controls implementation easier (now more magic happens under the hood).
|
||||
* Replaced ugly control position constants (e.g. `L.Control.Position.TOP_LEFT`) with light strings (`'topleft'`, `'bottomright'`, etc.)
|
||||
|
||||
#### Other breaking API changes
|
||||
|
||||
* Improved `TileLayer` constructor to interpolate URL template values from options (removed third `urlParams` argument).
|
||||
* Changed `TileLayer` `scheme: 'tms'` option to `tms: true`.
|
||||
* Removed `Map` `locateAndSetView` method (use `locate` with `setView: true` option)
|
||||
* Changed popup `minWidth` and `maxWidth` options to be applied to content element, not the whole popup.
|
||||
* Moved `prefix` argument to `options` in `Control.Attribution` constructor.
|
||||
* Renamed `L.VERSION` to `L.version`.
|
||||
|
||||
#### 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/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/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/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/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/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/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/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/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/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/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/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/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/Leaflet/Leaflet/pull/798)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* 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/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/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/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)
|
||||
|
||||
* Fixed a regression where default marker icons wouldn't work if Leaflet include url contained a query string.
|
||||
* Fixed a regression where tiles sometimes flickered with black on panning in iOS.
|
||||
|
||||
## 0.3 (February 13, 2012)
|
||||
|
||||
### Major features
|
||||
|
||||
* 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/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/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).
|
||||
|
||||
#### 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/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/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/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/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/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/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
|
||||
|
||||
* `shiftDragZoom` map option/property renamed to `boxZoom`.
|
||||
* Removed `mouseEventToLatLng` method (bringed back in 0.4).
|
||||
|
||||
#### Development workflow improvements
|
||||
|
||||
* Build system completely overhauled to be based on Node.js, Jake, JSHint and UglifyJS.
|
||||
* All code is now linted for errors and conformity with a strict code style (with JSHint), and wont build unless the check passes.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
#### General bugfixes
|
||||
|
||||
* 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/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/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/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/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/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/Leaflet/Leaflet/pull/358)
|
||||
|
||||
#### Browser bugfixes
|
||||
|
||||
* 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/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/Leaflet/Leaflet/issues/452)
|
||||
* Fixed a bug that caused click delays on zoom control.
|
||||
|
||||
|
||||
## 0.2.1 (2011-06-18)
|
||||
|
||||
* Fixed regression that caused error in `TileLayer.Canvas`.
|
||||
|
||||
## 0.2 (2011-06-17)
|
||||
|
||||
### Major features
|
||||
|
||||
* Added **WMS** support (`TileLayer.WMS` layer).
|
||||
* Added different **projections** support, having `EPSG:3857`, `EPSG:4326` and `EPSG:3395` out of the box (through `crs` option in `Map`). Thanks to [@Miroff](https://github.com/Miroff) & [@Komzpa](https://github.com/Komzpa) for great advice and explanation regarding this.
|
||||
* Added **GeoJSON** layer support.
|
||||
|
||||
### Improvements
|
||||
|
||||
#### Usability improvements
|
||||
|
||||
* 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/Leaflet/Leaflet/issues/61)
|
||||
|
||||
#### API improvements
|
||||
|
||||
* 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`.
|
||||
* Added `mouseover` and `mouseout` events to map, markers and paths; added map `mousemove` event.
|
||||
* Added `setLatLngs`, `spliceLatLngs`, `addLatLng`, `getLatLngs` methods to polylines and polygons.
|
||||
* Added `setLatLng` and `setRadius` methods to `Circle` and `CircleMarker`.
|
||||
* Improved `LatLngBounds contains` method to accept `LatLng` in addition to `LatLngBounds`, the same for `Bounds contains` and `Point`
|
||||
* Improved `LatLngBounds` & `Bounds` to allow their instantiation without arguments (by [@snc](https://github.com/snc)).
|
||||
* Added TMS tile numbering support through `TileLayer` `scheme: 'tms'` option (by [@tmcw](https://github.com/tmcw)).
|
||||
* Added `TileLayer` `noWrap` option to disable wrapping `x` tile coordinate (by [@jasondavies](https://github.com/jasondavies)).
|
||||
* Added `opacity` option and `setOpacity` method to `TileLayer`.
|
||||
* Added `setLatLng` and `setIcon` methods to `Marker`.
|
||||
* Added `title` option to `Marker`.
|
||||
* Added `maxZoom` argument to `map.locateAndSetView` method.
|
||||
* Added ability to pass Geolocation options to map `locate` and `locateAndSetView` methods (by [@JasonSanford](https://github.com/JasonSanford)).
|
||||
* Improved `Popup` to accept HTML elements in addition to strings as its content.
|
||||
|
||||
#### Development workflow improvements
|
||||
|
||||
* 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/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/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/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/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/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/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/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/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)
|
||||
|
||||
Initial Leaflet release.
|
155
CONTRIBUTING.md
155
CONTRIBUTING.md
@ -1,155 +0,0 @@
|
||||
Contributing to Leaflet
|
||||
=======================
|
||||
|
||||
1. [Getting Involved](#getting-involved)
|
||||
2. [Reporting Bugs](#reporting-bugs)
|
||||
3. [Contributing Code](#contributing-code)
|
||||
4. [Improving Documentation](#improving-documentation)
|
||||
|
||||
## Getting Involved
|
||||
|
||||
Third-party patches are absolutely essential on our quest to create the best mapping library that will ever exist.
|
||||
However, they're not the only way to get involved with the development of Leaflet.
|
||||
You can help the project tremendously by discovering and [reporting bugs](#reporting-bugs),
|
||||
[improving documentation](#improving-documentation),
|
||||
helping others on the [Leaflet forum](https://groups.google.com/forum/#!forum/leaflet-js)
|
||||
and [GitHub issues](https://github.com/Leaflet/Leaflet/issues),
|
||||
showing your support for your favorite feature suggestions on [Leaflet UserVoice page](http://leaflet.uservoice.com),
|
||||
tweeting to [@LeafletJS](http://twitter.com/LeafletJS)
|
||||
and spreading the word about Leaflet among your colleagues and friends.
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
Before reporting a bug on the project's [issues page](https://github.com/Leaflet/Leaflet/issues),
|
||||
first make sure that your issue is caused by Leaflet, not your application code
|
||||
(e.g. passing incorrect arguments to methods, etc.).
|
||||
Second, search the already reported issues for similar cases,
|
||||
and if it's already reported, just add any additional details in the comments.
|
||||
|
||||
After you made sure that you've found a new Leaflet bug,
|
||||
here are some tips for creating a helpful report that will make fixing it much easier and quicker:
|
||||
|
||||
* Write a **descriptive, specific title**. Bad: *Problem with polylines*. Good: *Doing X in IE9 causes Z*.
|
||||
* Include **browser, OS and Leaflet version** info in the description.
|
||||
* Create a **simple test case** that demonstrates the bug (e.g. using [JSFiddle](http://jsfiddle.net/)).
|
||||
* Check whether the bug can be reproduced in **other browsers**.
|
||||
* Check if the bug occurs in the stable version, master, or both.
|
||||
* *Bonus tip:* if the bug only appears in the master version but the stable version is fine,
|
||||
use `git bisect` to find the exact commit that introduced the bug.
|
||||
|
||||
If you just want some help with your project,
|
||||
try asking [on the Leaflet forum](https://groups.google.com/forum/#!forum/leaflet-js) instead.
|
||||
|
||||
## Contributing Code
|
||||
|
||||
### Considerations for Accepting Patches
|
||||
|
||||
While we happily accept patches, we're also commited to keeping Leaflet simple, lightweight and blazingly fast.
|
||||
So bugfixes, performance optimizations and small improvements that don't add a lot of code
|
||||
are much more likely to get accepted quickly.
|
||||
|
||||
Before sending a pull request with a new feature, first check if it's been discussed before already
|
||||
(either on [GitHub issues](https://github.com/Leaflet/Leaflet/issues)
|
||||
or [Leaflet UserVoice](http://leaflet.uservoice.com/)),
|
||||
and then ask yourself two questions:
|
||||
|
||||
1. Are you sure that this new feature is important enough to justify its presense in the Leaflet core?
|
||||
Or will it look better as a plugin in a separate repository?
|
||||
2. Is it written in a simple, concise way that doesn't add bulk to the codebase?
|
||||
|
||||
If your feature or API improvement did get merged into master,
|
||||
please consider submitting another pull request with the corresponding [documentation update](#improving-documentation).
|
||||
|
||||
### Setting up the Build System
|
||||
|
||||
To set up the Leaflet build system, install [Node](http://nodejs.org/),
|
||||
then run the following commands in the project root:
|
||||
|
||||
```
|
||||
npm install -g jake
|
||||
npm install
|
||||
```
|
||||
|
||||
You can build minified Leaflet by running `jake` (it will be built from source in the `dist` folder).
|
||||
For a custom build with selected components, open `build/build.html` in the browser and follow the instructions from there.
|
||||
|
||||
### Making Changes to Leaflet Source
|
||||
|
||||
If you're not yet familiar with the way GitHub works (forking, pull requests, etc.),
|
||||
be sure to check out the awesome [article about forking](https://help.github.com/articles/fork-a-repo)
|
||||
on the GitHub Help website — it will get you started quickly.
|
||||
|
||||
You should always write each batch of changes (feature, bugfix, etc.) in **its own topic branch**.
|
||||
Please do not commit to the `master` branch, or your unrelated changes will go into the same pull request.
|
||||
|
||||
You should also follow the code style and whitespace conventions of the original codebase.
|
||||
In particular, use tabs for indentation and spaces for alignment.
|
||||
|
||||
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.
|
||||
|
||||
Also, please make sure that you have [line endings configured properly](https://help.github.com/articles/dealing-with-line-endings) in Git! Otherwise the diff will show that all lines of a file were changed even if you touched only one.
|
||||
|
||||
Happy coding!
|
||||
|
||||
## Running the Tests
|
||||
|
||||
To run the tests from the command line,
|
||||
install [PhantomJS](http://phantomjs.org/) (and make sure it's in your `PATH`),
|
||||
then run:
|
||||
|
||||
```
|
||||
jake test
|
||||
```
|
||||
|
||||
To run all the tests in actual browsers at the same time, you can do:
|
||||
|
||||
```
|
||||
jake test --ff --chrome --safari --ie
|
||||
```
|
||||
|
||||
To run the tests in a browser manually, open `spec/index.html`.
|
||||
|
||||
## Code Coverage
|
||||
|
||||
To generate a detailed report about test coverage (which helps tremendously when working on test improvements), run:
|
||||
|
||||
```
|
||||
jake test --cov
|
||||
```
|
||||
|
||||
After that, open `spec/coverage/<environment>/index.html` in a browser to see the report.
|
||||
From there you can click through folders/files to get details on their individual coverage.
|
||||
|
||||
## Improving Documentation
|
||||
|
||||
The code of the live Leaflet website that contains all documentation and examples is located in the `gh-pages` branch
|
||||
and is automatically generated from a set of HTML and Markdown files by [Jekyll](https://github.com/mojombo/jekyll).
|
||||
|
||||
The easiest way to make little improvements such as fixing typos without even leaving the browser
|
||||
is by editing one of the files with the online GitHub editor:
|
||||
browse the [gh-pages branch](https://github.com/Leaflet/Leaflet/tree/gh-pages),
|
||||
choose a certain file for editing (e.g. `reference.html` for API reference),
|
||||
click the Edit button, make changes and follow instructions from there.
|
||||
Once it gets merged, the changes will immediately appear on the website.
|
||||
|
||||
If you need to make edits in a local repository to see how it looks in the process, do the following:
|
||||
|
||||
1. [Install Ruby](http://www.ruby-lang.org/en/) if don't have it yet.
|
||||
2. Run `gem install jekyll kramdown`. Alternatively, use bundler by using 'bundle install'
|
||||
3. Run `jekyll serve --watch` in the root `Leaflet` folder.
|
||||
4. Open `localhost:4000` in your browser.
|
||||
|
||||
Now any file changes will be updated when you reload pages automatically.
|
||||
After commiting the changes, just send a pull request.
|
||||
|
||||
If you need to update documentation according to a new feature that only appeared in the master version (not stable one),
|
||||
you need to make changes to `gh-pages-master` branch instead of `gh-pages`.
|
||||
It will get merged into the latter when released as stable.
|
||||
|
||||
## Thank You
|
||||
|
||||
Not only are we grateful for any contributions, — helping Leaflet and its community actually makes you AWESOME.
|
||||
Join [this approved list of awesome people](https://github.com/Leaflet/Leaflet/graphs/contributors)
|
||||
and help us push the limits of what's possible with online maps!
|
137
FAQ.md
137
FAQ.md
@ -1,137 +0,0 @@
|
||||
# Leaflet FAQ
|
||||
|
||||
This is a collection of answers to the most frequently asked questions about Leaflet.
|
||||
|
||||
1. [Data Providers](#data-providers)
|
||||
2. [Commercial Use and Licensing](#commercial-use-and-licensing)
|
||||
3. [Features](#features)
|
||||
4. [Performance](#performance)
|
||||
5. [Misc](#misc)
|
||||
|
||||
## Data Providers
|
||||
|
||||
#### The map is wrong in my neighborhood, could you fix it?
|
||||
|
||||
Nope, but you can.
|
||||
The map you see on Leaflet examples is based on [OpenStreetMap](http://openstreetmap.org),
|
||||
a free editable map of the world.
|
||||
Signing up and editing the map there is easy,
|
||||
and the changes will be reflected on the map in a few minutes.
|
||||
|
||||
#### What map tiles can I use with Leaflet? Is it limited to OpenStreetMap?
|
||||
|
||||
Leaflet is provider-agnostic, meaning you can use any map provider as long as you conform to its terms of use.
|
||||
You can roll your own tiles as well.
|
||||
[OpenStreetMap](http://openstreetmap.org) is the most popular data source among different tile providers,
|
||||
but there are providers that use other sources.
|
||||
|
||||
Check out [this example](http://leaflet-extras.github.io/leaflet-providers/preview/)
|
||||
with half a hundred different layers to choose from.
|
||||
Popular commercial options, free up to a particular number of requests, include
|
||||
[MapBox](http://mapbox.com),
|
||||
[Bing Maps](http://www.microsoft.com/maps/choose-your-binge's-maps-API.aspx) (using a [plugin](https://github.com/shramov/leaflet-plugins)),
|
||||
[Esri ArcGIS](http://www.arcgis.com/features/maps/imagery.html) ([official plugin](https://github.com/Esri/esri-leaflet))
|
||||
and [Nokia Here](http://developer.here.com/web-experiences).
|
||||
A notable exception is [MapQuest Open](http://developer.mapquest.com/web/products/open/map), which is free for any number of requests.
|
||||
|
||||
Always be sure to **read the terms of use** of a chosen tile provider, **know its limitations**, and **attribute it properly** in your app.
|
||||
|
||||
#### I'm looking for satellite imagery to use with my Leaflet map, any options?
|
||||
|
||||
[MapBox](http://mapbox.com),
|
||||
[Bing Maps](http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx),
|
||||
[ArcGIS](http://www.arcgis.com/features/maps/imagery.html)
|
||||
and [MapQuest Open](http://developer.mapquest.com/web/products/open/map) provide satellite imagery among others.
|
||||
|
||||
#### I want to use Google Maps API tiles with Leaflet, can I do that?
|
||||
|
||||
The problem with Google is that its [Terms of Use](https://developers.google.com/maps/terms?hl=ru) forbid any means of tile access other than through the Google Maps API.
|
||||
|
||||
You can add the Google Maps API as a Leaflet layer with a [plugin](https://github.com/shramov/leaflet-plugins). But note that the map experience will not be perfect, because Leaflet will just act as a proxy to the Google Maps JS engine, so you won't get all the performance and usability benefits of using Leaflet when the Google layer is on.
|
||||
|
||||
#### I want to roll my own OSM tile server for Leaflet, where do I start?
|
||||
|
||||
Check out [this excellent guide](http://switch2osm.org/serving-tiles/).
|
||||
|
||||
#### I want to create tiles from my own data for use with Leaflet, what are the options?
|
||||
|
||||
There's a number of services that allow you to do this easily,
|
||||
notably [MapBox](https://www.mapbox.com/), [CartoDB](http://cartodb.com/) and [GIS Cloud](http://www.giscloud.com/).
|
||||
If you want to make tiles on your own, probably the easiest way is using [TileMill](https://www.mapbox.com/tilemill/).
|
||||
TileMill can export your map as a single [.mbtiles](https://www.mapbox.com/developers/mbtiles/) file, which can be copied to a webserver and accessed by Leaflet with [a small PHP script](https://github.com/infostreams/mbtiles-php).
|
||||
Alternatively, you can [extract](https://github.com/mapbox/mbutil) the tiled images from the .mbtiles database and place them directly on your webserver with absolutely no server-side dependencies.
|
||||
|
||||
## Commercial Use and Licensing
|
||||
|
||||
#### I have an app that gets lots of hits a day, and I want to switch from Google/Bing/whatever to Leaflet. Is there a fee for using it?
|
||||
|
||||
Leaflet, unlike Google Maps and other all-in-one solutions, is just a JavaScript library.
|
||||
It's free to use, but doesn't provide map imagery on its own —
|
||||
you have to choose a tile service to combine with it.
|
||||
|
||||
There are [plenty of options](#what-map-tiles-can-i-use-with-leaflet-is-it-limited-to-openstreetmap) for a tile service,
|
||||
each with their own terms of use, prices (some of them free), features, limitations, etc.
|
||||
Choice is yours.
|
||||
|
||||
#### I'm building a commercial app that I plan to sell. Can I use Leaflet in it?
|
||||
|
||||
You're welcome, as the code is published under the very permissive [2-clause BSD License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE).
|
||||
Just make sure to attribute the use of the library somewhere in the app UI or the distribution
|
||||
(e.g. keep the Leaflet link on the map, or mention the use on the About page or a Readme file, etc.) and you'll be fine.
|
||||
|
||||
That only applies to the code though.
|
||||
Make sure you conform to the terms of use of the tile images provider(s) that you choose as well.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
#### Why is there still no feature X in Leaflet?
|
||||
|
||||
First of all, did you check out the [Leaflet plugins page](http://leafletjs.com/plugins.html)?
|
||||
It lists about a hundred plugins doing all kinds of crazy stuff,
|
||||
and there's a high possibility that it has what you're looking for.
|
||||
|
||||
Generally, we do our best to keep the Leaflet core small, lightweight and simple,
|
||||
focusing on _quality_ instead of _quantity_, and leaving all the rest to plugin authors.
|
||||
|
||||
Check out [this video](http://www.youtube.com/watch?v=_P2SaCPbJ4w) of a talk by the Leaflet creator for more background on the story and philosophy behind Leaflet.
|
||||
Another essential read is [Advocating Simplicity in Open Source](http://blog.universalmind.com/advocating-simplicity-in-open-source/) by the same guy.
|
||||
|
||||
|
||||
## Performance
|
||||
|
||||
#### I have thousands of markers on my map. How do I make it faster and more usable?
|
||||
|
||||
Check out the [Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster) plugin. It's amazing.
|
||||
|
||||
#### I have vector data with many thousands of points on my map. Any performance tips?
|
||||
|
||||
Leaflet generally does a pretty good job of handling heavy vector data
|
||||
with its real-time clipping and simplification algorithms,
|
||||
but browser technology still has its limits.
|
||||
Try [switching from SVG to Canvas as the default rendering back-end](http://leafletjs.com/reference.html#global),
|
||||
it may help considerably (depends on the app and the data).
|
||||
|
||||
If you still have too much data to render, you'll have to use some help of a server-side service
|
||||
like [MapBox](https://www.mapbox.com/),
|
||||
[CartoDB](http://cartodb.com/)
|
||||
and [GIS Cloud](http://www.giscloud.com/)
|
||||
(they all work great with Leaflet).
|
||||
What they do under the hood is serving rendered data as image tiles,
|
||||
along with additional data to enable interactivity like hovering shapes
|
||||
(e.g. done using [UTFGrid](https://www.mapbox.com/developers/utfgrid/) —
|
||||
Leaflet [has a nice plugin](https://github.com/danzel/Leaflet.utfgrid) for it).
|
||||
|
||||
|
||||
## Misc
|
||||
|
||||
#### I downloaded the Leaflet source but didn't find `leaflet.js` there. Why is that?
|
||||
|
||||
You can download the built versions using links from the [download page](http://leafletjs.com/download.html).
|
||||
It even includes the latest build of the development version (`master` branch),
|
||||
updated automatically on each commit to the repo.
|
||||
|
||||
We removed the built versions from the repository because it's a chore to build and commit them manually on each change,
|
||||
and it often complicates merging branches and managing contributions.
|
||||
|
||||
There's a common complaint that Leaflet can't be used with [Bower](http://bower.io/) because of that, but we'll resolve the issue soon.
|
48
Jakefile.js
48
Jakefile.js
@ -1,48 +0,0 @@
|
||||
/*
|
||||
Leaflet building, testing and linting scripts.
|
||||
|
||||
To use, install Node, then run the following commands in the project root:
|
||||
|
||||
npm install -g jake
|
||||
npm install
|
||||
|
||||
To check the code for errors and build Leaflet from source, run "jake".
|
||||
To run the tests, run "jake test".
|
||||
|
||||
For a custom build, open build/build.html in the browser and follow the instructions.
|
||||
*/
|
||||
|
||||
var build = require('./build/build.js');
|
||||
|
||||
function hint(msg, paths) {
|
||||
return function () {
|
||||
console.log(msg);
|
||||
jake.exec('node node_modules/jshint/bin/jshint -c ' + paths,
|
||||
{printStdout: true}, function () {
|
||||
console.log('\tCheck passed.\n');
|
||||
complete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
desc('Check Leaflet source for errors with JSHint');
|
||||
task('lint', {async: true}, hint('Checking for JS errors...', 'build/hintrc.js src'));
|
||||
|
||||
desc('Check Leaflet specs source for errors with JSHint');
|
||||
task('lintspec', {async: true}, hint('Checking for specs JS errors...', 'spec/spec.hintrc.js spec/suites'));
|
||||
|
||||
desc('Combine and compress Leaflet source files');
|
||||
task('build', {async: true}, function () {
|
||||
build.build(complete);
|
||||
});
|
||||
|
||||
desc('Run PhantomJS tests');
|
||||
task('test', ['lint', 'lintspec'], {async: true}, function () {
|
||||
build.test(complete);
|
||||
});
|
||||
|
||||
task('default', ['test', 'build']);
|
||||
|
||||
jake.addListener('complete', function () {
|
||||
process.exit();
|
||||
});
|
127
PLUGIN-GUIDE.md
127
PLUGIN-GUIDE.md
@ -1,127 +0,0 @@
|
||||
# Leaflet Plugin Authoring Guide
|
||||
|
||||
One of the greatest things about Leaflet is its powerful plugin ecosystem.
|
||||
The [Leaflet plugins page](http://leafletjs.com/plugins.html) lists dozens of awesome plugins, and more are being added every week.
|
||||
|
||||
This guide lists a number of best practices for publishing a Leaflet plugin that meets the quality standards of Leaflet itself.
|
||||
|
||||
1. [Presentation](#presentation)
|
||||
- [Repository](#repository)
|
||||
- [Name](#name)
|
||||
- [Demo](#demo)
|
||||
- [Readme](#readme)
|
||||
- [License](#license)
|
||||
2. [Code](#code)
|
||||
- [File Structure](#file-structure)
|
||||
- [Code Conventions](#code-conventions)
|
||||
- [Plugin API](#plugin-api)
|
||||
|
||||
## Presentation
|
||||
|
||||
### Repository
|
||||
|
||||
The best place to put your Leaflet plugin to is a separate [GitHub](http://github.com) repository.
|
||||
If you create a collection of plugins for different uses,
|
||||
don't put them in one repo —
|
||||
it's usually easier to work with small, self-contained plugins in individual repositories.
|
||||
|
||||
### Name
|
||||
|
||||
Most existing plugins follow the convention of naming plugins (and repos) like this: `Leaflet.MyPluginName`.
|
||||
You can use other forms (e.g. "leaflet-my-plugin-name"),
|
||||
just make sure to include the word "Leaflet" in the name so that it's obvious that it's a Leaflet plugin.
|
||||
|
||||
### Demo
|
||||
|
||||
The most essential thing to do when publishing a plugin is to include a demo that showcases what the plugin does —
|
||||
it's usually the first thing people will look for.
|
||||
|
||||
The easiest way to put up a demo is using [GitHub Pages](http://pages.github.com/).
|
||||
A good [starting point](https://help.github.com/articles/creating-project-pages-manually) is creating a `gh-pages` branch in your repo and adding an `index.html` page to it —
|
||||
after pushing, it'll be published as `http://<user>.github.io/<repo>`.
|
||||
|
||||
### Readme
|
||||
|
||||
The next thing you need to have is a descriptive `README.md` in the root of the repo (or a link to a website with a similar content).
|
||||
At a minimum it should contain the following items:
|
||||
|
||||
- name of the plugin
|
||||
- a simple, concise description of what it does
|
||||
- requirements
|
||||
- Leaflet version
|
||||
- other external dependencies (if any)
|
||||
- browser / device compatibility
|
||||
- links to demos
|
||||
- instructions for including the plugin
|
||||
- simple usage code example
|
||||
- API reference (methods, options, events)
|
||||
|
||||
### License
|
||||
|
||||
Every open source repository should include a license.
|
||||
If you don't know what open source license to choose for your code,
|
||||
[MIT License](http://opensource.org/licenses/MIT) and [BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause) are both good choices.
|
||||
You can either put it in the repo as a `LICENSE` file or just link to the license from the Readme.
|
||||
|
||||
## Code
|
||||
|
||||
### File Structure
|
||||
|
||||
Keep the file structure clean and simple,
|
||||
don't pile up lots of files in one place —
|
||||
make it easy for a new person to find their way in your repo.
|
||||
|
||||
A barebones repo for a simple plugin would look like this:
|
||||
|
||||
```
|
||||
my-plugin.js
|
||||
README.md
|
||||
```
|
||||
|
||||
An example of a more sophisticated plugin file structure:
|
||||
|
||||
```
|
||||
/src - JS source files
|
||||
/dist - minified plugin JS, CSS, images
|
||||
/spec - test files
|
||||
/lib - any external libraries/plugins if necessary
|
||||
/examples - HTML examples of plugin usage
|
||||
README.md
|
||||
LICENSE
|
||||
package.json
|
||||
```
|
||||
|
||||
### Code Conventions
|
||||
|
||||
Everyone's tastes are different, but it's important to be consistent with whatever conventions you choose for your plugin.
|
||||
|
||||
For a good starting point, check out [Airbnb JavaScript Guide](https://github.com/airbnb/javascript).
|
||||
Leaflet follows pretty much the same conventions
|
||||
except for using smart tabs (hard tabs for indentation, spaces for alignment)
|
||||
and putting a space after the `function` keyword.
|
||||
|
||||
### Plugin API
|
||||
|
||||
Never expose global variables in your plugin.<br>
|
||||
If you have a new class, put it directly in the `L` namespace (`L.MyPlugin`).<br>
|
||||
If you inherit one of the existing classes, make it a sub-property (`L.TileLayer.Banana`).<br>
|
||||
If you want to add new methods to existing Leaflet classes, you can do it like this: `L.Marker.include({myPlugin: …})`.
|
||||
|
||||
Function, method and property names should be in `camelCase`.<br>
|
||||
Class names should be in `CapitalizedCamelCase`.
|
||||
|
||||
If you have a lot of arguments in your function, consider accepting an options object instead
|
||||
(putting default values where possible so that users don't need specify all of them):
|
||||
|
||||
```js
|
||||
// bad
|
||||
marker.myPlugin('bla', 'foo', null, {}, 5, 0);
|
||||
|
||||
// good
|
||||
marker.myPlugin('bla', {
|
||||
optionOne: 'foo',
|
||||
optionThree: 5
|
||||
});
|
||||
```
|
||||
|
||||
And most importantly, keep it simple. Leaflet is all about *simplicity*.
|
227
build/build.html
227
build/build.html
@ -1,227 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet Build Helper</title>
|
||||
|
||||
<script type="text/javascript" src="deps.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font: 12px/1.4 Verdana, sans-serif;
|
||||
text-align: center;
|
||||
padding: 2em 0;
|
||||
}
|
||||
#container {
|
||||
text-align: left;
|
||||
margin: 0 auto;
|
||||
width: 780px;
|
||||
}
|
||||
#deplist {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
#deplist li {
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
#deplist li.heading {
|
||||
border: none;
|
||||
background: #ddd;
|
||||
padding: 5px 10px;
|
||||
margin-top: 25px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#deplist input {
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
display: inline;
|
||||
}
|
||||
#deplist label {
|
||||
float: left;
|
||||
width: 160px;
|
||||
font-weight: bold;
|
||||
}
|
||||
#deplist div {
|
||||
display: table-cell;
|
||||
height: 1%;
|
||||
}
|
||||
#deplist .desc {
|
||||
}
|
||||
|
||||
#deplist .deps {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
#command {
|
||||
width: 100%;
|
||||
}
|
||||
#command2 {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
#toolbar {
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<h1>Leaflet Build Helper</h1>
|
||||
|
||||
<p id="toolbar">
|
||||
<a id="select-all" href="#all">Select All</a> |
|
||||
<a id="deselect-all" href="#none">Deselect All</a>
|
||||
</p>
|
||||
|
||||
<ul id="deplist"></ul>
|
||||
|
||||
<h2>Building using Node and UglifyJS</h2>
|
||||
<ol>
|
||||
<li><a href="http://nodejs.org/#download">Download and install Node</a></li>
|
||||
<li>Run this in the command line:<br />
|
||||
<pre><code>npm install -g jake
|
||||
npm install</code></pre></li>
|
||||
<li>Run this command inside the Leaflet directory: <br /><input type="text" id="command2" />
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var deplist = document.getElementById('deplist'),
|
||||
commandInput = document.getElementById('command2');
|
||||
|
||||
document.getElementById('select-all').onclick = function() {
|
||||
var checks = deplist.getElementsByTagName('input');
|
||||
for (var i = 0; i < checks.length; i++) {
|
||||
checks[i].checked = true;
|
||||
}
|
||||
updateCommand();
|
||||
return false;
|
||||
};
|
||||
|
||||
document.getElementById('deselect-all').onclick = function() {
|
||||
var checks = deplist.getElementsByTagName('input');
|
||||
for (var i = 0; i < checks.length; i++) {
|
||||
if (!checks[i].disabled) {
|
||||
checks[i].checked = false;
|
||||
}
|
||||
}
|
||||
updateCommand();
|
||||
return false;
|
||||
};
|
||||
|
||||
function updateCommand() {
|
||||
var files = {};
|
||||
var checks = deplist.getElementsByTagName('input');
|
||||
var compsStr = '';
|
||||
|
||||
for (var i = 0, len = checks.length; i < len; i++) {
|
||||
if (checks[i].checked) {
|
||||
var srcs = deps[checks[i].id].src;
|
||||
for (var j = 0, len2 = srcs.length; j < len2; j++) {
|
||||
files[srcs[j]] = true;
|
||||
}
|
||||
compsStr = '1' + compsStr;
|
||||
} else {
|
||||
compsStr = '0' + compsStr;
|
||||
}
|
||||
}
|
||||
|
||||
commandInput.value = 'jake build[' + parseInt(compsStr, 2).toString(32) + ',custom]';
|
||||
}
|
||||
|
||||
function inputSelect() {
|
||||
this.focus();
|
||||
this.select();
|
||||
};
|
||||
|
||||
commandInput.onclick = inputSelect;
|
||||
|
||||
function onCheckboxChange() {
|
||||
if (this.checked) {
|
||||
var depDeps = deps[this.id].deps;
|
||||
if (depDeps) {
|
||||
for (var i = 0; i < depDeps.length; i++) {
|
||||
var check = document.getElementById(depDeps[i]);
|
||||
if (!check.checked) {
|
||||
check.checked = true;
|
||||
check.onchange();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var checks = deplist.getElementsByTagName('input');
|
||||
for (var i = 0; i < checks.length; i++) {
|
||||
var dep = deps[checks[i].id];
|
||||
if (!dep.deps) { continue; }
|
||||
for (var j = 0; j < dep.deps.length; j++) {
|
||||
if (dep.deps[j] === this.id) {
|
||||
if (checks[i].checked) {
|
||||
checks[i].checked = false;
|
||||
checks[i].onchange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateCommand();
|
||||
}
|
||||
|
||||
for (var name in deps) {
|
||||
var li = document.createElement('li');
|
||||
|
||||
if (deps[name].heading) {
|
||||
var heading = document.createElement('li');
|
||||
heading.className = 'heading';
|
||||
heading.appendChild(document.createTextNode(deps[name].heading));
|
||||
deplist.appendChild(heading);
|
||||
}
|
||||
|
||||
var div = document.createElement('div');
|
||||
|
||||
var label = document.createElement('label');
|
||||
|
||||
var check = document.createElement('input');
|
||||
check.type = 'checkbox';
|
||||
check.id = name;
|
||||
label.appendChild(check);
|
||||
check.onchange = onCheckboxChange;
|
||||
|
||||
if (name == 'Core') {
|
||||
check.checked = true;
|
||||
check.disabled = true;
|
||||
}
|
||||
|
||||
label.appendChild(document.createTextNode(name));
|
||||
label.htmlFor = name;
|
||||
|
||||
li.appendChild(label);
|
||||
|
||||
var desc = document.createElement('span');
|
||||
desc.className = 'desc';
|
||||
desc.appendChild(document.createTextNode(deps[name].desc));
|
||||
|
||||
var depText = deps[name].deps && deps[name].deps.join(', ');
|
||||
if (depText) {
|
||||
var depspan = document.createElement('span');
|
||||
depspan.className = 'deps';
|
||||
depspan.appendChild(document.createTextNode('Deps: ' + depText));
|
||||
}
|
||||
|
||||
div.appendChild(desc);
|
||||
div.appendChild(document.createElement('br'));
|
||||
if (depText) { div.appendChild(depspan); }
|
||||
|
||||
li.appendChild(div);
|
||||
|
||||
deplist.appendChild(li);
|
||||
}
|
||||
updateCommand();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
188
build/build.js
188
build/build.js
@ -1,188 +0,0 @@
|
||||
var fs = require('fs'),
|
||||
jshint = require('jshint'),
|
||||
UglifyJS = require('uglify-js'),
|
||||
zlib = require('zlib'),
|
||||
|
||||
deps = require('./deps.js').deps;
|
||||
|
||||
function getFiles(compsBase32) {
|
||||
var memo = {},
|
||||
comps;
|
||||
|
||||
if (compsBase32) {
|
||||
comps = parseInt(compsBase32, 32).toString(2).split('');
|
||||
console.log('Managing dependencies...');
|
||||
}
|
||||
|
||||
function addFiles(srcs) {
|
||||
for (var j = 0, len = srcs.length; j < len; j++) {
|
||||
memo[srcs[j]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in deps) {
|
||||
if (comps) {
|
||||
if (parseInt(comps.pop(), 2) === 1) {
|
||||
console.log(' * ' + i);
|
||||
addFiles(deps[i].src);
|
||||
} else {
|
||||
console.log(' ' + i);
|
||||
}
|
||||
} else {
|
||||
addFiles(deps[i].src);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
var files = [];
|
||||
|
||||
for (var src in memo) {
|
||||
files.push('src/' + src);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
exports.getFiles = getFiles;
|
||||
|
||||
function getSizeDelta(newContent, oldContent, fixCRLF) {
|
||||
if (!oldContent) {
|
||||
return ' (new)';
|
||||
}
|
||||
if (newContent === oldContent) {
|
||||
return ' (unchanged)';
|
||||
}
|
||||
if (fixCRLF) {
|
||||
newContent = newContent.replace(/\r\n?/g, '\n');
|
||||
oldContent = oldContent.replace(/\r\n?/g, '\n');
|
||||
}
|
||||
var delta = newContent.length - oldContent.length;
|
||||
|
||||
return delta === 0 ? '' : ' (' + (delta > 0 ? '+' : '') + delta + ' bytes)';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function bytesToKB(bytes) {
|
||||
return (bytes / 1024).toFixed(2) + ' KB';
|
||||
};
|
||||
|
||||
exports.build = function (callback, compsBase32, buildName) {
|
||||
|
||||
var files = getFiles(compsBase32);
|
||||
|
||||
console.log('Concatenating and compressing ' + files.length + ' files...');
|
||||
|
||||
var copy = fs.readFileSync('src/copyright.js', 'utf8'),
|
||||
intro = '(function (window, document, undefined) {',
|
||||
outro = '}(window, document));',
|
||||
newSrc = copy + intro + combineFiles(files) + outro,
|
||||
|
||||
pathPart = 'dist/leaflet' + (buildName ? '-' + buildName : ''),
|
||||
srcPath = pathPart + '-src.js',
|
||||
|
||||
oldSrc = loadSilently(srcPath),
|
||||
srcDelta = getSizeDelta(newSrc, oldSrc, true);
|
||||
|
||||
console.log('\tUncompressed: ' + bytesToKB(newSrc.length) + srcDelta);
|
||||
|
||||
if (newSrc !== oldSrc) {
|
||||
fs.writeFileSync(srcPath, newSrc);
|
||||
console.log('\tSaved to ' + srcPath);
|
||||
}
|
||||
|
||||
var path = pathPart + '.js',
|
||||
oldCompressed = loadSilently(path),
|
||||
newCompressed = copy + UglifyJS.minify(newSrc, {
|
||||
warnings: true,
|
||||
fromString: true
|
||||
}).code,
|
||||
delta = getSizeDelta(newCompressed, oldCompressed);
|
||||
|
||||
console.log('\tCompressed: ' + bytesToKB(newCompressed.length) + delta);
|
||||
|
||||
var newGzipped,
|
||||
gzippedDelta = '';
|
||||
|
||||
function done() {
|
||||
if (newCompressed !== oldCompressed) {
|
||||
fs.writeFileSync(path, newCompressed);
|
||||
console.log('\tSaved to ' + path);
|
||||
}
|
||||
console.log('\tGzipped: ' + bytesToKB(newGzipped.length) + gzippedDelta);
|
||||
callback();
|
||||
}
|
||||
|
||||
zlib.gzip(newCompressed, function (err, gzipped) {
|
||||
if (err) { return; }
|
||||
newGzipped = gzipped;
|
||||
if (oldCompressed && (oldCompressed !== newCompressed)) {
|
||||
zlib.gzip(oldCompressed, function (err, oldGzipped) {
|
||||
if (err) { return; }
|
||||
gzippedDelta = getSizeDelta(gzipped, oldGzipped);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.test = function(callback) {
|
||||
var karma = require('karma'),
|
||||
testConfig = {configFile : __dirname + '/../spec/karma.conf.js'};
|
||||
|
||||
testConfig.browsers = ['PhantomJS'];
|
||||
|
||||
function isArgv(optName) {
|
||||
return process.argv.indexOf(optName) !== -1;
|
||||
}
|
||||
|
||||
if (isArgv('--chrome')) {
|
||||
testConfig.browsers.push('Chrome');
|
||||
}
|
||||
if (isArgv('--safari')) {
|
||||
testConfig.browsers.push('Safari');
|
||||
}
|
||||
if (isArgv('--ff')) {
|
||||
testConfig.browsers.push('Firefox');
|
||||
}
|
||||
if (isArgv('--ie')) {
|
||||
testConfig.browsers.push('IE');
|
||||
}
|
||||
|
||||
if (isArgv('--cov')) {
|
||||
testConfig.preprocessors = {
|
||||
'../src/**/*.js': 'coverage'
|
||||
};
|
||||
testConfig.coverageReporter = {
|
||||
type : 'html',
|
||||
dir : 'coverage/'
|
||||
};
|
||||
testConfig.reporters = ['coverage'];
|
||||
}
|
||||
|
||||
console.log('Running tests...');
|
||||
|
||||
karma.server.start(testConfig, function(exitCode) {
|
||||
if (!exitCode) {
|
||||
console.log('\tTests ran successfully.\n');
|
||||
}
|
||||
callback();
|
||||
});
|
||||
};
|
259
build/deps.js
259
build/deps.js
@ -1,259 +0,0 @@
|
||||
var deps = {
|
||||
Core: {
|
||||
src: ['Leaflet.js',
|
||||
'core/Util.js',
|
||||
'core/Class.js',
|
||||
'core/Events.js',
|
||||
'core/Browser.js',
|
||||
'geometry/Point.js',
|
||||
'geometry/Bounds.js',
|
||||
'geometry/Transformation.js',
|
||||
'dom/DomUtil.js',
|
||||
'geo/LatLng.js',
|
||||
'geo/LatLngBounds.js',
|
||||
'geo/projection/Projection.js',
|
||||
'geo/projection/Projection.SphericalMercator.js',
|
||||
'geo/projection/Projection.LonLat.js',
|
||||
'geo/crs/CRS.js',
|
||||
'geo/crs/CRS.Simple.js',
|
||||
'geo/crs/CRS.EPSG3857.js',
|
||||
'geo/crs/CRS.EPSG4326.js',
|
||||
'map/Map.js'],
|
||||
desc: 'The core of the library, including OOP, events, DOM facilities, basic units, projections (EPSG:3857 and EPSG:4326) and the base Map class.'
|
||||
},
|
||||
|
||||
EPSG3395: {
|
||||
src: ['geo/projection/Projection.Mercator.js',
|
||||
'geo/crs/CRS.EPSG3395.js'],
|
||||
desc: 'EPSG:3395 projection (used by some map providers).',
|
||||
heading: 'Additional projections'
|
||||
},
|
||||
|
||||
TileLayer: {
|
||||
src: ['layer/tile/TileLayer.js'],
|
||||
desc: 'The base class for displaying tile layers on the map.',
|
||||
heading: 'Layers'
|
||||
},
|
||||
|
||||
TileLayerWMS: {
|
||||
src: ['layer/tile/TileLayer.WMS.js'],
|
||||
desc: 'WMS tile layer.',
|
||||
deps: ['TileLayer']
|
||||
},
|
||||
|
||||
TileLayerCanvas: {
|
||||
src: ['layer/tile/TileLayer.Canvas.js'],
|
||||
desc: 'Tile layer made from canvases (for custom drawing purposes).',
|
||||
deps: ['TileLayer']
|
||||
},
|
||||
|
||||
ImageOverlay: {
|
||||
src: ['layer/ImageOverlay.js'],
|
||||
desc: 'Used to display an image over a particular rectangular area of the map.'
|
||||
},
|
||||
|
||||
Marker: {
|
||||
src: ['layer/marker/Icon.js',
|
||||
'layer/marker/Icon.Default.js',
|
||||
'layer/marker/Marker.js'],
|
||||
desc: 'Markers to put on the map.'
|
||||
},
|
||||
|
||||
DivIcon: {
|
||||
src: ['layer/marker/DivIcon.js'],
|
||||
deps: ['Marker'],
|
||||
desc: 'Lightweight div-based icon for markers.'
|
||||
},
|
||||
|
||||
Popup: {
|
||||
src: ['layer/Popup.js',
|
||||
'layer/marker/Marker.Popup.js'],
|
||||
deps: ['Marker'],
|
||||
desc: 'Used to display the map popup (used mostly for binding HTML data to markers and paths on click).'
|
||||
},
|
||||
|
||||
LayerGroup: {
|
||||
src: ['layer/LayerGroup.js'],
|
||||
desc: 'Allows grouping several layers to handle them as one.'
|
||||
},
|
||||
|
||||
FeatureGroup: {
|
||||
src: ['layer/FeatureGroup.js'],
|
||||
deps: ['LayerGroup', 'Popup'],
|
||||
desc: 'Extends LayerGroup with mouse events and bindPopup method shared between layers.'
|
||||
},
|
||||
|
||||
Path: {
|
||||
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'
|
||||
},
|
||||
|
||||
PathVML: {
|
||||
src: ['layer/vector/Path.VML.js'],
|
||||
desc: 'VML fallback for vector rendering core (IE 6-8).'
|
||||
},
|
||||
|
||||
PathCanvas: {
|
||||
src: ['layer/vector/canvas/Path.Canvas.js'],
|
||||
deps: ['Path', 'Polyline', 'Polygon', 'Circle'],
|
||||
desc: 'Canvas fallback for vector rendering core (makes it work on Android 2+).'
|
||||
},
|
||||
|
||||
Polyline: {
|
||||
src: ['geometry/LineUtil.js',
|
||||
'layer/vector/Polyline.js'],
|
||||
deps: ['Path'],
|
||||
desc: 'Polyline overlays.'
|
||||
},
|
||||
|
||||
Polygon: {
|
||||
src: ['geometry/PolyUtil.js',
|
||||
'layer/vector/Polygon.js'],
|
||||
deps: ['Polyline'],
|
||||
desc: 'Polygon overlays.'
|
||||
},
|
||||
|
||||
MultiPoly: {
|
||||
src: ['layer/vector/MultiPoly.js'],
|
||||
deps: ['FeatureGroup', 'Polyline', 'Polygon'],
|
||||
desc: 'MultiPolygon and MultyPolyline layers.'
|
||||
},
|
||||
|
||||
Rectangle: {
|
||||
src: ['layer/vector/Rectangle.js'],
|
||||
deps: ['Polygon'],
|
||||
desc: ['Rectangle overlays.']
|
||||
},
|
||||
|
||||
Circle: {
|
||||
src: ['layer/vector/Circle.js'],
|
||||
deps: ['Path'],
|
||||
desc: 'Circle overlays (with radius in meters).'
|
||||
},
|
||||
|
||||
CircleMarker: {
|
||||
src: ['layer/vector/CircleMarker.js'],
|
||||
deps: ['Circle'],
|
||||
desc: 'Circle overlays with a constant pixel radius.'
|
||||
},
|
||||
|
||||
VectorsCanvas: {
|
||||
src: ['layer/vector/canvas/Polyline.Canvas.js',
|
||||
'layer/vector/canvas/Polygon.Canvas.js',
|
||||
'layer/vector/canvas/Circle.Canvas.js',
|
||||
'layer/vector/canvas/CircleMarker.Canvas.js'],
|
||||
deps: ['PathCanvas', 'Polyline', 'Polygon', 'Circle', 'CircleMarker'],
|
||||
desc: 'Canvas fallback for vector layers (polygons, polylines, circles, circlemarkers)'
|
||||
},
|
||||
|
||||
GeoJSON: {
|
||||
src: ['layer/GeoJSON.js'],
|
||||
deps: ['CircleMarker', 'Marker', 'MultiPoly', 'FeatureGroup'],
|
||||
desc: 'GeoJSON layer, parses the data and adds corresponding layers above.'
|
||||
},
|
||||
|
||||
|
||||
MapDrag: {
|
||||
src: ['dom/DomEvent.js',
|
||||
'dom/Draggable.js',
|
||||
'core/Handler.js',
|
||||
'map/handler/Map.Drag.js'],
|
||||
desc: 'Makes the map draggable (by mouse or touch).',
|
||||
heading: 'Interaction'
|
||||
},
|
||||
|
||||
MouseZoom: {
|
||||
src: ['dom/DomEvent.js',
|
||||
'core/Handler.js',
|
||||
'map/handler/Map.DoubleClickZoom.js',
|
||||
'map/handler/Map.ScrollWheelZoom.js'],
|
||||
desc: 'Scroll wheel zoom and double click zoom on the map.'
|
||||
},
|
||||
|
||||
TouchZoom: {
|
||||
src: ['dom/DomEvent.js',
|
||||
'dom/DomEvent.DoubleTap.js',
|
||||
'dom/DomEvent.Pointer.js',
|
||||
'core/Handler.js',
|
||||
'map/handler/Map.TouchZoom.js',
|
||||
'map/handler/Map.Tap.js'],
|
||||
deps: ['AnimationZoom'],
|
||||
desc: 'Enables smooth touch zoom / tap / longhold / doubletap on iOS, IE10, Android.'
|
||||
},
|
||||
|
||||
BoxZoom: {
|
||||
src: ['map/handler/Map.BoxZoom.js'],
|
||||
desc: 'Enables zooming to bounding box by shift-dragging the map.'
|
||||
},
|
||||
|
||||
Keyboard: {
|
||||
src: ['map/handler/Map.Keyboard.js'],
|
||||
desc: 'Enables keyboard pan/zoom when the map is focused.'
|
||||
},
|
||||
|
||||
MarkerDrag: {
|
||||
src: ['layer/marker/Marker.Drag.js'],
|
||||
deps: ['Marker'],
|
||||
desc: 'Makes markers draggable (by mouse or touch).'
|
||||
},
|
||||
|
||||
ControlZoom: {
|
||||
src: ['control/Control.js',
|
||||
'control/Control.Zoom.js'],
|
||||
heading: 'Controls',
|
||||
desc: 'Basic zoom control with two buttons (zoom in / zoom out).'
|
||||
},
|
||||
|
||||
ControlAttrib: {
|
||||
src: ['control/Control.js',
|
||||
'control/Control.Attribution.js'],
|
||||
desc: 'Attribution control.'
|
||||
},
|
||||
|
||||
ControlScale: {
|
||||
src: ['control/Control.js',
|
||||
'control/Control.Scale.js'],
|
||||
desc: 'Scale control.'
|
||||
},
|
||||
|
||||
ControlLayers: {
|
||||
src: ['control/Control.js',
|
||||
'control/Control.Layers.js'],
|
||||
desc: 'Layer Switcher control.'
|
||||
},
|
||||
|
||||
AnimationPan: {
|
||||
src: [
|
||||
'dom/DomEvent.js',
|
||||
'dom/PosAnimation.js',
|
||||
'map/anim/Map.PanAnimation.js'
|
||||
],
|
||||
heading: 'Animation',
|
||||
desc: 'Core panning animation support.'
|
||||
},
|
||||
|
||||
AnimationTimer: {
|
||||
src: ['dom/PosAnimation.Timer.js'],
|
||||
deps: ['AnimationPan'],
|
||||
desc: 'Timer-based pan animation fallback for browsers that don\'t support CSS3 transitions.'
|
||||
},
|
||||
|
||||
AnimationZoom: {
|
||||
src: ['map/anim/Map.ZoomAnimation.js', 'layer/tile/TileLayer.Anim.js'],
|
||||
deps: ['AnimationPan'],
|
||||
desc: 'Smooth zooming animation. Works only on browsers that support CSS3 Transitions.'
|
||||
},
|
||||
|
||||
Geolocation: {
|
||||
src: ['map/ext/Map.Geolocation.js'],
|
||||
desc: 'Adds Map#locate method and related events to make geolocation easier.',
|
||||
heading: 'Misc'
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof exports !== 'undefined') {
|
||||
exports.deps = deps;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
{
|
||||
// environment
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"globals": {
|
||||
"L": true,
|
||||
"define": true
|
||||
},
|
||||
"strict": false,
|
||||
|
||||
// code style
|
||||
"bitwise": true,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"quotmark": "single",
|
||||
|
||||
// whitespace
|
||||
"indent": 4,
|
||||
"trailing": true,
|
||||
"white": true,
|
||||
"smarttabs": true,
|
||||
"maxlen": 120
|
||||
|
||||
// code simplicity - not enforced but nice to check from time to time
|
||||
// "maxstatements": 20,
|
||||
// "maxcomplexity": 5
|
||||
// "maxparams": 4,
|
||||
// "maxdepth": 4
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
html, body, #map {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 600px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1 maximum-scale=1.0 user-scalable=0">
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<div >
|
||||
<form method="get">Click in field then scroll map (in up/left direction) to see shift of map tiles.
|
||||
<fieldset><label for="textField">Name</label>:
|
||||
<input id="textField" name="textField" type="text" value="">
|
||||
</fieldset>
|
||||
</form>
|
||||
Bug tested to occur on: Safari on Mac (Tested in 5.1.7), iPad/iPhone 5.1.1., Android 4 Browser. Hack is in L.Browser.chrome and TileLayer._addTile
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/997/256/{z}/{x}/{y}.png', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6'
|
||||
});
|
||||
|
||||
//Disable the hack fix
|
||||
L.Browser.chrome = true;
|
||||
|
||||
var map = L.map('map')
|
||||
.setView([50.5, 30.51], 15)
|
||||
.addLayer(cloudmade);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,59 +0,0 @@
|
||||
(function() {
|
||||
function getFiles() {
|
||||
var memo = {},
|
||||
files = [],
|
||||
i, src;
|
||||
|
||||
function addFiles(srcs) {
|
||||
for (var j = 0, len = srcs.length; j < len; j++) {
|
||||
memo[srcs[j]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (i in deps) {
|
||||
addFiles(deps[i].src);
|
||||
}
|
||||
|
||||
for (src in memo) {
|
||||
files.push(src);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
var scripts = getFiles();
|
||||
|
||||
function getSrcUrl() {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var src = scripts[i].src;
|
||||
if (src) {
|
||||
var res = src.match(/^(.*)leaflet-include\.js$/);
|
||||
if (res) {
|
||||
return res[1] + '../src/';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var path = getSrcUrl();
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
document.writeln("<script src='" + path + scripts[i] + "'></script>");
|
||||
}
|
||||
document.writeln('<script defer>L.Icon.Default.imagePath = "' + path + '../dist/images";</script>');
|
||||
})();
|
||||
|
||||
function getRandomLatLng(map) {
|
||||
var bounds = map.getBounds(),
|
||||
southWest = bounds.getSouthWest(),
|
||||
northEast = bounds.getNorthEast(),
|
||||
lngSpan = northEast.lng - southWest.lng,
|
||||
latSpan = northEast.lat - southWest.lat;
|
||||
|
||||
return new L.LatLng(
|
||||
southWest.lat + latSpan * Math.random(),
|
||||
southWest.lng + lngSpan * Math.random());
|
||||
}
|
||||
|
||||
function logEvent(e) {
|
||||
console.log(e.type);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var tiles = new L.TileLayer.Canvas();
|
||||
|
||||
tiles.drawTile = function(canvas, tile, zoom) {
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillRect(0, 0, 255, 255);
|
||||
|
||||
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillText('x: ' + tile.x + ', y: ' + tile.y + ', zoom:' + zoom, 20, 20);
|
||||
|
||||
|
||||
ctx.strokeStyle = 'red';
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.lineTo(255, 0);
|
||||
ctx.lineTo(255, 255);
|
||||
ctx.lineTo(0, 255);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
var map = new L.Map('map', {center: new L.LatLng(50.5, 30.51), zoom: 15, layers: [tiles]});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,49 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function getCloudMadeUrl(styleId) {
|
||||
return 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/' + styleId + '/256/{z}/{x}/{y}.png';
|
||||
}
|
||||
|
||||
var cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(getCloudMadeUrl(997), {attribution: cloudmadeAttribution}),
|
||||
cloudmade2 = new L.TileLayer(getCloudMadeUrl(998), {attribution: 'Hello world'});
|
||||
|
||||
var map = new L.Map('map').addLayer(cloudmade).setView(new L.LatLng(50.5, 30.512), 15);
|
||||
|
||||
var marker = new L.Marker(new L.LatLng(50.5, 30.505), {color: 'red'});
|
||||
map.addLayer(marker);
|
||||
marker.bindPopup("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 still being accessible on older ones.").openPopup();
|
||||
|
||||
var marker2 = new L.Marker(new L.LatLng(50.502, 30.515));
|
||||
map.addLayer(marker2);
|
||||
|
||||
var layersControl = new L.Control.Layers({
|
||||
'CloudMade Fresh': cloudmade,
|
||||
'CloudMade Pale Dawn': cloudmade2
|
||||
}, {
|
||||
'Some marker': marker,
|
||||
'Another marker': marker2
|
||||
});
|
||||
|
||||
map.addControl(layersControl);
|
||||
map.addControl(new L.Control.Scale());
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet geolocation debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<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 cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
||||
|
||||
var map = new L.Map('map', {zoom: 15, layers: [cloudmade]});
|
||||
|
||||
function logEvent(e) { console.log(e.type); }
|
||||
map.on('locationerror', logEvent);
|
||||
map.on('locationfound', logEvent);
|
||||
|
||||
map.locate({setView: true});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,11 +0,0 @@
|
||||
<style>
|
||||
iframe {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
left: 50px;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
</style>
|
||||
<iframe src="map.html">
|
||||
</iframe>
|
@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<button id="populate">Populate with 10 markers</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
latlng = new L.LatLng(50.5, 30.51);
|
||||
|
||||
var map = new L.Map('map');
|
||||
map.addLayer(cloudmade);
|
||||
|
||||
var bounds = new L.LatLngBounds(
|
||||
new L.LatLng(40.71222,-74.22655),
|
||||
new L.LatLng(40.77394,-74.12544));
|
||||
|
||||
map.fitBounds(bounds);
|
||||
|
||||
var overlay = new L.ImageOverlay("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg", bounds, {
|
||||
opacity: 0.5
|
||||
});
|
||||
map.addLayer(overlay);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,34 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
latlng = new L.LatLng(50.5, 30.51);
|
||||
|
||||
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
||||
|
||||
var marker = new L.Marker(latlng);
|
||||
map.addLayer(marker);
|
||||
|
||||
marker.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.</p>");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<button id="populate">Populate with 10 markers</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/997/256/{z}/{x}/{y}.png', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © 2011 <a href="#">OpenStreetMap</a> contributors, Imagery © 2011 <a href="#">CloudMade</a>',
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6'
|
||||
});
|
||||
|
||||
var map = L.map('map')
|
||||
.setView([50.5, 30.51], 15)
|
||||
.addLayer(cloudmade);
|
||||
|
||||
var markers = new L.FeatureGroup();
|
||||
|
||||
function populate() {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
markers.addLayer(new L.Marker(getRandomLatLng(map)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
markers.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.</p>");
|
||||
|
||||
map.addLayer(markers);
|
||||
|
||||
populate();
|
||||
L.DomUtil.get('populate').onclick = populate;
|
||||
|
||||
// function logEvent(e) { console.log(e.type); }
|
||||
//
|
||||
// map.on('movestart', logEvent);
|
||||
// map.on('move', logEvent);
|
||||
// map.on('moveend', logEvent);
|
||||
//
|
||||
// map.on('zoomstart', logEvent);
|
||||
// map.on('zoomend', logEvent);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
bounds = new L.LatLngBounds(new L.LatLng(49.5, -11.3), new L.LatLng(61.2, 2.5));
|
||||
|
||||
var map = new L.Map('map', {
|
||||
center: bounds.getCenter(),
|
||||
zoom: 7,
|
||||
layers: [cloudmade],
|
||||
maxBounds: bounds
|
||||
});
|
||||
|
||||
var latlngs = L.rectangle(bounds).getLatLngs();
|
||||
L.polyline(latlngs.concat([latlngs[0]])).addTo(map);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,223 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<style>
|
||||
.mapcontainer {
|
||||
float:left;
|
||||
position: relative;
|
||||
width: 32%;
|
||||
font-size: 12px;
|
||||
font-family: sans-serif;
|
||||
height: 340px;
|
||||
margin-bottom: 15px;
|
||||
background-color: #eee;
|
||||
margin-right: 1%;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 280px;
|
||||
bottom: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>These should all render identically.</p>
|
||||
<div class="mapcontainer">
|
||||
CASE 1: no opacity set on any layers
|
||||
<br />
|
||||
<div id="map1" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 2: opacity set to .99 on overlays but not on basemap
|
||||
<br />
|
||||
<div id="map2" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 3: opacity set on overlays but not on basemap, zIndex option set to 0 on basemap
|
||||
<br />
|
||||
<div id="map3" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 4: opacity set to .99 on overlays but set to 1 on basemap
|
||||
<br />
|
||||
<div id="map4" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 5: opacity set to .99 on all layers
|
||||
<br />
|
||||
<div id="map5" class="map"></div>
|
||||
</div>
|
||||
<div class="mapcontainer">
|
||||
CASE 6: opacity set to .99 on 1st and 3rd layers and 1 on middle layer
|
||||
<br />
|
||||
<div id="map6" class="map"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var mapopts = {
|
||||
center: [35, -122],
|
||||
zoom : 5
|
||||
};
|
||||
|
||||
var map1 = L.map('map1', mapopts);
|
||||
var map2 = L.map('map2', mapopts);
|
||||
var map3 = L.map('map3', mapopts);
|
||||
var map4 = L.map('map4', mapopts);
|
||||
var map5 = L.map('map5', mapopts);
|
||||
var map6 = L.map('map6', mapopts);
|
||||
|
||||
/**********
|
||||
CASE 1: no opacity set on any layers
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm1 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941
|
||||
}).addTo(map1);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez1 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true
|
||||
}).addTo(map1);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa1 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false
|
||||
}).addTo(map1);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 2: opacity set on overlays but not on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm2 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941
|
||||
}).addTo(map2);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez2 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map2);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa2 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map2);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 3: opacity set on overlays but not on basemap, zIndex option set to 0 on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm3 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
zIndex: 0
|
||||
}).addTo(map3);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez3 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map3);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa3 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map3);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 4: opacity set on overlays but set to 1 on basemap
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm4 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 1
|
||||
}).addTo(map4);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez4 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map4);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa4 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map4);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 5: opacity set to .5 on all layers
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm5 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez5 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa5 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map5);
|
||||
|
||||
|
||||
/**********
|
||||
CASE 6: opacity set to .5 on 1st and 3rd layers and 1 on middle layer
|
||||
**********/
|
||||
// OSM Basemap
|
||||
var osm6 = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png?v=1', {
|
||||
attribution: '',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707',
|
||||
styleId: 97941,
|
||||
opacity: 0.99
|
||||
}).addTo(map6);
|
||||
|
||||
// EEZs / Nations
|
||||
var eez6 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/eezs/{z}/{x}/{y}.png', {
|
||||
tms: true,
|
||||
opacity: 1
|
||||
}).addTo(map6);
|
||||
|
||||
// Marine Protected Areas overlay
|
||||
var mpa6 = new L.tileLayer('http://tile1.mpatlas.org/tilecache/mpas/{z}/{x}/{y}.png', {
|
||||
tms: false,
|
||||
opacity: 0.99
|
||||
}).addTo(map6);
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,41 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="position: absolute; top: 100px; left: 100px; border: 1px solid green">
|
||||
<div style="position: relative; margin-top: 500px; width: 800px; border: 1px solid red; margin-left: 200px">
|
||||
<div style="height: 600px; overflow: auto">
|
||||
<div id="map" style="width: 600px; height: 1000px; border: 1px solid #ccc"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
latlng = new L.LatLng(50.5, 30.51);
|
||||
|
||||
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
||||
|
||||
var s = '';
|
||||
for (var i = 0; i < 100; i++) s += 'Test<br>';
|
||||
|
||||
var popup = L.popup({maxHeight: 100})
|
||||
.setContent(s)
|
||||
.setLatLng(latlng)
|
||||
.openOn(map);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</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>
|
@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 1024px; height: 440px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var map = new L.Map('map', {crs: L.CRS.EPSG4326});
|
||||
|
||||
var bluemarble = new L.TileLayer.WMS("http://maps.opengeo.org/geowebcache/service/wms", {
|
||||
layers: 'bluemarble',
|
||||
attribution: "Data © NASA Blue Marble, image service by OpenGeo",
|
||||
minZoom: 2,
|
||||
maxZoom: 5
|
||||
});
|
||||
|
||||
map.addLayer(bluemarble).fitWorld();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var map = new L.Map('map');
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/{styleId}/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {styleId: 997, attribution: cloudmadeAttribution}),
|
||||
cloudmade2 = new L.TileLayer(cloudmadeUrl, {styleId: 998, attribution: cloudmadeAttribution});
|
||||
|
||||
var nexrad = new L.TileLayer.WMS("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
|
||||
layers: 'nexrad-n0r-900913',
|
||||
format: 'image/png',
|
||||
transparent: true,
|
||||
attribution: "Weather data © 2011 IEM Nexrad",
|
||||
opacity: 0.4
|
||||
});
|
||||
|
||||
var bounds = new L.LatLngBounds(new L.LatLng(32, -126), new L.LatLng(50, -64));
|
||||
|
||||
map.addLayer(cloudmade).addLayer(nexrad).fitBounds(bounds);
|
||||
|
||||
L.control.layers({"CM": cloudmade, "CM2": cloudmade2}, {"NexRad": nexrad}).addTo(map);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,45 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<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/d4fc77ea4a63471cab2423e66626cbb6/' + styleId + '/256/{z}/{x}/{y}.png';
|
||||
}
|
||||
|
||||
var map = L.map('map').setView(L.latLng(50.5, 30.51), 0);
|
||||
|
||||
var cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = L.tileLayer(getCloudMadeUrl(997), {attribution: cloudmadeAttribution, minZoom: 0, maxZoom: 10}).addTo(map),
|
||||
cloudmade2 = L.tileLayer(getCloudMadeUrl(998), {attribution: 'Hello world', minZoom: 5, maxZoom: 18});
|
||||
|
||||
L.control.layers({
|
||||
'CloudMade Pale Dawn (5-18)': cloudmade2,
|
||||
'CloudMade Fresh (0-10)': cloudmade
|
||||
}).addTo(map);
|
||||
|
||||
L.control.scale().addTo(map);
|
||||
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
L.marker(getRandomLatLng(map)).addTo(map);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,87 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<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>
|
@ -1,37 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<button id="foo">Click to add layer, then zoom out or in</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = new L.Map('map', { center: new L.LatLng(45.50144, -122.67599), zoom: 4 });
|
||||
|
||||
var demoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/tile/{z}/{y}/{x}';
|
||||
var demoMap = new L.TileLayer(demoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
|
||||
map.addLayer(demoMap);
|
||||
|
||||
$('#foo').click(function() {
|
||||
var topoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}';
|
||||
var topoMap = new L.TileLayer(topoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
map.addLayer(topoMap);
|
||||
topoMap.bringToBack();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,47 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
<script>
|
||||
L_PREFER_CANVAS = true;
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
//Init a map, and attempt a locate.
|
||||
var map = L.map('map', {
|
||||
center: [39.84, -96.591],
|
||||
zoom: 4
|
||||
}).locate();
|
||||
|
||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
var vanillaLayer = new L.LayerGroup();
|
||||
map.addLayer(vanillaLayer);
|
||||
|
||||
map.on('moveend',function(e) {
|
||||
console.log('moveend fired.')
|
||||
});
|
||||
|
||||
//For experiments using setRadius
|
||||
window.marker = L.circleMarker(map.getCenter(),{radius:30}).addTo(vanillaLayer);
|
||||
});
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
|
||||
<script src="../leaflet-include.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,58 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<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 cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
|
||||
|
||||
var map = L.map('map', {
|
||||
minZoom: 1,
|
||||
maxZoom: 19,
|
||||
center: [51.505, -0.09],
|
||||
zoom: 9,
|
||||
layers: [cloudmade]
|
||||
});
|
||||
|
||||
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: 10,
|
||||
opacity: 1,
|
||||
smoothFactor: 1,
|
||||
color: 'red',
|
||||
clickable:true
|
||||
}));
|
||||
|
||||
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 type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
@ -1,49 +0,0 @@
|
||||
<!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>
|
@ -1,61 +0,0 @@
|
||||
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
On the left Map dragging and worldCopyJump are enabled during initialisation.<br>
|
||||
On the right Map worldCopyJump is enabled. Dragging is enabled by clicking the button.
|
||||
</p>
|
||||
<button id="foo">
|
||||
Click to enable dragging on the right map, then dragging around and watch copying
|
||||
</button><br>
|
||||
<div id="map1" style="height: 300px;width: 400px; float:left;"></div>
|
||||
<div id="map2" style="height: 300px;width: 400px; float:left; margin-left: 10px;"></div>
|
||||
<div style="clear:both"></div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function addLayerAndMarker(map) {
|
||||
var layer = new L.TileLayer('http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png', {
|
||||
maxZoom : 18
|
||||
}).addTo(map);
|
||||
|
||||
var marker = L.marker([50.5, 30.5]).addTo(map);
|
||||
|
||||
}
|
||||
var map1 = new L.Map('map1', {
|
||||
center : new L.LatLng(45.50144, -122.67599),
|
||||
zoom : 0,
|
||||
dragging : true,
|
||||
worldCopyJump : true
|
||||
});
|
||||
var map2 = new L.Map('map2', {
|
||||
center : new L.LatLng(45.50144, -122.67599),
|
||||
zoom : 0,
|
||||
dragging : false,
|
||||
worldCopyJump : true
|
||||
});
|
||||
$("#foo").click(function() {
|
||||
map2.dragging.enable();
|
||||
});
|
||||
|
||||
|
||||
|
||||
addLayerAndMarker(map1);
|
||||
addLayerAndMarker(map2);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,56 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
<style>
|
||||
.mybox {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
latlng = new L.LatLng(50.5, 30.51);
|
||||
|
||||
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
||||
|
||||
//Create a marker, clicking it toggles opacity
|
||||
var marker = new L.Marker(latlng, { icon: new L.DivIcon({ className: 'mybox', iconSize: new L.Point(100,100), html: 'opaque. click to toggle' }) });
|
||||
map.addLayer(marker);
|
||||
|
||||
var visible = true;
|
||||
marker.on('click', function () {
|
||||
if (visible) {
|
||||
marker.setOpacity(0.3);
|
||||
marker._icon.innerHTML = 'transparent';
|
||||
} else {
|
||||
marker.setOpacity(1);
|
||||
marker._icon.innerHTML = 'opaque';
|
||||
}
|
||||
visible = !visible;
|
||||
});
|
||||
|
||||
var marker2 = new L.Marker(new L.LatLng(50.5, 30.52));
|
||||
map.addLayer(marker2);
|
||||
marker2.bindPopup('This is an amazing message. I shouldn\'t of deleted the Ipsum text');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
<button id="populate">Populate with 10 markers</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = L.map('map').setView([36.9, -95.4], 5);
|
||||
map.on('contextmenu', function (e) {
|
||||
alert('The map has been right-clicked');
|
||||
});
|
||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
key: 'BC9A493B41014CAABB98F0471D759707'
|
||||
}).addTo(map);
|
||||
|
||||
|
||||
|
||||
var exampleGeoJSON = {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[-90.0, 35.0],
|
||||
[-90.0, 45.0],
|
||||
[-100.0, 45.0],
|
||||
[-100.0, 35.0]
|
||||
]
|
||||
]
|
||||
};
|
||||
|
||||
var geoJsonLayer = L.geoJson(exampleGeoJSON, {
|
||||
onEachFeature: function (feature, layer) {
|
||||
layer.on('contextmenu', function (e) {
|
||||
alert('The GeoJSON layer has been clicked');
|
||||
});
|
||||
}
|
||||
}).addTo(map);
|
||||
|
||||
var marker = L.marker([36, -95]).addTo(map);
|
||||
marker.bindPopup('Right-click me <br> to test contextmenu <br> event capture').openPopup();
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = L.map('map').setView( [50, 50], 10);
|
||||
var marker = L.marker([50, 50], {draggable: true}).addTo(map);
|
||||
|
||||
setTimeout(function() {
|
||||
map.removeLayer(marker);
|
||||
}, 3000);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,41 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = new L.Map('map', { center: new L.LatLng(45.50144, -122.67599), zoom: 4 });
|
||||
|
||||
var demoUrl='http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/tile/{z}/{y}/{x}';
|
||||
var demoMap = new L.TileLayer(demoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
|
||||
var topoUrl = 'http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}';
|
||||
var topoMap = new L.TileLayer(topoUrl, { maxZoom: 19, attribution: 'Tiles: © Esri' });
|
||||
map.addLayer(topoMap);
|
||||
|
||||
map.addLayer(demoMap);
|
||||
|
||||
map.on('dragstart', function () {
|
||||
console.log('dragstart');
|
||||
setTimeout(function () {
|
||||
console.log('removing');
|
||||
map.removeLayer(demoMap);
|
||||
}, 400);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script>
|
||||
var map = L.map('map');
|
||||
|
||||
var marker = L.marker([51.5, -0.09])
|
||||
.bindPopup("<b>Hello world!</b><br />I am a popup.")
|
||||
.addTo(map);
|
||||
//.openPopup();
|
||||
|
||||
var marker2 = L.marker([51.525, -0.09])
|
||||
.addTo(map);
|
||||
|
||||
map.setView([51.505, -0.09], 13);
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
maxZoom: 18,
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6',
|
||||
styleId: 997
|
||||
}).addTo(map);
|
||||
|
||||
var a_popup = L.popup().setContent('Previously created')
|
||||
|
||||
marker2.bindPopup(a_popup);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,42 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<style>
|
||||
body {
|
||||
direction: rtl;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Click the map to place a popup at the mouse location</p>
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/997/256/{z}/{x}/{y}.png', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6'
|
||||
});
|
||||
|
||||
var map = L.map('map')
|
||||
.setView([50.5, 30.51], 15)
|
||||
.addLayer(cloudmade);
|
||||
|
||||
map.on('click', function(e) {
|
||||
L.popup().setLatLng(e.latlng).setContent('Hello').openOn(map);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,27 +0,0 @@
|
||||
<html dir="rtl">
|
||||
<head>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<style>
|
||||
#map { height: 100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<script>
|
||||
var map = L.map('map').setView([51.505, -0.09], 13);
|
||||
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
|
||||
map.on('click', function(e) {
|
||||
L.popup().setLatLng(e.latlng).setContent('Hello').openOn(map);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for preservation of Icon DOM element</title>
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var blueIcon = new L.Icon({iconUrl: 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_blue.gif'});
|
||||
var redIcon = new L.Icon({iconUrl: 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_red.gif'});
|
||||
|
||||
var map = L.map('map').setView( [50, 50], 10);
|
||||
|
||||
var marker = L.marker([50, 50], {icon: blueIcon, draggable: true});
|
||||
|
||||
marker.on('dragstart', function () {
|
||||
console.log('dragstart');
|
||||
marker.setIcon(redIcon);
|
||||
//This is the previous workaround:
|
||||
//var iconElem = L.DomUtil.get(marker._icon);
|
||||
//iconElem.src = 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_red.gif';
|
||||
});
|
||||
|
||||
marker.on('dragend', function () {
|
||||
console.log('dragend');
|
||||
marker.setIcon(blueIcon);
|
||||
//This is the previous workaround:
|
||||
//var iconElem = L.DomUtil.get(marker._icon);
|
||||
//iconElem.src = 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_blue.gif';
|
||||
|
||||
});
|
||||
|
||||
marker.addTo(map);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,54 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var map;
|
||||
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 osm = new L.TileLayer(osmUrl, { minZoom: 1, maxZoom: 17 });
|
||||
map.addLayer(osm);
|
||||
map.fitBounds(new L.LatLngBounds([51,7],[51,7]));
|
||||
|
||||
var route = L.polyline([
|
||||
[51, 7.000],
|
||||
[51.002, 7.004],
|
||||
[51.004, 7.006]
|
||||
]).addTo(map).on('click',function(e){console.log('bottom')})
|
||||
|
||||
var route2 = L.polyline([
|
||||
[51, 7.000],
|
||||
[51.002, 7.004]
|
||||
],
|
||||
{ clickable:false,color:'#f00' }
|
||||
).addTo(map);
|
||||
|
||||
// when the mouse hovers over the red route2, you cannot click through the blue route1 beneath
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,88 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<button onclick="boundsExtendBounds();">Extend the bounds of the center rectangle with the upper right rectangle</button>
|
||||
<button onclick="boundsExtendLatLng()">Extend the bounds of the center rectangle with the lower left marker</button>
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
|
||||
|
||||
var latLng = new L.LatLng(54.18815548107151, -7.657470703124999);
|
||||
|
||||
var bounds1 = new L.LatLngBounds(new L.LatLng(54.559322, -5.767822), new L.LatLng(56.1210604, -3.021240));
|
||||
var bounds2 = new L.LatLngBounds(new L.LatLng(56.56023925701561, -2.076416015625), new L.LatLng(57.01158038001565, -0.9777832031250001));
|
||||
var bounds3;
|
||||
|
||||
var map = new L.Map('map', {
|
||||
layers: [cloudmade],
|
||||
center: bounds1.getCenter(),
|
||||
zoom: 7
|
||||
});
|
||||
|
||||
var rectangle1 = new L.Rectangle(bounds1);
|
||||
var rectangle2 = new L.Rectangle(bounds2);
|
||||
var rectangle3;
|
||||
|
||||
var marker = new L.Marker(latLng);
|
||||
|
||||
map.addLayer(rectangle1).addLayer(rectangle2).addLayer(marker);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function boundsExtendBounds() {
|
||||
if (rectangle3) {
|
||||
map.removeLayer(rectangle3);
|
||||
rectangle3 = null;
|
||||
}
|
||||
if (bounds3) {
|
||||
bounds3 = null;
|
||||
}
|
||||
bounds3 = new L.LatLngBounds(bounds1.getSouthWest(), bounds1.getNorthEast());
|
||||
bounds3.extend(bounds2);
|
||||
rectangle3 = new L.Rectangle(bounds3, {
|
||||
color: "#ff0000",
|
||||
weight: 1,
|
||||
opacity: 1,
|
||||
fillOpacity: 0
|
||||
});
|
||||
|
||||
map.addLayer(rectangle3);
|
||||
}
|
||||
|
||||
function boundsExtendLatLng() {
|
||||
if (rectangle3) {
|
||||
map.removeLayer(rectangle3);
|
||||
rectangle3 = null;
|
||||
}
|
||||
if (bounds3) {
|
||||
bounds3 = null;
|
||||
}
|
||||
bounds3 = new L.LatLngBounds(bounds1.getSouthWest(), bounds1.getNorthEast());
|
||||
bounds3.extend(marker.getLatLng());
|
||||
rectangle3 = new L.Rectangle(bounds3, {
|
||||
color: "#ff0000",
|
||||
weight: 1,
|
||||
opacity: 1,
|
||||
fillOpacity: 0
|
||||
});
|
||||
|
||||
map.addLayer(rectangle3);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,90 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<button onclick="geojsonLayerBounds();">Show GeoJSON layer bounds</button>
|
||||
<button onclick="featureGroupBounds();">Show feature group bounds</button>
|
||||
|
||||
<script type="text/javascript" src="geojson-sample.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution}),
|
||||
rectangle,
|
||||
featureGroup;
|
||||
|
||||
var map = new L.Map('map', {
|
||||
center: new L.LatLng(0.78, 102.37),
|
||||
zoom: 7,
|
||||
layers: [cloudmade]
|
||||
});
|
||||
|
||||
var geojson = L.geoJson(geojsonSample, {
|
||||
|
||||
style: function (feature) {
|
||||
return {color: feature.properties.color};
|
||||
},
|
||||
|
||||
onEachFeature: function (feature, layer) {
|
||||
var popupText = 'geometry type: ' + feature.geometry.type;
|
||||
|
||||
if (feature.properties.color) {
|
||||
popupText += '<br/>color: ' + feature.properties.color
|
||||
}
|
||||
|
||||
layer.bindPopup(popupText);
|
||||
}
|
||||
});
|
||||
|
||||
geojson.addLayer(new L.Marker(new L.LatLng(2.745530718801952, 105.194091796875)))
|
||||
|
||||
var eye1 = new L.Marker(new L.LatLng(-0.7250783020332547, 101.8212890625));
|
||||
var eye2 = new L.Marker(new L.LatLng(-0.7360637370492077, 103.2275390625));
|
||||
var nose = new L.Marker(new L.LatLng(-1.3292264529974207, 102.5463867187));
|
||||
var mouth = new L.Polyline([
|
||||
new L.LatLng(-1.3841426927920029, 101.7333984375),
|
||||
new L.LatLng(-1.6037944300589726, 101.964111328125),
|
||||
new L.LatLng(-1.6806671337507222, 102.249755859375),
|
||||
new L.LatLng(-1.7355743631421197, 102.67822265625),
|
||||
new L.LatLng(-1.5928123762763, 103.0078125),
|
||||
new L.LatLng(-1.3292264529974207, 103.3154296875)
|
||||
]);
|
||||
map.addLayer(eye1).addLayer(eye2).addLayer(nose).addLayer(mouth);
|
||||
featureGroup = new L.FeatureGroup([eye1, eye2, nose, mouth]);
|
||||
|
||||
map.addLayer(geojson);
|
||||
map.addLayer(featureGroup);
|
||||
|
||||
function geojsonLayerBounds() {
|
||||
if (rectangle) {
|
||||
rectangle.setBounds(geojson.getBounds());
|
||||
} else {
|
||||
rectangle = new L.Rectangle(geojson.getBounds());
|
||||
map.addLayer(rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
function featureGroupBounds() {
|
||||
if (rectangle) {
|
||||
rectangle.setBounds(featureGroup.getBounds());
|
||||
} else {
|
||||
rectangle = new L.Rectangle(featureGroup.getBounds());
|
||||
map.addLayer(rectangle);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,53 +0,0 @@
|
||||
var geojsonSample = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [102.0, 0.5]
|
||||
},
|
||||
"properties": {
|
||||
"prop0": "value0",
|
||||
"color": "blue"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]
|
||||
},
|
||||
"properties": {
|
||||
"color": "red",
|
||||
"prop1": 0.0
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]]
|
||||
},
|
||||
"properties": {
|
||||
"color": "green",
|
||||
"prop1": {
|
||||
"this": "that"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [[[[100.0, 1.5], [100.5, 1.5], [100.5, 2.0], [100.0, 2.0], [100.0, 1.5]]], [[[100.5, 2.0], [100.5, 2.5], [101.0, 2.5], [101.0, 2.0], [100.5, 2.0]]]]
|
||||
},
|
||||
"properties": {
|
||||
"color": "#ff7800"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
@ -1,173 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<style>
|
||||
#map {
|
||||
width: 800px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.info {
|
||||
padding: 6px 8px;
|
||||
font: 14px/16px Arial, Helvetica, sans-serif;
|
||||
background: white;
|
||||
background: rgba(255,255,255,0.8);
|
||||
box-shadow: 0 0 15px rgba(0,0,0,0.2);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.info h4 {
|
||||
margin: 0 0 5px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.legend {
|
||||
text-align: left;
|
||||
line-height: 18px;
|
||||
color: #555;
|
||||
}
|
||||
.legend i {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
float: left;
|
||||
margin-right: 8px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map"></div>
|
||||
|
||||
<script type="text/javascript" src="us-states.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var map = L.map('map').setView([37.8, -96], 4);
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6',
|
||||
styleId: 998
|
||||
}).addTo(map);
|
||||
|
||||
|
||||
// control that shows state info on hover
|
||||
var info = L.control();
|
||||
|
||||
info.onAdd = function (map) {
|
||||
this._div = L.DomUtil.create('div', 'info');
|
||||
this.update();
|
||||
return this._div;
|
||||
};
|
||||
|
||||
info.update = function (props) {
|
||||
this._div.innerHTML = '<h4>US Population Density</h4>' + (props ?
|
||||
'<b>' + props.name + '</b><br />' + props.density + ' people / mi<sup>2</sup>'
|
||||
: 'Hover over a state');
|
||||
};
|
||||
|
||||
info.addTo(map);
|
||||
|
||||
|
||||
// get color depending on population density value
|
||||
function getColor(d) {
|
||||
return d > 1000 ? '#800026' :
|
||||
d > 500 ? '#BD0026' :
|
||||
d > 200 ? '#E31A1C' :
|
||||
d > 100 ? '#FC4E2A' :
|
||||
d > 50 ? '#FD8D3C' :
|
||||
d > 20 ? '#FEB24C' :
|
||||
d > 10 ? '#FED976' :
|
||||
'#FFEDA0';
|
||||
}
|
||||
|
||||
function style(feature) {
|
||||
return {
|
||||
weight: 2,
|
||||
opacity: 1,
|
||||
color: 'white',
|
||||
dashArray: '3',
|
||||
fillOpacity: 0.7,
|
||||
fillColor: getColor(feature.properties.density)
|
||||
};
|
||||
}
|
||||
|
||||
function highlightFeature(e) {
|
||||
var layer = e.target;
|
||||
|
||||
layer.setStyle({
|
||||
weight: 5,
|
||||
color: '#666',
|
||||
dashArray: '',
|
||||
fillOpacity: 0.7
|
||||
});
|
||||
|
||||
if (!L.Browser.ie) {
|
||||
layer.bringToFront();
|
||||
}
|
||||
|
||||
info.update(layer.feature.properties);
|
||||
}
|
||||
|
||||
var geojson;
|
||||
|
||||
function resetHighlight(e) {
|
||||
geojson.resetStyle(e.target);
|
||||
info.update();
|
||||
}
|
||||
|
||||
function zoomToFeature(e) {
|
||||
map.fitBounds(e.target.getBounds());
|
||||
}
|
||||
|
||||
function onEachFeature(feature, layer) {
|
||||
layer.on({
|
||||
mouseover: highlightFeature,
|
||||
mouseout: resetHighlight,
|
||||
click: zoomToFeature
|
||||
});
|
||||
}
|
||||
|
||||
geojson = L.geoJson(statesData, {
|
||||
style: style,
|
||||
onEachFeature: onEachFeature
|
||||
}).addTo(map);
|
||||
|
||||
map.attributionControl.addAttribution('Population data © <a href="http://census.gov/">US Census Bureau</a>');
|
||||
|
||||
|
||||
var legend = L.control({position: 'bottomright'});
|
||||
|
||||
legend.onAdd = function (map) {
|
||||
|
||||
var div = L.DomUtil.create('div', 'info legend'),
|
||||
grades = [0, 10, 20, 50, 100, 200, 500, 1000],
|
||||
labels = [],
|
||||
from, to;
|
||||
|
||||
for (var i = 0; i < grades.length; i++) {
|
||||
from = grades[i];
|
||||
to = grades[i + 1];
|
||||
|
||||
labels.push(
|
||||
'<i style="background:' + getColor(from + 1) + '"></i> ' +
|
||||
from + (to ? '–' + to : '+'));
|
||||
}
|
||||
|
||||
div.innerHTML = labels.join('<br>');
|
||||
return div;
|
||||
};
|
||||
|
||||
legend.addTo(map);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="map" style="width: 500px; height: 500px;"></div>
|
||||
<input type="button" value="Set blue rectangle bounds as current map extent." onclick="resetBounds();" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});;
|
||||
|
||||
var bounds = new L.LatLngBounds(new L.LatLng(54.559322, -5.767822), new L.LatLng(56.1210604, -3.021240));
|
||||
var bounds2 = new L.LatLngBounds(new L.LatLng(56.2124322195806, -3.427734375), new L.LatLng(56.307776937156945, -3.2560729980468746));
|
||||
|
||||
var rectangle = new L.Rectangle(bounds);
|
||||
var styledRectangle = new L.Rectangle(bounds2, {
|
||||
fillColor: "#ff7800",
|
||||
color: "#000000",
|
||||
opacity: 1,
|
||||
weight: 2
|
||||
});
|
||||
|
||||
rectangle.on("click", function () {
|
||||
alert("you clicked a rectangle.")
|
||||
});
|
||||
|
||||
var map = new L.Map('map', {
|
||||
center: bounds.getCenter(),
|
||||
zoom: 7,
|
||||
layers: [cloudmade]
|
||||
});
|
||||
|
||||
map.addLayer(rectangle).addLayer(styledRectangle);
|
||||
|
||||
function resetBounds() {
|
||||
rectangle.setBounds(map.getBounds());
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
@ -1,194 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<div style="background-color:chartreuse; width: 100px; height:100px; position: absolute; left: 850px; top: 10px" onclick="Hack1()">Hack1Touch</div>
|
||||
<div style="background-color:coral; width: 100px; height:100px; position: absolute; left: 850px; top: 120px" onclick="Hack2()">Hack2Touch</div>
|
||||
<div style="background-color:lightblue; width: 100px; height:100px; position: absolute; left: 850px; top: 230px" onclick="Hack3()">Hack3Touch</div>
|
||||
<div style="background-color:lightpink; width: 100px; height:100px; position: absolute; left: 850px; top: 340px" onclick="Hack4()">Hack4Touch</div>
|
||||
<div style="background-color:yellow; width: 100px; height:100px; position: absolute; left: 850px; top: 450px" onclick="alert(buffer)">Print Buffer</div>
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
//var buffer = "";
|
||||
//console.log = function (text) {
|
||||
// buffer += text + "\r\n";
|
||||
//}
|
||||
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
|
||||
map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(51.505, -0.04), zoom: 13});
|
||||
|
||||
|
||||
var polygon = new L.Polygon([
|
||||
new L.LatLng(51.51, -0.1),
|
||||
new L.LatLng(51.5, -0.06),
|
||||
new L.LatLng(51.52, -0.03)
|
||||
]);
|
||||
|
||||
map.addLayer(polygon);
|
||||
|
||||
var polyline = new L.Polyline([
|
||||
new L.LatLng(51.49, -0.02),
|
||||
new L.LatLng(51.51, 0),
|
||||
new L.LatLng(51.52, -0.02)
|
||||
]);
|
||||
|
||||
map.addLayer(polyline);
|
||||
|
||||
polygon.on('edit', function() {
|
||||
console.log('Polygon was edited!');
|
||||
});
|
||||
polyline.on('edit', function() {
|
||||
console.log('Polyline was edited!');
|
||||
});
|
||||
|
||||
var _timerAt, _timer;
|
||||
function Hack1() {
|
||||
_timerAt = 0;
|
||||
clearInterval(_timer);
|
||||
_timer = setInterval(Hack1Timer, 200);
|
||||
}
|
||||
function Hack1Timer() {
|
||||
console.log(_timerAt);
|
||||
switch (_timerAt) {
|
||||
case 0:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
|
||||
break;
|
||||
case 1:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 452, pageY: 312 }, { pageX: 236, pageY: 322 }] });
|
||||
break;
|
||||
case 2:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 3:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
|
||||
break;
|
||||
case 4:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
|
||||
//map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
|
||||
break;
|
||||
case 5:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 6:
|
||||
clearInterval(_timer);
|
||||
break;
|
||||
}
|
||||
_timerAt++;
|
||||
}
|
||||
function Hack2() {
|
||||
_timerAt = 0;
|
||||
clearInterval(_timer);
|
||||
_timer = setInterval(Hack2Timer, 100);
|
||||
}
|
||||
function Hack2Timer() {
|
||||
console.log(_timerAt);
|
||||
switch (_timerAt) {
|
||||
case 0:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 100, pageY: 100 }, { pageX: 50, pageY: 100}] });
|
||||
break;
|
||||
case 1:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 100, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 2:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 110, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 3:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 120, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 4:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 130, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 5:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 140, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 6:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 150, pageY: 100 }, { pageX: 50, pageY: 100 }] });
|
||||
break;
|
||||
case 7:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 8:
|
||||
clearInterval(_timer);
|
||||
break;
|
||||
}
|
||||
_timerAt++;
|
||||
}
|
||||
function Hack3() {
|
||||
_timerAt = 0;
|
||||
clearInterval(_timer);
|
||||
_timer = setInterval(Hack3Timer, 100);
|
||||
}
|
||||
function Hack3Timer() {
|
||||
console.log(_timerAt);
|
||||
switch (_timerAt) {
|
||||
case 0:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
|
||||
break;
|
||||
case 1:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 412, pageY: 312 }, { pageX: 236, pageY: 322 }] });
|
||||
break;
|
||||
case 2:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 3:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 423, pageY: 313 }, { pageX: 243, pageY: 321 }] });
|
||||
break;
|
||||
case 4:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 476, pageY: 326 }, { pageX: 299, pageY: 321 }] });
|
||||
break;
|
||||
case 5:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 6:
|
||||
clearInterval(_timer);
|
||||
break;
|
||||
}
|
||||
_timerAt++;
|
||||
}
|
||||
|
||||
function Hack4() {
|
||||
_timerAt = 0;
|
||||
clearInterval(_timer);
|
||||
_timer = setInterval(Hack4Timer, 40);
|
||||
}
|
||||
function Hack4Timer() {
|
||||
console.log(_timerAt);
|
||||
switch (_timerAt) {
|
||||
case 0:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
|
||||
break;
|
||||
case 1:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 236, pageY: 322 }] });
|
||||
break;
|
||||
case 2:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 5:
|
||||
map.touchZoom._onTouchStart({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
|
||||
break;
|
||||
case 6:
|
||||
map.touchZoom._onTouchMove({ touches: [{ pageX: 405, pageY: 312 }, { pageX: 233, pageY: 321 }] });
|
||||
break;
|
||||
case 7:
|
||||
map.touchZoom._onTouchEnd();
|
||||
break;
|
||||
case 8:
|
||||
clearInterval(_timer);
|
||||
break;
|
||||
}
|
||||
_timerAt++;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
@ -1,69 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<button onclick="map.fitBounds(path.getBounds())">Zoom to path</button>
|
||||
<button onclick="map.fitBounds(poly.getBounds())">Zoom to polygon</button>
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
|
||||
|
||||
var poly_points = [
|
||||
[39.70348880963439, -104.98603820800781],
|
||||
[39.69926245589766, -104.95582580566406],
|
||||
[39.67918374111695, -104.94483947753906],
|
||||
[39.663856582926165, -104.95307922363281],
|
||||
[39.66279941218785, -104.98672485351562],
|
||||
[39.70348880963439, -104.98603820800781]
|
||||
];
|
||||
|
||||
var path_points = [
|
||||
[39.72567292003209, -104.98672485351562],
|
||||
[39.717222671644635, -104.96612548828124],
|
||||
[39.71405356154611, -104.95513916015625],
|
||||
[39.70982785491674, -104.94758605957031],
|
||||
[39.70454535762547, -104.93247985839844],
|
||||
[39.696092520737224, -104.91874694824217],
|
||||
[39.687638648548635, -104.90432739257812],
|
||||
[39.67759833072648, -104.89471435546875]
|
||||
];
|
||||
|
||||
for (var i = 0, latlngs = [], len = path_points.length; i < len; i++) {
|
||||
latlngs.push(new L.LatLng(path_points[i][0], path_points[i][1]));
|
||||
}
|
||||
var path = new L.Polyline(latlngs);
|
||||
|
||||
for (var i = 0, latlngs2 = [], len = poly_points.length; i < len; i++) {
|
||||
latlngs2.push(new L.LatLng(poly_points[i][0], poly_points[i][1]));
|
||||
}
|
||||
var poly = new L.Polygon(latlngs2);
|
||||
|
||||
var map = new L.Map('map', {
|
||||
layers: [cloudmade],
|
||||
center: new L.LatLng(39.69596043694606, -104.95084762573242),
|
||||
zoom: 12
|
||||
});
|
||||
|
||||
//map.fitBounds(new L.LatLngBounds(latlngs));
|
||||
|
||||
//map.addLayer(new L.Marker(latlngs[0]));
|
||||
//map.addLayer(new L.Marker(latlngs[len - 1]));
|
||||
|
||||
map.addLayer(path);
|
||||
map.addLayer(poly);
|
||||
|
||||
path.bindPopup("Hello world");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,92 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script>
|
||||
L_PREFER_CANVAS = true; // experimental
|
||||
</script>
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<button onclick="group.removeLayer(path)">Remove path</button>
|
||||
<button onclick="group.removeLayer(circle)">Remove circle</button>
|
||||
<button onclick="group.clearLayers()">Remove all layers</button>
|
||||
|
||||
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
|
||||
|
||||
for (var i = 0, latlngs = [], len = route.length; i < len; i++) {
|
||||
latlngs.push(new L.LatLng(route[i][0], route[i][1]));
|
||||
}
|
||||
var path = new L.Polyline(latlngs);
|
||||
|
||||
var map = new L.Map('map', {layers: [cloudmade]});
|
||||
|
||||
var group = new L.LayerGroup();
|
||||
|
||||
map.fitBounds(new L.LatLngBounds(latlngs));
|
||||
|
||||
var circleLocation = new L.LatLng(51.508, -0.11),
|
||||
circleOptions = {
|
||||
color: 'red',
|
||||
fillColor: 'yellow',
|
||||
fillOpacity: 0.7
|
||||
};
|
||||
|
||||
var circle = new L.Circle(circleLocation, 500000, circleOptions),
|
||||
circleMarker = new L.CircleMarker(circleLocation, {fillColor: 'blue', fillOpacity: 1, stroke: false});
|
||||
|
||||
group.addLayer(circle).addLayer(circleMarker);
|
||||
|
||||
circle.bindPopup('I am a circle');
|
||||
circleMarker.bindPopup('I am a circle marker');
|
||||
|
||||
group.addLayer(path);
|
||||
path.bindPopup('I am a polyline');
|
||||
|
||||
var p1 = latlngs[0],
|
||||
p2 = latlngs[parseInt(len/4)],
|
||||
p3 = latlngs[parseInt(len/3)],
|
||||
p4 = latlngs[parseInt(len/2)],
|
||||
p5 = latlngs[len - 1],
|
||||
polygonPoints = [p1, p2, p3, p4, p5];
|
||||
|
||||
var h1 = new L.LatLng(p1.lat, p1.lng),
|
||||
h2 = new L.LatLng(p2.lat, p2.lng),
|
||||
h3 = new L.LatLng(p3.lat, p3.lng),
|
||||
h4 = new L.LatLng(p4.lat, p4.lng),
|
||||
h5 = new L.LatLng(p5.lat, p5.lng);
|
||||
|
||||
h1.lng += 20;
|
||||
h2.lat -= 5;
|
||||
h3.lat -= 5;
|
||||
h4.lng -= 10;
|
||||
h5.lng -= 8;
|
||||
h5.lat += 10;
|
||||
|
||||
var holePoints = [h5, h4, h3, h2, h1];
|
||||
|
||||
var polygon = new L.Polygon([polygonPoints, holePoints], {
|
||||
fillColor: "#333",
|
||||
color: 'green'
|
||||
});
|
||||
group.addLayer(polygon);
|
||||
|
||||
polygon.bindPopup('I am a polygon');
|
||||
|
||||
map.addLayer(group);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
|
||||
|
||||
for (var i = 0, latlngs = [], len = route.length; i < len; i++) {
|
||||
latlngs.push(new L.LatLng(route[i][0], route[i][1]));
|
||||
}
|
||||
var path = new L.Polyline(latlngs, {smoothFactor: 1});
|
||||
|
||||
var map = new L.Map('map', {layers: [cloudmade]});
|
||||
|
||||
map.fitBounds(new L.LatLngBounds(latlngs));
|
||||
|
||||
map.addLayer(new L.Marker(latlngs[0]));
|
||||
map.addLayer(new L.Marker(latlngs[latlngs.length - 1]));
|
||||
|
||||
map.addLayer(path);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,48 +0,0 @@
|
||||
<!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" />
|
||||
|
||||
<link rel="stylesheet" href="../css/mobile.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
|
||||
<script>
|
||||
var map = L.map('map');
|
||||
|
||||
var marker = L.marker([51.5, -0.09])
|
||||
.bindPopup("<b>Hello world!</b><br />I am a popup.")
|
||||
.addTo(map);
|
||||
//.openPopup();
|
||||
|
||||
var circle = L.circle([51.508, -0.11], 500, {color: '#f03', opacity: 0.7})
|
||||
.bindPopup("I am a circle.")
|
||||
.addTo(map);
|
||||
|
||||
var polygon = L.polygon([
|
||||
[51.509, -0.08],
|
||||
[51.503, -0.06],
|
||||
[51.51, -0.047]])
|
||||
.bindPopup("I am a polygon.")
|
||||
.addTo(map);
|
||||
|
||||
map.setView([51.505, -0.09], 13);
|
||||
|
||||
var cloudmade = L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', {
|
||||
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
||||
maxZoom: 18,
|
||||
key: 'd4fc77ea4a63471cab2423e66626cbb6',
|
||||
styleId: 997
|
||||
}).addTo(map);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Leaflet debug page</title>
|
||||
|
||||
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
|
||||
<script src="route.js"></script>
|
||||
<script>
|
||||
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
||||
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
|
||||
|
||||
for (var i = 0, latlngs = [], len = route.length; i < len; i++) {
|
||||
latlngs.push(new L.LatLng(route[i][0], route[i][1]));
|
||||
}
|
||||
var path = new L.Polyline(latlngs);
|
||||
|
||||
var map = new L.Map('map', {layers: [cloudmade]});
|
||||
|
||||
map.fitBounds(new L.LatLngBounds(latlngs));
|
||||
|
||||
map.addLayer(new L.Marker(latlngs[0]));
|
||||
map.addLayer(new L.Marker(latlngs[len - 1]));
|
||||
|
||||
map.addLayer(path);
|
||||
|
||||
path.bindPopup("Hello world");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
dist/images/layers-2x.png
vendored
BIN
dist/images/layers-2x.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB |
BIN
dist/images/layers.png
vendored
BIN
dist/images/layers.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
BIN
dist/images/marker-icon-2x.png
vendored
BIN
dist/images/marker-icon-2x.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB |
BIN
dist/images/marker-icon.png
vendored
BIN
dist/images/marker-icon.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
BIN
dist/images/marker-shadow.png
vendored
BIN
dist/images/marker-shadow.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 797 B |
9163
dist/leaflet-src.js
vendored
9163
dist/leaflet-src.js
vendored
File diff suppressed because it is too large
Load Diff
478
dist/leaflet.css
vendored
478
dist/leaflet.css
vendored
@ -1,478 +0,0 @@
|
||||
/* required styles */
|
||||
|
||||
.leaflet-map-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-pane,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-overlay-pane,
|
||||
.leaflet-shadow-pane,
|
||||
.leaflet-marker-pane,
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-overlay-pane svg,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
-ms-touch-action: none;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
/* map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container img {
|
||||
max-width: none !important;
|
||||
}
|
||||
/* stupid Android 2 doesn't understand "max-width: none" properly */
|
||||
.leaflet-container img.leaflet-image-layer {
|
||||
max-width: 15000px !important;
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-tile-pane { z-index: 2; }
|
||||
.leaflet-objects-pane { z-index: 3; }
|
||||
.leaflet-overlay-pane { z-index: 4; }
|
||||
.leaflet-shadow-pane { z-index: 5; }
|
||||
.leaflet-marker-pane { z-index: 6; }
|
||||
.leaflet-popup-pane { z-index: 7; }
|
||||
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
z-index: 7;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-top {
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-right {
|
||||
right: 0;
|
||||
}
|
||||
.leaflet-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.leaflet-left {
|
||||
left: 0;
|
||||
}
|
||||
.leaflet-control {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
float: right;
|
||||
}
|
||||
.leaflet-top .leaflet-control {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.leaflet-left .leaflet-control {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-tile,
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
-o-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-tile-loaded,
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile,
|
||||
.leaflet-touching .leaflet-zoom-animated {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-container {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging .leaflet-container,
|
||||
.leaflet-dragging .leaflet-clickable {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
}
|
||||
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline: 0;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-container a.leaflet-active {
|
||||
outline: 2px solid orange;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #38f;
|
||||
background: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-bar a:hover {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-bar a:hover {
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.leaflet-bar a.leaflet-disabled {
|
||||
cursor: default;
|
||||
background-color: #f4f4f4;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
font: bold 18px 'Lucida Console', Monaco, monospace;
|
||||
text-indent: 1px;
|
||||
}
|
||||
.leaflet-control-zoom-out {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-zoom-in {
|
||||
font-size: 22px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-retina .leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers-2x.png);
|
||||
background-size: 26px 26px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display: none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height: 0;
|
||||
border-top: 1px solid #ddd;
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
margin: 0;
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
}
|
||||
.leaflet-control-attribution a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.leaflet-container .leaflet-control-attribution,
|
||||
.leaflet-container .leaflet-control-scale {
|
||||
font-size: 11px;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 13px 19px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 18px 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
margin: 0 auto;
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 1px;
|
||||
|
||||
margin: -10px auto 0;
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
-o-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
background: white;
|
||||
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 4px 4px 0 0;
|
||||
text-align: center;
|
||||
width: 18px;
|
||||
height: 14px;
|
||||
font: 16px/14px Tahoma, Verdana, sans-serif;
|
||||
color: #c3c3c3;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover {
|
||||
color: #999;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper {
|
||||
zoom: 1;
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
width: 24px;
|
||||
margin: 0 auto;
|
||||
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip-container {
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-zoom,
|
||||
.leaflet-oldie .leaflet-control-layers,
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper,
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
/* div icon */
|
||||
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
9
dist/leaflet.js
vendored
9
dist/leaflet.js
vendored
File diff suppressed because one or more lines are too long
27
package.json
27
package.json
@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "leaflet",
|
||||
"version": "0.7.2",
|
||||
"description": "JavaScript library for mobile-friendly interactive maps",
|
||||
"devDependencies": {
|
||||
"jake": "~0.7.4",
|
||||
"jshint": "~2.3.0",
|
||||
"uglify-js": "~2.4.3",
|
||||
"mocha": "~1.14.0",
|
||||
"happen": "~0.1.3",
|
||||
"karma": "~0.10.4",
|
||||
"karma-mocha": "~0.1.0"
|
||||
},
|
||||
"main": "dist/leaflet-src.js",
|
||||
"scripts": {
|
||||
"test": "jake test",
|
||||
"prepublish": "jake build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Leaflet/Leaflet.git"
|
||||
},
|
||||
"keywords": [
|
||||
"gis",
|
||||
"map"
|
||||
]
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
// put after Leaflet files as imagePath can't be detected in a PhantomJS env
|
||||
L.Icon.Default.imagePath = "/base/dist/images";
|
@ -1,3 +0,0 @@
|
||||
// set up before Leaflet files to test L#noConflict later
|
||||
L = 'test';
|
||||
|
1253
spec/expect.js
1253
spec/expect.js
File diff suppressed because it is too large
Load Diff
@ -1,86 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Leaflet Spec Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="expect.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/mocha/mocha.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/happen/happen.js"></script>
|
||||
<script type="text/javascript" src="sinon.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
<script type="text/javascript" src="before.js"></script>
|
||||
<script type="text/javascript" src="../build/deps.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../debug/leaflet-include.js"></script>
|
||||
|
||||
<script>
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
ignoreLeaks: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- spec files -->
|
||||
|
||||
<script type="text/javascript" src="suites/SpecHelper.js"></script>
|
||||
<script type="text/javascript" src="suites/LeafletSpec.js"></script>
|
||||
|
||||
<!-- /control -->
|
||||
<script type="text/javascript" src="suites/control/Control.LayersSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/control/Control.ScaleSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/control/Control.AttributionSpec.js"></script>
|
||||
|
||||
<!-- /core -->
|
||||
<script type="text/javascript" src="suites/core/UtilSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/core/ClassSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/core/EventsSpec.js"></script>
|
||||
|
||||
<!-- /geometry -->
|
||||
<script type="text/javascript" src="suites/geometry/PointSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geometry/BoundsSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geometry/TransformationSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geometry/LineUtilSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geometry/PolyUtilSpec.js"></script>
|
||||
|
||||
<!-- /geo -->
|
||||
<script type="text/javascript" src="suites/geo/LatLngSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geo/LatLngBoundsSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/geo/ProjectionSpec.js"></script>
|
||||
|
||||
<!-- /dom -->
|
||||
<script type="text/javascript" src="suites/dom/DomEventSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/dom/DomUtilSpec.js"></script>
|
||||
|
||||
<!-- /layer -->
|
||||
<script type="text/javascript" src="suites/layer/FeatureGroupSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/GeoJSONSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/LayerGroupSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/TileLayerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/PopupSpec.js"></script>
|
||||
|
||||
<!-- /layer/marker/ -->
|
||||
<script type="text/javascript" src="suites/layer/marker/MarkerSpec.js"></script>
|
||||
|
||||
<!-- /layer/vector/ -->
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/CircleMarkerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolygonSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/layer/vector/PolylineGeometrySpec.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
<script type="text/javascript" src="suites/map/MapSpec.js"></script>
|
||||
|
||||
<!-- /map/handler -->
|
||||
<script type="text/javascript" src="suites/map/handler/Map.DragSpec.js"></script>
|
||||
|
||||
<script>
|
||||
(window.mochaPhantomJS || window.mocha).run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,65 +0,0 @@
|
||||
// Karma configuration
|
||||
module.exports = function (config) {
|
||||
|
||||
var libSources = require(__dirname+'/../build/build.js').getFiles();
|
||||
|
||||
var files = [
|
||||
"spec/before.js",
|
||||
"spec/sinon.js",
|
||||
"spec/expect.js"
|
||||
].concat(libSources, [
|
||||
"spec/after.js",
|
||||
"node_modules/happen/happen.js",
|
||||
"spec/suites/SpecHelper.js",
|
||||
"spec/suites/**/*.js",
|
||||
{pattern: "dist/images/*.png", included: false}
|
||||
]);
|
||||
|
||||
config.set({
|
||||
// base path, that will be used to resolve files and exclude
|
||||
basePath: '../',
|
||||
|
||||
plugins: ['karma-mocha', 'karma-phantomjs-launcher', 'karma-chrome-launcher'],
|
||||
|
||||
// frameworks to use
|
||||
frameworks: ['mocha'],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: files,
|
||||
exclude: [],
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
|
||||
reporters: ['dots'],
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_WARN,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// Start these browsers, currently available:
|
||||
// - Chrome
|
||||
// - ChromeCanary
|
||||
// - Firefox
|
||||
// - Opera
|
||||
// - Safari (only Mac)
|
||||
// - PhantomJS
|
||||
// - IE (only Windows)
|
||||
browsers: ['PhantomJS'],
|
||||
|
||||
// If browser does not capture in given timeout [ms], kill it
|
||||
captureTimeout: 5000,
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, it capture browsers, run tests and exit
|
||||
singleRun: true
|
||||
});
|
||||
};
|
4223
spec/sinon.js
4223
spec/sinon.js
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
||||
{
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"predef": ["define", "L", "expect", "describe", "it", "sinon", "happen", "beforeEach", "afterEach"],
|
||||
"strict": false,
|
||||
"bitwise": true,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"undef": true,
|
||||
// "unused": true,
|
||||
// "quotmark": "single",
|
||||
"indent": 4,
|
||||
"trailing": true,
|
||||
"white": true,
|
||||
"smarttabs": true
|
||||
// "maxlen": 120
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
describe('L#noConflict', function () {
|
||||
it('restores the previous L value and returns Leaflet namespace', function () {
|
||||
|
||||
expect(L.version).to.be.ok();
|
||||
|
||||
var L2 = L.noConflict();
|
||||
|
||||
expect(L).to.eql('test');
|
||||
expect(L2.version).to.be.ok();
|
||||
|
||||
window.L = L2;
|
||||
});
|
||||
});
|
@ -1,42 +0,0 @@
|
||||
if (!Array.prototype.map) {
|
||||
Array.prototype.map = function (fun /*, thisp */) {
|
||||
"use strict";
|
||||
|
||||
if (this === void 0 || this === null) {
|
||||
throw new TypeError();
|
||||
}
|
||||
|
||||
var t = Object(this);
|
||||
// jshint bitwise: false
|
||||
var len = t.length >>> 0;
|
||||
if (typeof fun !== "function") {
|
||||
throw new TypeError();
|
||||
}
|
||||
|
||||
var res = new Array(len);
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (i in t) {
|
||||
res[i] = fun.call(thisp, t[i], i, t);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
expect.Assertion.prototype.near = function (expected, delta) {
|
||||
delta = delta || 1;
|
||||
expect(this.obj.x).to
|
||||
.be.within(expected.x - delta, expected.x + delta);
|
||||
expect(this.obj.y).to
|
||||
.be.within(expected.y - delta, expected.y + delta);
|
||||
};
|
||||
|
||||
expect.Assertion.prototype.nearLatLng = function (expected, delta) {
|
||||
delta = delta || 1e-4;
|
||||
expect(this.obj.lat).to
|
||||
.be.within(expected.lat - delta, expected.lat + delta);
|
||||
expect(this.obj.lng).to
|
||||
.be.within(expected.lng - delta, expected.lng + delta);
|
||||
};
|
@ -1,68 +0,0 @@
|
||||
describe("Control.Attribution", function () {
|
||||
|
||||
var map, control, container;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
control = new L.Control.Attribution({
|
||||
prefix: 'prefix'
|
||||
}).addTo(map);
|
||||
container = control.getContainer();
|
||||
});
|
||||
|
||||
it("contains just prefix if no attributions added", function () {
|
||||
expect(container.innerHTML).to.eql('prefix');
|
||||
});
|
||||
|
||||
describe('#addAttribution', function () {
|
||||
it('adds one attribution correctly', function () {
|
||||
control.addAttribution('foo');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
|
||||
it('adds no duplicate attributions', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('foo');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
|
||||
it('adds several attributions listed with comma', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('bar');
|
||||
expect(container.innerHTML).to.eql('prefix | foo, bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#removeAttribution', function () {
|
||||
it('removes attribution correctly', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('bar');
|
||||
control.removeAttribution('foo');
|
||||
expect(container.innerHTML).to.eql('prefix | bar');
|
||||
});
|
||||
it('does nothing if removing attribution that was not present', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('baz');
|
||||
control.removeAttribution('bar');
|
||||
control.removeAttribution('baz');
|
||||
control.removeAttribution('baz');
|
||||
control.removeAttribution('');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setPrefix', function () {
|
||||
it('changes prefix', function () {
|
||||
control.setPrefix('bla');
|
||||
expect(container.innerHTML).to.eql('bla');
|
||||
});
|
||||
});
|
||||
|
||||
describe('control.attribution factory', function () {
|
||||
it('creates Control.Attribution instance', function () {
|
||||
var options = {prefix: 'prefix'};
|
||||
expect(L.control.attribution(options)).to.eql(new L.Control.Attribution(options));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -1,67 +0,0 @@
|
||||
describe("Control.Layers", function () {
|
||||
var map;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
});
|
||||
|
||||
describe("baselayerchange event", function () {
|
||||
it("is fired on input that changes the base layer", function () {
|
||||
var baseLayers = {"Layer 1": L.tileLayer(), "Layer 2": L.tileLayer()},
|
||||
layers = L.control.layers(baseLayers).addTo(map),
|
||||
spy = sinon.spy();
|
||||
|
||||
map.on('baselayerchange', spy)
|
||||
.whenReady(function () {
|
||||
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy.called).to.be.ok();
|
||||
expect(spy.mostRecentCall.args[0].layer).to.be(baseLayers["Layer 1"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("is not fired on input that doesn't change the base layer", function () {
|
||||
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
|
||||
layers = L.control.layers({}, overlays).addTo(map),
|
||||
spy = sinon.spy();
|
||||
|
||||
map.on('baselayerchange', spy);
|
||||
happen.click(layers._overlaysList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
var spy = sinon.spy(layers, '_update');
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(spy.called).to.be.ok();
|
||||
expect(spy.callCount).to.eql(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);
|
||||
|
||||
var spy = sinon.spy(layers, '_update');
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(spy.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
describe("Control.Scale", function () {
|
||||
it("can be added to an unloaded map", function () {
|
||||
var map = L.map(document.createElement('div'));
|
||||
new L.Control.Scale().addTo(map);
|
||||
});
|
||||
});
|
@ -1,156 +0,0 @@
|
||||
describe("Class", function () {
|
||||
|
||||
describe("#extend", function () {
|
||||
var Klass,
|
||||
constructor,
|
||||
method;
|
||||
|
||||
beforeEach(function () {
|
||||
constructor = sinon.spy();
|
||||
method = sinon.spy();
|
||||
|
||||
Klass = L.Class.extend({
|
||||
statics: {bla: 1},
|
||||
includes: {mixin: true},
|
||||
|
||||
initialize: constructor,
|
||||
foo: 5,
|
||||
bar: method
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a class with the given constructor & properties", function () {
|
||||
var a = new Klass();
|
||||
|
||||
expect(constructor.called).to.be.ok();
|
||||
expect(a.foo).to.eql(5);
|
||||
|
||||
a.bar();
|
||||
|
||||
expect(method.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("inherits parent classes' constructor & properties", function () {
|
||||
var Klass2 = Klass.extend({baz: 2});
|
||||
|
||||
var b = new Klass2();
|
||||
|
||||
expect(b instanceof Klass).to.be.ok();
|
||||
expect(b instanceof Klass2).to.be.ok();
|
||||
|
||||
expect(constructor.called).to.be.ok();
|
||||
expect(b.baz).to.eql(2);
|
||||
|
||||
b.bar();
|
||||
|
||||
expect(method.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("supports static properties", function () {
|
||||
expect(Klass.bla).to.eql(1);
|
||||
});
|
||||
|
||||
it("inherits parent static properties", function () {
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
expect(Klass2.bla).to.eql(1);
|
||||
});
|
||||
|
||||
it("overrides parent static properties", function () {
|
||||
var Klass2 = Klass.extend({statics: {bla: 2}});
|
||||
|
||||
expect(Klass2.bla).to.eql(2);
|
||||
});
|
||||
|
||||
it("includes the given mixin", function () {
|
||||
var a = new Klass();
|
||||
expect(a.mixin).to.be.ok();
|
||||
});
|
||||
|
||||
it("includes multiple mixins", function () {
|
||||
var Klass2 = L.Class.extend({
|
||||
includes: [{mixin: true}, {mixin2: true}]
|
||||
});
|
||||
var a = new Klass2();
|
||||
|
||||
expect(a.mixin).to.be.ok();
|
||||
expect(a.mixin2).to.be.ok();
|
||||
});
|
||||
|
||||
it("grants the ability to include the given mixin", function () {
|
||||
Klass.include({mixin2: true});
|
||||
|
||||
var a = new Klass();
|
||||
expect(a.mixin2).to.be.ok();
|
||||
});
|
||||
|
||||
it("merges options instead of replacing them", function () {
|
||||
var KlassWithOptions1 = L.Class.extend({
|
||||
options: {
|
||||
foo1: 1,
|
||||
foo2: 2
|
||||
}
|
||||
});
|
||||
var KlassWithOptions2 = KlassWithOptions1.extend({
|
||||
options: {
|
||||
foo2: 3,
|
||||
foo3: 4
|
||||
}
|
||||
});
|
||||
|
||||
var a = new KlassWithOptions2();
|
||||
|
||||
expect(a.options).to.eql({
|
||||
foo1: 1,
|
||||
foo2: 3,
|
||||
foo3: 4
|
||||
});
|
||||
});
|
||||
|
||||
it("adds constructor hooks correctly", function () {
|
||||
var spy1 = sinon.spy();
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass.addInitHook('bar', 1, 2, 3);
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(method.calledWith(1, 2, 3));
|
||||
});
|
||||
|
||||
it("inherits constructor hooks", function () {
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy();
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass2.addInitHook(spy2);
|
||||
|
||||
var a = new Klass2();
|
||||
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(spy2.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("does not call child constructor hooks", function () {
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy();
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass2.addInitHook(spy2);
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(spy2.called).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Class.include
|
||||
|
||||
// TODO Class.mergeOptions
|
||||
});
|
@ -1,392 +0,0 @@
|
||||
describe('Events', function () {
|
||||
var Klass;
|
||||
|
||||
beforeEach(function () {
|
||||
Klass = L.Class.extend({
|
||||
includes: L.Mixin.Events
|
||||
});
|
||||
});
|
||||
|
||||
describe('#fireEvent', function () {
|
||||
|
||||
it('fires all listeners added through #addEventListener', function () {
|
||||
var obj = new Klass(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy(),
|
||||
spy4 = sinon.spy(),
|
||||
spy5 = sinon.spy(),
|
||||
spy6 = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', spy1);
|
||||
obj.addEventListener('test', spy2);
|
||||
obj.addEventListener('other', spy3);
|
||||
obj.addEventListener({ test: spy4, other: spy5 });
|
||||
obj.addEventListener({'test other': spy6 });
|
||||
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(false);
|
||||
expect(spy3.called).to.be(false);
|
||||
expect(spy4.called).to.be(false);
|
||||
expect(spy5.called).to.be(false);
|
||||
expect(spy6.called).to.be(false);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy1.called).to.be(true);
|
||||
expect(spy2.called).to.be(true);
|
||||
expect(spy3.called).to.be(false);
|
||||
expect(spy4.called).to.be(true);
|
||||
expect(spy5.called).to.be(false);
|
||||
expect(spy6.called).to.be(true);
|
||||
expect(spy6.callCount).to.be(1);
|
||||
});
|
||||
|
||||
it('provides event object to listeners and executes them in the right context', function () {
|
||||
var obj = new Klass(),
|
||||
obj2 = new Klass(),
|
||||
obj3 = new Klass(),
|
||||
obj4 = new Klass(),
|
||||
foo = {};
|
||||
|
||||
function listener1(e) {
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj);
|
||||
expect(this).to.eql(obj);
|
||||
expect(e.baz).to.eql(1);
|
||||
}
|
||||
|
||||
function listener2(e) {
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj2);
|
||||
expect(this).to.eql(foo);
|
||||
expect(e.baz).to.eql(2);
|
||||
}
|
||||
|
||||
function listener3(e) {
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj3);
|
||||
expect(this).to.eql(obj3);
|
||||
expect(e.baz).to.eql(3);
|
||||
}
|
||||
|
||||
function listener4(e) {
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj4);
|
||||
expect(this).to.eql(foo);
|
||||
expect(e.baz).to.eql(4);
|
||||
}
|
||||
|
||||
obj.addEventListener('test', listener1);
|
||||
obj2.addEventListener('test', listener2, foo);
|
||||
obj3.addEventListener({ test: listener3 });
|
||||
obj4.addEventListener({ test: listener4 }, foo);
|
||||
|
||||
obj.fireEvent('test', {baz: 1});
|
||||
obj2.fireEvent('test', {baz: 2});
|
||||
obj3.fireEvent('test', {baz: 3});
|
||||
obj4.fireEvent('test', {baz: 4});
|
||||
});
|
||||
|
||||
it('calls no listeners removed through #removeEventListener', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy(),
|
||||
spy4 = sinon.spy(),
|
||||
spy5 = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', spy);
|
||||
obj.removeEventListener('test', spy);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
|
||||
obj.addEventListener('test2', spy2);
|
||||
obj.addEventListener('test2', spy3);
|
||||
obj.removeEventListener('test2');
|
||||
|
||||
obj.fireEvent('test2');
|
||||
|
||||
expect(spy2.called).to.be(false);
|
||||
expect(spy3.called).to.be(false);
|
||||
|
||||
obj.addEventListener('test3', spy4);
|
||||
obj.addEventListener('test4', spy5);
|
||||
obj.removeEventListener({
|
||||
test3: spy4,
|
||||
test4: spy5
|
||||
});
|
||||
|
||||
obj.fireEvent('test3');
|
||||
obj.fireEvent('test4');
|
||||
|
||||
expect(spy4.called).to.be(false);
|
||||
expect(spy5.called).to.be(false);
|
||||
});
|
||||
|
||||
it('can handle calls to #removeEventListener on objects with no registered event listeners', function () {
|
||||
var obj = new Klass();
|
||||
var removeNonExistentListener = function () {
|
||||
obj.removeEventListener('test');
|
||||
};
|
||||
expect(removeNonExistentListener).to.not.throwException();
|
||||
});
|
||||
|
||||
// added due to context-sensitive removeListener optimization
|
||||
it('fires multiple listeners with the same context with id', function () {
|
||||
var obj = new Klass(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
L.Util.stamp(foo);
|
||||
|
||||
obj.addEventListener('test', spy1, foo);
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy1.called).to.be(true);
|
||||
expect(spy2.called).to.be(true);
|
||||
});
|
||||
|
||||
it('removes listeners with stamped contexts', function () {
|
||||
var obj = new Klass(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
L.Util.stamp(foo);
|
||||
|
||||
obj.addEventListener('test', spy1, foo);
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.removeEventListener('test', spy1, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(true);
|
||||
});
|
||||
|
||||
it('removes listeners with a stamp originally added without one', function () {
|
||||
var obj = new Klass(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
obj.addEventListener('test', spy1, foo);
|
||||
L.Util.stamp(foo);
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.removeEventListener('test', spy1, foo);
|
||||
obj.removeEventListener('test', spy2, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(false);
|
||||
});
|
||||
|
||||
it('removes listeners with context == this and a stamp originally added without one', function () {
|
||||
var obj = new Klass(),
|
||||
obj2 = new Klass(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', spy1, obj);
|
||||
L.Util.stamp(obj);
|
||||
obj.addEventListener('test', spy2, obj);
|
||||
obj.addEventListener('test', spy3, obj2); // So that there is a contextId based listener, otherwise removeEventListener will do correct behaviour anyway
|
||||
|
||||
obj.removeEventListener('test', spy1, obj);
|
||||
obj.removeEventListener('test', spy2, obj);
|
||||
obj.removeEventListener('test', spy3, obj2);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(false);
|
||||
expect(spy3.called).to.be(false);
|
||||
});
|
||||
|
||||
it('doesnt lose track of listeners when removing non existent ones', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {},
|
||||
foo2 = {};
|
||||
|
||||
L.Util.stamp(foo);
|
||||
L.Util.stamp(foo2);
|
||||
|
||||
obj.addEventListener('test', spy, foo2);
|
||||
|
||||
obj.removeEventListener('test', spy, foo); // Decrements test_idx to 0, even though event listener isn't registered with foo's _leaflet_id
|
||||
obj.removeEventListener('test', spy, foo2); // Doesn't get removed
|
||||
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
});
|
||||
|
||||
it('correctly removes all listeners if given no fn', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy(),
|
||||
foo = {},
|
||||
foo2 = {},
|
||||
foo3 = {};
|
||||
|
||||
obj.addEventListener('test', spy, foo2);
|
||||
obj.addEventListener('test', spy, foo3);
|
||||
|
||||
obj.removeEventListener('test'); // Removes both of the above listeners
|
||||
|
||||
expect(obj.hasEventListeners('test')).to.be(false);
|
||||
|
||||
//Add and remove a listener
|
||||
obj.addEventListener('test', spy, foo2);
|
||||
obj.removeEventListener('test', spy, foo2);
|
||||
|
||||
expect(obj.hasEventListeners('test')).to.be(false);
|
||||
});
|
||||
|
||||
it('makes sure an event is not triggered if a listener is removed during dispatch', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', function () { obj.removeEventListener('test', spy); });
|
||||
obj.addEventListener('test', spy);
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#on, #off & #fire', function () {
|
||||
|
||||
it('works like #addEventListener && #removeEventListener', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy();
|
||||
|
||||
obj.on('test', spy);
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.called).to.be(true);
|
||||
|
||||
obj.off('test', spy);
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy.callCount).to.be.lessThan(2);
|
||||
});
|
||||
|
||||
it('does not override existing methods with the same name', function () {
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy();
|
||||
|
||||
var Klass2 = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
on: spy1,
|
||||
off: spy2,
|
||||
fire: spy3
|
||||
});
|
||||
|
||||
var obj = new Klass2();
|
||||
|
||||
obj.on();
|
||||
expect(spy1.called).to.be(true);
|
||||
|
||||
obj.off();
|
||||
expect(spy2.called).to.be(true);
|
||||
|
||||
obj.fire();
|
||||
expect(spy3.called).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#clearEventListeners", function () {
|
||||
it("clears all registered listeners on an object", function () {
|
||||
var spy = sinon.spy(),
|
||||
obj = new Klass(),
|
||||
otherObj = new Klass();
|
||||
|
||||
obj.on('test', spy, obj);
|
||||
obj.on('testTwo', spy);
|
||||
obj.on('test', spy, otherObj);
|
||||
obj.off();
|
||||
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#once', function () {
|
||||
it('removes event listeners after first trigger', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy();
|
||||
|
||||
obj.once('test', spy, obj);
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.called).to.be(true);
|
||||
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.callCount).to.be.lessThan(2);
|
||||
});
|
||||
|
||||
it('works with an object hash', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy(),
|
||||
otherSpy = sinon.spy();
|
||||
|
||||
obj.once({
|
||||
'test': spy,
|
||||
otherTest: otherSpy
|
||||
}, obj);
|
||||
|
||||
obj.fire('test');
|
||||
obj.fire('otherTest');
|
||||
|
||||
expect(spy.called).to.be(true);
|
||||
expect(otherSpy.called).to.be(true);
|
||||
|
||||
obj.fire('test');
|
||||
obj.fire('otherTest');
|
||||
|
||||
expect(spy.callCount).to.be.lessThan(2);
|
||||
expect(otherSpy.callCount).to.be.lessThan(2);
|
||||
});
|
||||
|
||||
it("doesn't call listeners to events that have been removed", function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy();
|
||||
|
||||
obj.once('test', spy, obj);
|
||||
obj.off('test', spy, obj);
|
||||
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
});
|
||||
|
||||
it('works if called from a context that doesnt implement #Events', function () {
|
||||
var obj = new Klass(),
|
||||
spy = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
obj.once('test', spy, foo);
|
||||
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy.called).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,223 +0,0 @@
|
||||
describe('Util', function () {
|
||||
|
||||
describe('#extend', function () {
|
||||
var a;
|
||||
|
||||
beforeEach(function () {
|
||||
a = {
|
||||
foo: 5,
|
||||
bar: 'asd'
|
||||
};
|
||||
});
|
||||
|
||||
it('extends the first argument with the properties of the second', function () {
|
||||
L.Util.extend(a, {
|
||||
bar: 7,
|
||||
baz: 3
|
||||
});
|
||||
|
||||
expect(a).to.eql({
|
||||
foo: 5,
|
||||
bar: 7,
|
||||
baz: 3
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts more than 2 arguments', function () {
|
||||
L.Util.extend(a, {bar: 7}, {baz: 3});
|
||||
|
||||
expect(a).to.eql({
|
||||
foo: 5,
|
||||
bar: 7,
|
||||
baz: 3
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#bind', function () {
|
||||
it('returns the given function with the given context', function () {
|
||||
var fn = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
var fn2 = L.Util.bind(fn, { foo: 'bar' });
|
||||
|
||||
expect(fn2()).to.eql({ foo: 'bar' });
|
||||
});
|
||||
|
||||
it('passes additional arguments to the bound function', function () {
|
||||
var fn = sinon.spy(),
|
||||
foo = {},
|
||||
a = {},
|
||||
b = {};
|
||||
|
||||
var fn2 = L.Util.bind(fn, foo, a, b);
|
||||
|
||||
fn2();
|
||||
|
||||
expect(fn.calledWith(a, b)).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#stamp', function () {
|
||||
it('sets a unique id on the given object and returns it', function () {
|
||||
var a = {},
|
||||
id = L.Util.stamp(a);
|
||||
|
||||
expect(typeof id).to.eql('number');
|
||||
expect(L.Util.stamp(a)).to.eql(id);
|
||||
|
||||
var b = {},
|
||||
id2 = L.Util.stamp(b);
|
||||
|
||||
expect(id2).not.to.eql(id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#invokeEach', function () {
|
||||
it('calls the given method/context with each key/value and additional arguments', function () {
|
||||
var spy = sinon.spy(),
|
||||
ctx = {};
|
||||
|
||||
var result = L.Util.invokeEach({
|
||||
foo: 'bar',
|
||||
yo: 'hey'
|
||||
}, spy, ctx, 1, 2, 3);
|
||||
|
||||
expect(spy.firstCall.calledWith('foo', 'bar', 1, 2, 3)).to.be.ok();
|
||||
expect(spy.secondCall.calledWith('yo', 'hey', 1, 2, 3)).to.be.ok();
|
||||
|
||||
expect(spy.firstCall.calledOn(ctx)).to.be.ok();
|
||||
expect(spy.secondCall.calledOn(ctx)).to.be.ok();
|
||||
|
||||
expect(result).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false if the given agument is not object', function () {
|
||||
var spy = sinon.spy();
|
||||
|
||||
expect(L.Util.invokeEach('foo', spy)).to.be(false);
|
||||
expect(spy.called).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#falseFn', function () {
|
||||
it('returns false', function () {
|
||||
expect(L.Util.falseFn()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#formatNum', function () {
|
||||
it('formats numbers with a given precision', function () {
|
||||
expect(L.Util.formatNum(13.12325555, 3)).to.eql(13.123);
|
||||
expect(L.Util.formatNum(13.12325555)).to.eql(13.12326);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#getParamString', function () {
|
||||
it('creates 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)).to.eql(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)).to.eql(b.result);
|
||||
|
||||
var c = {
|
||||
url: undefined,
|
||||
obj: {bar: 7, baz: 3},
|
||||
result: '?bar=7&baz=3'
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(c.obj, c.url)).to.eql(c.result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#requestAnimFrame', function () {
|
||||
it('calles a function on next frame, unless canceled', function (done) {
|
||||
var spy = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
L.Util.requestAnimFrame(spy);
|
||||
|
||||
L.Util.requestAnimFrame(function () {
|
||||
expect(this).to.eql(foo);
|
||||
done();
|
||||
}, foo);
|
||||
|
||||
L.Util.cancelAnimFrame(spy);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#limitExecByInterval', function () {
|
||||
it('limits execution to not more often than specified time interval', function (done) {
|
||||
var spy = sinon.spy();
|
||||
|
||||
var fn = L.Util.limitExecByInterval(spy, 20);
|
||||
|
||||
fn();
|
||||
fn();
|
||||
fn();
|
||||
|
||||
expect(spy.callCount).to.eql(1);
|
||||
|
||||
setTimeout(function () {
|
||||
expect(spy.callCount).to.eql(2);
|
||||
done();
|
||||
}, 30);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#splitWords', function () {
|
||||
it('splits words into an array', function () {
|
||||
expect(L.Util.splitWords('foo bar baz')).to.eql(['foo', 'bar', 'baz']);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO setOptions
|
||||
|
||||
describe('#template', function () {
|
||||
it('evaluates templates with a given data object', function () {
|
||||
var tpl = 'Hello {foo} and {bar}!';
|
||||
|
||||
var str = L.Util.template(tpl, {
|
||||
foo: 'Vlad',
|
||||
bar: 'Dave'
|
||||
});
|
||||
|
||||
expect(str).to.eql('Hello Vlad and Dave!');
|
||||
});
|
||||
it('does not modify text without a token variable', function () {
|
||||
expect(L.Util.template('foo', {})).to.eql('foo');
|
||||
});
|
||||
|
||||
it('supports templates with double quotes', function () {
|
||||
expect(L.Util.template('He said: "{foo}"!', {
|
||||
foo: 'Hello'
|
||||
})).to.eql('He said: "Hello"!');
|
||||
});
|
||||
|
||||
it('throws when a template token is not given', function () {
|
||||
expect(function () {
|
||||
L.Util.template(undefined, {foo: 'bar'});
|
||||
}).to.throwError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isArray', function () {
|
||||
expect(L.Util.isArray([1, 2, 3])).to.be(true);
|
||||
expect(L.Util.isArray(new Array(1, 2, 3))).to.be(true);
|
||||
expect(L.Util.isArray('blabla')).to.be(false);
|
||||
expect(L.Util.isArray({0: 1, 1: 2})).to.be(false);
|
||||
});
|
||||
});
|
@ -1,102 +0,0 @@
|
||||
describe('DomEvent', function () {
|
||||
var el;
|
||||
|
||||
function simulateClick(el) {
|
||||
if (document.createEvent) {
|
||||
var e = document.createEvent('MouseEvents');
|
||||
e.initMouseEvent('click', true, true, window,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
return el.dispatchEvent(e);
|
||||
} else if (el.fireEvent) {
|
||||
return el.fireEvent('onclick');
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
el = document.createElement('div');
|
||||
el.style.position = 'absolute';
|
||||
el.style.top = el.style.left = '-10000px';
|
||||
document.body.appendChild(el);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
describe('#addListener', function () {
|
||||
it('adds a listener and calls it on event', function () {
|
||||
var listener1 = sinon.spy(),
|
||||
listener2 = sinon.spy();
|
||||
|
||||
L.DomEvent.addListener(el, 'click', listener1);
|
||||
L.DomEvent.addListener(el, 'click', listener2);
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(listener1.called).to.be.ok();
|
||||
expect(listener2.called).to.be.ok();
|
||||
});
|
||||
|
||||
it('binds "this" to the given context', function () {
|
||||
var obj = {foo: 'bar'},
|
||||
result;
|
||||
|
||||
L.DomEvent.addListener(el, 'click', function () {
|
||||
result = this;
|
||||
}, obj);
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(result).to.eql(obj);
|
||||
});
|
||||
|
||||
it('passes an event object to the listener', function () {
|
||||
var type;
|
||||
|
||||
L.DomEvent.addListener(el, 'click', function (e) {
|
||||
type = e && e.type;
|
||||
});
|
||||
simulateClick(el);
|
||||
|
||||
expect(type).to.eql('click');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#removeListener', function () {
|
||||
it('removes a previously added listener', function () {
|
||||
var listener = sinon.spy();
|
||||
|
||||
L.DomEvent.addListener(el, 'click', listener);
|
||||
L.DomEvent.removeListener(el, 'click', listener);
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(listener.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#stopPropagation', function () {
|
||||
it('stops propagation of the given event', function () {
|
||||
var child = document.createElement('div'),
|
||||
listener = sinon.spy();
|
||||
|
||||
el.appendChild(child);
|
||||
|
||||
L.DomEvent.addListener(child, 'click', L.DomEvent.stopPropagation);
|
||||
L.DomEvent.addListener(el, 'click', listener);
|
||||
|
||||
simulateClick(child);
|
||||
|
||||
expect(listener.called).to.not.be.ok();
|
||||
|
||||
el.removeChild(child);
|
||||
});
|
||||
});
|
||||
describe('#preventDefault', function () {
|
||||
it('prevents the default action of event', function () {
|
||||
L.DomEvent.addListener(el, 'click', L.DomEvent.preventDefault);
|
||||
|
||||
expect(simulateClick(el)).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,82 +0,0 @@
|
||||
describe('DomUtil', function () {
|
||||
var el;
|
||||
|
||||
beforeEach(function () {
|
||||
el = document.createElement('div');
|
||||
el.style.position = 'absolute';
|
||||
el.style.top = el.style.left = '-10000px';
|
||||
document.body.appendChild(el);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
describe('#get', function () {
|
||||
it('gets element by id if the given argument is string', function () {
|
||||
el.id = 'testId';
|
||||
expect(L.DomUtil.get(el.id)).to.eql(el);
|
||||
});
|
||||
|
||||
it('returns the element if it is given as an argument', function () {
|
||||
expect(L.DomUtil.get(el)).to.eql(el);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#addClass, #removeClass, #hasClass', function () {
|
||||
it('has defined class for test element', function () {
|
||||
el.className = 'bar foo baz ';
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'bar')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'baz')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'boo')).to.not.be.ok();
|
||||
});
|
||||
|
||||
it('adds or removes the class', function () {
|
||||
el.className = '';
|
||||
L.DomUtil.addClass(el, 'foo');
|
||||
|
||||
expect(el.className).to.eql('foo');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
|
||||
L.DomUtil.addClass(el, 'bar');
|
||||
expect(el.className).to.eql('foo bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
|
||||
L.DomUtil.removeClass(el, 'foo');
|
||||
expect(el.className).to.eql('bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.not.be.ok();
|
||||
|
||||
el.className = 'foo bar barz';
|
||||
L.DomUtil.removeClass(el, 'bar');
|
||||
expect(el.className).to.eql('foo barz');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getViewportOffset', function () {
|
||||
it('calculates the viewport offset of an element', function () {
|
||||
var div = document.createElement('div');
|
||||
div.style.position = 'absolute';
|
||||
div.style.top = '100px';
|
||||
div.style.left = '200px';
|
||||
div.style.border = '10px solid black';
|
||||
div.style.padding = '50px';
|
||||
div.style.visibility = 'hidden';
|
||||
|
||||
var div2 = document.createElement('div');
|
||||
div.style.marginTop = '100px';
|
||||
|
||||
div.appendChild(div2);
|
||||
|
||||
document.body.appendChild(div);
|
||||
|
||||
expect(L.DomUtil.getViewportOffset(div2)).to.eql(new L.Point(260, 260));
|
||||
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
});
|
||||
|
||||
// describe('#setPosition', noSpecs);
|
||||
|
||||
// describe('#getStyle', noSpecs);
|
||||
});
|
@ -1,27 +0,0 @@
|
||||
describe('PosAnimation', function () {
|
||||
var el;
|
||||
|
||||
beforeEach(function () {
|
||||
el = document.createElement('div');
|
||||
this.subject = new L.PosAnimation();
|
||||
this.subject._el = el;
|
||||
});
|
||||
|
||||
describe('#_onStep', function () {
|
||||
it("sets element position and fires step event if it is able to get current position", function () {
|
||||
var point = new L.Point(5, 5, true);
|
||||
sinon.stub(this.subject, '_getPos').returns(point);
|
||||
this.subject.fire = sinon.stub();
|
||||
this.subject._onStep();
|
||||
expect(this.subject.fire.withArgs('step').calledOnce).to.be(true);
|
||||
expect(L.DomUtil.getPosition(this.subject._el)).to.be(point);
|
||||
});
|
||||
|
||||
it('stops transition if a position returned', function () {
|
||||
sinon.stub(this.subject, '_onTransitionEnd');
|
||||
sinon.stub(this.subject, '_getPos').returns(undefined);
|
||||
this.subject._onStep();
|
||||
expect(this.subject._onTransitionEnd.calledOnce).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,47 +0,0 @@
|
||||
describe("CRS.EPSG3395", function () {
|
||||
var crs = L.CRS.EPSG3395;
|
||||
|
||||
describe("#latLngToPoint", function () {
|
||||
it("projects a center point", function () {
|
||||
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
||||
});
|
||||
|
||||
it("projects the northeast corner of the world", function () {
|
||||
expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
|
||||
});
|
||||
});
|
||||
|
||||
describe("#pointToLatLng", function () {
|
||||
it("reprojects a center point", function () {
|
||||
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
||||
});
|
||||
|
||||
it("reprojects the northeast corner of the world", function () {
|
||||
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("CRS.EPSG3857", function () {
|
||||
var crs = L.CRS.EPSG3857;
|
||||
|
||||
describe("#latLngToPoint", function () {
|
||||
it("projects a center point", function () {
|
||||
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
||||
});
|
||||
|
||||
it("projects the northeast corner of the world", function () {
|
||||
expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
|
||||
});
|
||||
});
|
||||
|
||||
describe("#pointToLatLng", function () {
|
||||
it("reprojects a center point", function () {
|
||||
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
||||
});
|
||||
|
||||
it("reprojects the northeast corner of the world", function () {
|
||||
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
|
||||
});
|
||||
});
|
||||
});
|
@ -1,144 +0,0 @@
|
||||
describe('LatLngBounds', function () {
|
||||
var a, c;
|
||||
|
||||
beforeEach(function () {
|
||||
a = new L.LatLngBounds(
|
||||
new L.LatLng(14, 12),
|
||||
new L.LatLng(30, 40));
|
||||
c = new L.LatLngBounds();
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('instantiates either passing two latlngs or an array of latlngs', function () {
|
||||
var b = new L.LatLngBounds([
|
||||
new L.LatLng(14, 12),
|
||||
new L.LatLng(30, 40)
|
||||
]);
|
||||
expect(b).to.eql(a);
|
||||
expect(b.getNorthWest()).to.eql(new L.LatLng(30, 12));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#extend', function () {
|
||||
it('extends the bounds by a given point', function () {
|
||||
a.extend(new L.LatLng(20, 50));
|
||||
expect(a.getNorthEast()).to.eql(new L.LatLng(30, 50));
|
||||
});
|
||||
|
||||
it('extends the bounds by given bounds', function () {
|
||||
a.extend([[20, 50], [8, 40]]);
|
||||
expect(a.getSouthEast()).to.eql(new L.LatLng(8, 50));
|
||||
});
|
||||
|
||||
it('extends the bounds by undefined', function () {
|
||||
expect(a.extend()).to.eql(a);
|
||||
});
|
||||
|
||||
it('extends the bounds by raw object', function () {
|
||||
a.extend({lat: 20, lng: 50});
|
||||
expect(a.getNorthEast()).to.eql(new L.LatLng(30, 50));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCenter', function () {
|
||||
it('returns the bounds center', function () {
|
||||
expect(a.getCenter()).to.eql(new L.LatLng(22, 26));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#pad', function () {
|
||||
it('pads the bounds by a given ratio', function () {
|
||||
var b = a.pad(0.5);
|
||||
|
||||
expect(b).to.eql(L.latLngBounds([[6, -2], [38, 54]]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#equals', function () {
|
||||
it('returns true if bounds equal', function () {
|
||||
expect(a.equals([[14, 12], [30, 40]])).to.eql(true);
|
||||
expect(a.equals([[14, 13], [30, 40]])).to.eql(false);
|
||||
expect(a.equals(null)).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isValid', function () {
|
||||
it('returns true if properly set up', function () {
|
||||
expect(a.isValid()).to.be.ok();
|
||||
});
|
||||
it('returns false if is invalid', function () {
|
||||
expect(c.isValid()).to.not.be.ok();
|
||||
});
|
||||
it('returns true if extended', function () {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getWest', function () {
|
||||
it('returns a proper bbox west value', function () {
|
||||
expect(a.getWest()).to.eql(12);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSouth', function () {
|
||||
it('returns a proper bbox south value', function () {
|
||||
expect(a.getSouth()).to.eql(14);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getEast', function () {
|
||||
it('returns a proper bbox east value', function () {
|
||||
expect(a.getEast()).to.eql(40);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getNorth', function () {
|
||||
it('returns a proper bbox north value', function () {
|
||||
expect(a.getNorth()).to.eql(30);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#toBBoxString', function () {
|
||||
it('returns a proper left,bottom,right,top bbox', function () {
|
||||
expect(a.toBBoxString()).to.eql("12,14,40,30");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getNorthWest', function () {
|
||||
it('returns a proper north-west LatLng', function () {
|
||||
expect(a.getNorthWest()).to.eql(new L.LatLng(a.getNorth(), a.getWest()));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getSouthEast', function () {
|
||||
it('returns a proper south-east LatLng', function () {
|
||||
expect(a.getSouthEast()).to.eql(new L.LatLng(a.getSouth(), a.getEast()));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#contains', function () {
|
||||
it('returns true if contains latlng point', function () {
|
||||
expect(a.contains([16, 20])).to.eql(true);
|
||||
expect(L.latLngBounds(a).contains([5, 20])).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true if contains bounds', function () {
|
||||
expect(a.contains([[16, 20], [20, 40]])).to.eql(true);
|
||||
expect(a.contains([[16, 50], [8, 40]])).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#intersects', function () {
|
||||
it('returns true if intersects the given bounds', function () {
|
||||
expect(a.intersects([[16, 20], [50, 60]])).to.eql(true);
|
||||
expect(a.contains([[40, 50], [50, 60]])).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -1,132 +0,0 @@
|
||||
describe('LatLng', function () {
|
||||
describe('constructor', function () {
|
||||
it("sets lat and lng", function () {
|
||||
var a = new L.LatLng(25, 74);
|
||||
expect(a.lat).to.eql(25);
|
||||
expect(a.lng).to.eql(74);
|
||||
|
||||
var b = new L.LatLng(-25, -74);
|
||||
expect(b.lat).to.eql(-25);
|
||||
expect(b.lng).to.eql(-74);
|
||||
});
|
||||
|
||||
it('throws an error if invalid lat or lng', function () {
|
||||
expect(function () {
|
||||
var a = new L.LatLng(NaN, NaN);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('does not set altitude if undefined', function () {
|
||||
var a = new L.LatLng(25, 74);
|
||||
expect(typeof a.alt).to.eql('undefined');
|
||||
});
|
||||
|
||||
it('sets altitude', function () {
|
||||
var a = new L.LatLng(25, 74, 50);
|
||||
expect(a.alt).to.eql(50);
|
||||
|
||||
var b = new L.LatLng(-25, -74, -50);
|
||||
expect(b.alt).to.eql(-50);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#equals', function () {
|
||||
it("returns 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)).to.eql(true);
|
||||
});
|
||||
|
||||
it("returns 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)).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns false if passed non-valid object', function () {
|
||||
var a = new L.LatLng(10, 20);
|
||||
expect(a.equals(null)).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#wrap', function () {
|
||||
it("wraps longitude to lie between -180 and 180 by default", function () {
|
||||
var a = new L.LatLng(0, 190).wrap().lng;
|
||||
expect(a).to.eql(-170);
|
||||
|
||||
var b = new L.LatLng(0, 360).wrap().lng;
|
||||
expect(b).to.eql(0);
|
||||
|
||||
var c = new L.LatLng(0, 380).wrap().lng;
|
||||
expect(c).to.eql(20);
|
||||
|
||||
var d = new L.LatLng(0, -190).wrap().lng;
|
||||
expect(d).to.eql(170);
|
||||
|
||||
var e = new L.LatLng(0, -360).wrap().lng;
|
||||
expect(e).to.eql(0);
|
||||
|
||||
var f = new L.LatLng(0, -380).wrap().lng;
|
||||
expect(f).to.eql(-20);
|
||||
|
||||
var g = new L.LatLng(0, 90).wrap().lng;
|
||||
expect(g).to.eql(90);
|
||||
|
||||
var h = new L.LatLng(0, 180).wrap().lng;
|
||||
expect(h).to.eql(180);
|
||||
});
|
||||
|
||||
it("wraps longitude within the given range", function () {
|
||||
var a = new L.LatLng(0, 190).wrap(-100, 100).lng;
|
||||
expect(a).to.eql(-10);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#toString', function () {
|
||||
it('formats a string', function () {
|
||||
var a = new L.LatLng(10.333333333, 20.2222222);
|
||||
expect(a.toString(3)).to.eql('LatLng(10.333, 20.222)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#distanceTo', function () {
|
||||
it('calculates distance in meters', function () {
|
||||
var a = new L.LatLng(50.5, 30.5);
|
||||
var b = new L.LatLng(50, 1);
|
||||
|
||||
expect(Math.abs(Math.round(a.distanceTo(b) / 1000) - 2084) < 5).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('L.latLng factory', function () {
|
||||
it('returns LatLng instance as is', function () {
|
||||
var a = new L.LatLng(50, 30);
|
||||
|
||||
expect(L.latLng(a)).to.eql(a);
|
||||
});
|
||||
|
||||
it('accepts an array of coordinates', function () {
|
||||
expect(L.latLng([50, 30])).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('passes null or undefined as is', function () {
|
||||
expect(L.latLng(undefined)).to.eql(undefined);
|
||||
expect(L.latLng(null)).to.eql(null);
|
||||
});
|
||||
|
||||
it('creates a LatLng object from two coordinates', function () {
|
||||
expect(L.latLng(50, 30)).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('accepts an object with lat/lng', function () {
|
||||
expect(L.latLng({lat: 50, lng: 30})).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('accepts an object with lat/lon', function () {
|
||||
expect(L.latLng({lat: 50, lon: 30})).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,48 +0,0 @@
|
||||
describe("Projection.Mercator", function () {
|
||||
var p = L.Projection.Mercator;
|
||||
|
||||
describe("#project", function () {
|
||||
it("projects a center point", function () {
|
||||
//edge cases
|
||||
expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
|
||||
});
|
||||
|
||||
it("projects the northeast corner of the world", function () {
|
||||
expect(p.project(new L.LatLng(90, 180))).near(new L.Point(20037508, 20037508));
|
||||
});
|
||||
|
||||
it("projects the southwest corner of the world", function () {
|
||||
expect(p.project(new L.LatLng(-90, -180))).near(new L.Point(-20037508, -20037508));
|
||||
});
|
||||
|
||||
it("projects other points", function () {
|
||||
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524));
|
||||
|
||||
// from https://github.com/Leaflet/Leaflet/issues/1578
|
||||
expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
|
||||
.near(new L.Point(8918060.964088084, 6755099.410887127));
|
||||
});
|
||||
});
|
||||
|
||||
describe("#unproject", function () {
|
||||
function pr(point) {
|
||||
return p.project(p.unproject(point));
|
||||
}
|
||||
|
||||
it("unprojects a center point", function () {
|
||||
expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
|
||||
});
|
||||
|
||||
it("unprojects pi points", function () {
|
||||
expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
|
||||
expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));
|
||||
|
||||
expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683));
|
||||
});
|
||||
|
||||
it('unprojects other points', function () {
|
||||
// from https://github.com/Leaflet/Leaflet/issues/1578
|
||||
expect(pr(new L.Point(8918060.964088084, 6755099.410887127)));
|
||||
});
|
||||
});
|
||||
});
|
@ -1,87 +0,0 @@
|
||||
describe('Bounds', function () {
|
||||
var a, b, c;
|
||||
|
||||
beforeEach(function () {
|
||||
a = new L.Bounds(
|
||||
new L.Point(14, 12),
|
||||
new L.Point(30, 40));
|
||||
b = new L.Bounds([
|
||||
new L.Point(20, 12),
|
||||
new L.Point(14, 20),
|
||||
new L.Point(30, 40)
|
||||
]);
|
||||
c = new L.Bounds();
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('creates bounds with proper min & max on (Point, Point)', function () {
|
||||
expect(a.min).to.eql(new L.Point(14, 12));
|
||||
expect(a.max).to.eql(new L.Point(30, 40));
|
||||
});
|
||||
it('creates bounds with proper min & max on (Point[])', function () {
|
||||
expect(b.min).to.eql(new L.Point(14, 12));
|
||||
expect(b.max).to.eql(new L.Point(30, 40));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#extend', function () {
|
||||
it('extends the bounds to contain the given point', function () {
|
||||
a.extend(new L.Point(50, 20));
|
||||
expect(a.min).to.eql(new L.Point(14, 12));
|
||||
expect(a.max).to.eql(new L.Point(50, 40));
|
||||
|
||||
b.extend(new L.Point(25, 50));
|
||||
expect(b.min).to.eql(new L.Point(14, 12));
|
||||
expect(b.max).to.eql(new L.Point(30, 50));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCenter', function () {
|
||||
it('returns the center point', function () {
|
||||
expect(a.getCenter()).to.eql(new L.Point(22, 26));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#contains', function () {
|
||||
it('contains other bounds or point', function () {
|
||||
a.extend(new L.Point(50, 10));
|
||||
expect(a.contains(b)).to.be.ok();
|
||||
expect(b.contains(a)).to.not.be.ok();
|
||||
expect(a.contains(new L.Point(24, 25))).to.be.ok();
|
||||
expect(a.contains(new L.Point(54, 65))).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isValid', function () {
|
||||
it('returns true if properly set up', function () {
|
||||
expect(a.isValid()).to.be.ok();
|
||||
});
|
||||
it('returns false if is invalid', function () {
|
||||
expect(c.isValid()).to.not.be.ok();
|
||||
});
|
||||
it('returns true if extended', function () {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSize', function () {
|
||||
it('returns the size of the bounds as point', function () {
|
||||
expect(a.getSize()).to.eql(new L.Point(16, 28));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#intersects', function () {
|
||||
it('returns true if bounds intersect', function () {
|
||||
expect(a.intersects(b)).to.be(true);
|
||||
expect(a.intersects(new L.Bounds(new L.Point(100, 100), new L.Point(120, 120)))).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('L.bounds factory', function () {
|
||||
it('creates bounds from array of number arrays', function () {
|
||||
var bounds = L.bounds([[14, 12], [30, 40]]);
|
||||
expect(bounds).to.eql(a);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,75 +0,0 @@
|
||||
describe('LineUtil', function () {
|
||||
|
||||
describe('#clipSegment', function () {
|
||||
|
||||
var bounds;
|
||||
|
||||
beforeEach(function () {
|
||||
bounds = L.bounds([5, 0], [15, 10]);
|
||||
});
|
||||
|
||||
it('clips a segment by bounds', function () {
|
||||
var a = new L.Point(0, 0);
|
||||
var b = new L.Point(15, 15);
|
||||
|
||||
var segment = L.LineUtil.clipSegment(a, b, bounds);
|
||||
|
||||
expect(segment[0]).to.eql(new L.Point(5, 5));
|
||||
expect(segment[1]).to.eql(new L.Point(10, 10));
|
||||
|
||||
var c = new L.Point(5, -5);
|
||||
var d = new L.Point(20, 10);
|
||||
|
||||
var segment2 = L.LineUtil.clipSegment(c, d, bounds);
|
||||
|
||||
expect(segment2[0]).to.eql(new L.Point(10, 0));
|
||||
expect(segment2[1]).to.eql(new L.Point(15, 5));
|
||||
});
|
||||
|
||||
it('uses last bit code and reject segments out of bounds', function () {
|
||||
var a = new L.Point(15, 15);
|
||||
var b = new L.Point(25, 20);
|
||||
var segment = L.LineUtil.clipSegment(a, b, bounds, true);
|
||||
|
||||
expect(segment).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#pointToSegmentDistance & #closestPointOnSegment', function () {
|
||||
|
||||
var p1 = new L.Point(0, 10);
|
||||
var p2 = new L.Point(10, 0);
|
||||
var p = new L.Point(0, 0);
|
||||
|
||||
it('calculates distance from point to segment', function () {
|
||||
expect(L.LineUtil.pointToSegmentDistance(p, p1, p2)).to.eql(Math.sqrt(200) / 2);
|
||||
});
|
||||
|
||||
it('calculates point closest to segment', function () {
|
||||
expect(L.LineUtil.closestPointOnSegment(p, p1, p2)).to.eql(new L.Point(5, 5));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#simplify', function () {
|
||||
it('simplifies polylines according to tolerance', function () {
|
||||
var points = [
|
||||
new L.Point(0, 0),
|
||||
new L.Point(0.01, 0),
|
||||
new L.Point(0.5, 0.01),
|
||||
new L.Point(0.7, 0),
|
||||
new L.Point(1, 0),
|
||||
new L.Point(1.999, 0.999),
|
||||
new L.Point(2, 1)
|
||||
];
|
||||
|
||||
var simplified = L.LineUtil.simplify(points, 0.1);
|
||||
|
||||
expect(simplified).to.eql([
|
||||
new L.Point(0, 0),
|
||||
new L.Point(1, 0),
|
||||
new L.Point(2, 1)
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -1,104 +0,0 @@
|
||||
describe("Point", function () {
|
||||
|
||||
describe('constructor', function () {
|
||||
|
||||
it("creates a point with the given x and y", function () {
|
||||
var p = new L.Point(1.5, 2.5);
|
||||
expect(p.x).to.eql(1.5);
|
||||
expect(p.y).to.eql(2.5);
|
||||
});
|
||||
|
||||
it("rounds the given x and y if the third argument is true", function () {
|
||||
var p = new L.Point(1.3, 2.7, true);
|
||||
expect(p.x).to.eql(1);
|
||||
expect(p.y).to.eql(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#subtract', function () {
|
||||
it('subtracts the given point from this one', function () {
|
||||
var a = new L.Point(50, 30),
|
||||
b = new L.Point(20, 10);
|
||||
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#add', function () {
|
||||
it('adds given point to this one', function () {
|
||||
expect(new L.Point(50, 30).add(new L.Point(20, 10))).to.eql(new L.Point(70, 40));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#divideBy', function () {
|
||||
it('divides this point by the given amount', function () {
|
||||
expect(new L.Point(50, 30).divideBy(5)).to.eql(new L.Point(10, 6));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#multiplyBy', function () {
|
||||
it('multiplies this point by the given amount', function () {
|
||||
expect(new L.Point(50, 30).multiplyBy(2)).to.eql(new L.Point(100, 60));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#floor', function () {
|
||||
it('returns a new point with floored coordinates', function () {
|
||||
expect(new L.Point(50.56, 30.123).floor()).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#distanceTo', function () {
|
||||
it('calculates distance between two points', function () {
|
||||
var p1 = new L.Point(0, 30);
|
||||
var p2 = new L.Point(40, 0);
|
||||
expect(p1.distanceTo(p2)).to.eql(50.0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#equals', function () {
|
||||
it('returns true if points are equal', function () {
|
||||
var p1 = new L.Point(20.4, 50.12);
|
||||
var p2 = new L.Point(20.4, 50.12);
|
||||
var p3 = new L.Point(20.5, 50.13);
|
||||
|
||||
expect(p1.equals(p2)).to.be(true);
|
||||
expect(p1.equals(p3)).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#contains', function () {
|
||||
it('returns true if the point is bigger in absolute dimensions than the passed one', function () {
|
||||
var p1 = new L.Point(50, 30),
|
||||
p2 = new L.Point(-40, 20),
|
||||
p3 = new L.Point(60, -20),
|
||||
p4 = new L.Point(-40, -40);
|
||||
|
||||
expect(p1.contains(p2)).to.be(true);
|
||||
expect(p1.contains(p3)).to.be(false);
|
||||
expect(p1.contains(p4)).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toString', function () {
|
||||
it('formats a string out of point coordinates', function () {
|
||||
expect(new L.Point(50, 30) + '').to.eql('Point(50, 30)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('L.point factory', function () {
|
||||
it('leaves L.Point instances as is', function () {
|
||||
var p = new L.Point(50, 30);
|
||||
expect(L.point(p)).to.be(p);
|
||||
});
|
||||
it('creates a point out of three arguments', function () {
|
||||
expect(L.point(50.1, 30.1, true)).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
it('creates a point from an array of coordinates', function () {
|
||||
expect(L.point([50, 30])).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
it('does not fail on invalid arguments', function () {
|
||||
expect(L.point(undefined)).to.be(undefined);
|
||||
expect(L.point(null)).to.be(null);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,27 +0,0 @@
|
||||
describe('PolyUtil', function () {
|
||||
|
||||
describe('#clipPolygon', function () {
|
||||
it('clips polygon by bounds', function () {
|
||||
var bounds = L.bounds([0, 0], [10, 10]);
|
||||
|
||||
var points = [
|
||||
new L.Point(5, 5),
|
||||
new L.Point(15, 10),
|
||||
new L.Point(10, 15)
|
||||
];
|
||||
|
||||
var clipped = L.PolyUtil.clipPolygon(points, bounds);
|
||||
|
||||
for (var i = 0, len = clipped.length; i < len; i++) {
|
||||
delete clipped[i]._code;
|
||||
}
|
||||
|
||||
expect(clipped).to.eql([
|
||||
new L.Point(7.5, 10),
|
||||
new L.Point(5, 5),
|
||||
new L.Point(10, 7.5),
|
||||
new L.Point(10, 10)
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,31 +0,0 @@
|
||||
describe("Transformation", function () {
|
||||
var t, p;
|
||||
|
||||
beforeEach(function () {
|
||||
t = new L.Transformation(1, 2, 3, 4);
|
||||
p = new L.Point(10, 20);
|
||||
});
|
||||
|
||||
describe('#transform', function () {
|
||||
it("performs a transformation", function () {
|
||||
var p2 = t.transform(p, 2);
|
||||
expect(p2).to.eql(new L.Point(24, 128));
|
||||
});
|
||||
it('assumes a scale of 1 if not specified', function () {
|
||||
var p2 = t.transform(p);
|
||||
expect(p2).to.eql(new L.Point(12, 64));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#untransform', function () {
|
||||
it("performs a reverse transformation", function () {
|
||||
var p2 = t.transform(p, 2);
|
||||
var p3 = t.untransform(p2, 2);
|
||||
expect(p3).to.eql(p);
|
||||
});
|
||||
it('assumes a scale of 1 if not specified', function () {
|
||||
var p2 = t.transform(p);
|
||||
expect(t.untransform(new L.Point(12, 64))).to.eql(new L.Point(10, 20));
|
||||
});
|
||||
});
|
||||
});
|
@ -1,86 +0,0 @@
|
||||
describe('FeatureGroup', function () {
|
||||
var map;
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
map.setView([0, 0], 1);
|
||||
});
|
||||
describe("#_propagateEvent", function () {
|
||||
var marker;
|
||||
beforeEach(function () {
|
||||
marker = L.marker([0, 0]);
|
||||
});
|
||||
describe("when a Marker is added to multiple FeatureGroups ", function () {
|
||||
it("e.layer should be the Marker", function () {
|
||||
var fg1 = L.featureGroup(),
|
||||
fg2 = L.featureGroup();
|
||||
|
||||
fg1.addLayer(marker);
|
||||
fg2.addLayer(marker);
|
||||
|
||||
var wasClicked1,
|
||||
wasClicked2;
|
||||
|
||||
fg2.on('click', function (e) {
|
||||
expect(e.layer).to.be(marker);
|
||||
expect(e.target).to.be(fg2);
|
||||
wasClicked2 = true;
|
||||
});
|
||||
|
||||
fg1.on('click', function (e) {
|
||||
expect(e.layer).to.be(marker);
|
||||
expect(e.target).to.be(fg1);
|
||||
wasClicked1 = true;
|
||||
});
|
||||
|
||||
marker.fire('click', { type: 'click' });
|
||||
|
||||
expect(wasClicked1).to.be(true);
|
||||
expect(wasClicked2).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('addLayer', function () {
|
||||
it('adds the layer', function () {
|
||||
var fg = L.featureGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
expect(fg.hasLayer(marker)).to.be(false);
|
||||
|
||||
fg.addLayer(marker);
|
||||
|
||||
expect(fg.hasLayer(marker)).to.be(true);
|
||||
});
|
||||
it('supports non-evented layers', function () {
|
||||
var fg = L.featureGroup(),
|
||||
g = L.layerGroup();
|
||||
|
||||
expect(fg.hasLayer(g)).to.be(false);
|
||||
|
||||
fg.addLayer(g);
|
||||
|
||||
expect(fg.hasLayer(g)).to.be(true);
|
||||
});
|
||||
});
|
||||
describe('removeLayer', function () {
|
||||
it('removes the layer passed to it', function () {
|
||||
var fg = L.featureGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
fg.addLayer(marker);
|
||||
expect(fg.hasLayer(marker)).to.be(true);
|
||||
|
||||
fg.removeLayer(marker);
|
||||
expect(fg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
it('removes the layer passed to it by id', function () {
|
||||
var fg = L.featureGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
fg.addLayer(marker);
|
||||
expect(fg.hasLayer(marker)).to.be(true);
|
||||
|
||||
fg.removeLayer(L.stamp(marker));
|
||||
expect(fg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,282 +0,0 @@
|
||||
describe("L.GeoJSON", function () {
|
||||
describe("addData", function () {
|
||||
var geoJSON = {
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [20, 10, 5]
|
||||
}
|
||||
};
|
||||
|
||||
it("sets feature property on member layers", function () {
|
||||
var layer = new L.GeoJSON();
|
||||
layer.addData(geoJSON);
|
||||
expect(layer.getLayers()[0].feature).to.eql(geoJSON);
|
||||
});
|
||||
|
||||
it("normalizes a geometry to a Feature", function () {
|
||||
var layer = new L.GeoJSON();
|
||||
layer.addData(geoJSON.geometry);
|
||||
expect(layer.getLayers()[0].feature).to.eql(geoJSON);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.Marker#toGeoJSON", function () {
|
||||
it("returns a 2D Point object", function () {
|
||||
var marker = new L.Marker([10, 20]);
|
||||
expect(marker.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D Point object", function () {
|
||||
var marker = new L.Marker([10, 20, 30]);
|
||||
expect(marker.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10, 30]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.Circle#toGeoJSON", function () {
|
||||
it("returns a 2D Point object", function () {
|
||||
var circle = new L.Circle([10, 20], 100);
|
||||
expect(circle.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D Point object", function () {
|
||||
var circle = new L.Circle([10, 20, 30], 100);
|
||||
expect(circle.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10, 30]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.CircleMarker#toGeoJSON", function () {
|
||||
it("returns a 2D Point object", function () {
|
||||
var marker = new L.CircleMarker([10, 20]);
|
||||
expect(marker.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D Point object", function () {
|
||||
var marker = new L.CircleMarker([10, 20, 30]);
|
||||
expect(marker.toGeoJSON().geometry).to.eql({
|
||||
type: 'Point',
|
||||
coordinates: [20, 10, 30]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.Polyline#toGeoJSON", function () {
|
||||
it("returns a 2D LineString object", function () {
|
||||
var polyline = new L.Polyline([[10, 20], [2, 5]]);
|
||||
expect(polyline.toGeoJSON().geometry).to.eql({
|
||||
type: 'LineString',
|
||||
coordinates: [[20, 10], [5, 2]]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D LineString object", function () {
|
||||
var polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]);
|
||||
expect(polyline.toGeoJSON().geometry).to.eql({
|
||||
type: 'LineString',
|
||||
coordinates: [[20, 10, 30], [5, 2, 10]]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.MultiPolyline#toGeoJSON", function () {
|
||||
it("returns a 2D MultiLineString object", function () {
|
||||
var multiPolyline = new L.MultiPolyline([[[10, 20], [2, 5]], [[1, 2], [3, 4]]]);
|
||||
expect(multiPolyline.toGeoJSON().geometry).to.eql({
|
||||
type: 'MultiLineString',
|
||||
coordinates: [
|
||||
[[20, 10], [5, 2]],
|
||||
[[2, 1], [4, 3]]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D MultiLineString object", function () {
|
||||
var multiPolyline = new L.MultiPolyline([[[10, 20, 30], [2, 5, 10]], [[1, 2, 3], [4, 5, 6]]]);
|
||||
expect(multiPolyline.toGeoJSON().geometry).to.eql({
|
||||
type: 'MultiLineString',
|
||||
coordinates: [
|
||||
[[20, 10, 30], [5, 2, 10]],
|
||||
[[2, 1, 3], [5, 4, 6]]
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.Polygon#toGeoJSON", function () {
|
||||
it("returns a 2D Polygon object (no holes)", function () {
|
||||
var polygon = new L.Polygon([[1, 2], [3, 4], [5, 6]]);
|
||||
expect(polygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'Polygon',
|
||||
coordinates: [[[2, 1], [4, 3], [6, 5], [2, 1]]]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D Polygon object (no holes)", function () {
|
||||
var polygon = new L.Polygon([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
||||
expect(polygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'Polygon',
|
||||
coordinates: [[[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]]]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 2D Polygon object (with holes)", function () {
|
||||
var polygon = new L.Polygon([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]]);
|
||||
expect(polygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[[2, 1], [4, 3], [6, 5], [2, 1]],
|
||||
[[8, 7], [10, 9], [12, 11], [8, 7]]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D Polygon object (with holes)", function () {
|
||||
var polygon = new L.Polygon([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[10, 11, 12], [13, 14, 15], [16, 17, 18]]]);
|
||||
expect(polygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]],
|
||||
[[11, 10, 12], [14, 13, 15], [17, 16, 18], [11, 10, 12]]
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.MultiPolygon#toGeoJSON", function () {
|
||||
it("returns a 2D MultiPolygon object", function () {
|
||||
var multiPolygon = new L.MultiPolygon([[[1, 2], [3, 4], [5, 6]]]);
|
||||
expect(multiPolygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[[[2, 1], [4, 3], [6, 5], [2, 1]]]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D MultiPolygon object", function () {
|
||||
var multiPolygon = new L.MultiPolygon([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]);
|
||||
expect(multiPolygon.toGeoJSON().geometry).to.eql({
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[[[2, 1, 3], [5, 4, 6], [8, 7, 9], [2, 1, 3]]]
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("L.LayerGroup#toGeoJSON", function () {
|
||||
it("returns a 2D FeatureCollection object", function () {
|
||||
var marker = new L.Marker([10, 20]),
|
||||
polyline = new L.Polyline([[10, 20], [2, 5]]),
|
||||
layerGroup = new L.LayerGroup([marker, polyline]);
|
||||
expect(layerGroup.toGeoJSON()).to.eql({
|
||||
type: 'FeatureCollection',
|
||||
features: [marker.toGeoJSON(), polyline.toGeoJSON()]
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a 3D FeatureCollection object", function () {
|
||||
var marker = new L.Marker([10, 20, 30]),
|
||||
polyline = new L.Polyline([[10, 20, 30], [2, 5, 10]]),
|
||||
layerGroup = new L.LayerGroup([marker, polyline]);
|
||||
expect(layerGroup.toGeoJSON()).to.eql({
|
||||
type: 'FeatureCollection',
|
||||
features: [marker.toGeoJSON(), polyline.toGeoJSON()]
|
||||
});
|
||||
});
|
||||
|
||||
it("ensures that every member is a Feature", function () {
|
||||
var tileLayer = new L.TileLayer(),
|
||||
layerGroup = new L.LayerGroup([tileLayer]);
|
||||
|
||||
tileLayer.toGeoJSON = function () {
|
||||
return {
|
||||
type: 'Point',
|
||||
coordinates: [20, 10]
|
||||
};
|
||||
};
|
||||
|
||||
expect(layerGroup.toGeoJSON()).to.eql({
|
||||
type: 'FeatureCollection',
|
||||
features: [{
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [20, 10]
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
it('roundtrips GeometryCollection features', function () {
|
||||
var json = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "GeometryCollection",
|
||||
"geometries": [{
|
||||
"type": "LineString",
|
||||
"coordinates": [[-122.4425587930444, 37.80666418607323], [-122.4428379594768, 37.80663578323093]]
|
||||
}, {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[-122.4425509770566, 37.80662588061205],
|
||||
[-122.4428340530617, 37.8065999493009]
|
||||
]
|
||||
}]
|
||||
},
|
||||
"properties": {
|
||||
"name": "SF Marina Harbor Master"
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
expect(L.geoJson(json).toGeoJSON()).to.eql(json);
|
||||
});
|
||||
|
||||
it('roundtrips MiltiPoint features', function () {
|
||||
var json = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [[-122.4425587930444, 37.80666418607323], [-122.4428379594768, 37.80663578323093]]
|
||||
},
|
||||
"properties": {
|
||||
"name": "Test MultiPoints"
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
expect(L.geoJson(json).toGeoJSON()).to.eql(json);
|
||||
});
|
||||
|
||||
it("omits layers which do not implement toGeoJSON", function () {
|
||||
var tileLayer = new L.TileLayer(),
|
||||
layerGroup = new L.LayerGroup([tileLayer]);
|
||||
expect(layerGroup.toGeoJSON()).to.eql({
|
||||
type: 'FeatureCollection',
|
||||
features: []
|
||||
});
|
||||
});
|
||||
});
|
@ -1,58 +0,0 @@
|
||||
describe('LayerGroup', function () {
|
||||
describe("#addLayer", function () {
|
||||
it('adds a layer', function () {
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
expect(lg.addLayer(marker)).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).to.be(true);
|
||||
});
|
||||
});
|
||||
describe("#removeLayer", function () {
|
||||
it('removes a layer', function () {
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
lg.addLayer(marker);
|
||||
expect(lg.removeLayer(marker)).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
});
|
||||
describe("#clearLayers", function () {
|
||||
it('removes all layers', function () {
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
lg.addLayer(marker);
|
||||
expect(lg.clearLayers()).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
});
|
||||
describe("#getLayers", function () {
|
||||
it('gets all layers', function () {
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
lg.addLayer(marker);
|
||||
|
||||
expect(lg.getLayers()).to.eql([marker]);
|
||||
});
|
||||
});
|
||||
describe("#eachLayer", function () {
|
||||
it('iterates over all layers', function () {
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]),
|
||||
ctx = { foo: 'bar' };
|
||||
|
||||
lg.addLayer(marker);
|
||||
|
||||
lg.eachLayer(function (layer) {
|
||||
expect(layer).to.eql(marker);
|
||||
expect(this).to.eql(ctx);
|
||||
}, ctx);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,119 +0,0 @@
|
||||
describe('Popup', function () {
|
||||
|
||||
var c, map;
|
||||
|
||||
beforeEach(function () {
|
||||
c = document.createElement('div');
|
||||
c.style.width = '400px';
|
||||
c.style.height = '400px';
|
||||
map = new L.Map(c);
|
||||
map.setView(new L.LatLng(55.8, 37.6), 6);
|
||||
});
|
||||
|
||||
it("closes on map click when map has closePopupOnClick option", function () {
|
||||
map.options.closePopupOnClick = true;
|
||||
|
||||
var popup = new L.Popup()
|
||||
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||
.openOn(map);
|
||||
|
||||
happen.click(c);
|
||||
|
||||
expect(map.hasLayer(popup)).to.be(false);
|
||||
});
|
||||
|
||||
it("closes on map click when popup has closeOnClick option", function () {
|
||||
map.options.closePopupOnClick = false;
|
||||
|
||||
var popup = new L.Popup({closeOnClick: true})
|
||||
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||
.openOn(map);
|
||||
|
||||
happen.click(c);
|
||||
|
||||
expect(map.hasLayer(popup)).to.be(false);
|
||||
});
|
||||
|
||||
it("does not close on map click when popup has closeOnClick: false option", function () {
|
||||
map.options.closePopupOnClick = true;
|
||||
|
||||
var popup = new L.Popup({closeOnClick: false})
|
||||
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||
.openOn(map);
|
||||
|
||||
happen.click(c);
|
||||
|
||||
expect(map.hasLayer(popup)).to.be(true);
|
||||
});
|
||||
|
||||
it("toggles its visibility when marker is clicked", function () {
|
||||
var marker = new L.Marker(new L.LatLng(55.8, 37.6));
|
||||
map.addLayer(marker);
|
||||
|
||||
marker.bindPopup('Popup1').openPopup();
|
||||
|
||||
map.options.closePopupOnClick = true;
|
||||
happen.click(c);
|
||||
|
||||
// toggle open popup
|
||||
sinon.spy(marker, "openPopup");
|
||||
marker.fire('click');
|
||||
expect(marker.openPopup.calledOnce).to.be(true);
|
||||
expect(map.hasLayer(marker._popup)).to.be(true);
|
||||
marker.openPopup.restore();
|
||||
|
||||
// toggle close popup
|
||||
sinon.spy(marker, "closePopup");
|
||||
marker.fire('click');
|
||||
expect(marker.closePopup.calledOnce).to.be(true);
|
||||
expect(map.hasLayer(marker._popup)).to.be(false);
|
||||
marker.closePopup.restore();
|
||||
});
|
||||
|
||||
it("should trigger popupopen on marker when popup opens", function () {
|
||||
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
|
||||
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));
|
||||
|
||||
map.addLayer(marker1);
|
||||
map.addLayer(marker2);
|
||||
|
||||
marker1.bindPopup('Popup1');
|
||||
marker2.bindPopup('Popup2');
|
||||
|
||||
var spy = sinon.spy();
|
||||
|
||||
marker1.on('popupopen', spy);
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
marker2.openPopup();
|
||||
expect(spy.called).to.be(false);
|
||||
marker1.openPopup();
|
||||
expect(spy.called).to.be(true);
|
||||
});
|
||||
|
||||
it("should trigger popupclose on marker when popup closes", function () {
|
||||
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
|
||||
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));
|
||||
|
||||
map.addLayer(marker1);
|
||||
map.addLayer(marker2);
|
||||
|
||||
marker1.bindPopup('Popup1');
|
||||
marker2.bindPopup('Popup2');
|
||||
|
||||
var spy = sinon.spy();
|
||||
|
||||
marker1.on('popupclose', spy);
|
||||
|
||||
expect(spy.called).to.be(false);
|
||||
marker2.openPopup();
|
||||
expect(spy.called).to.be(false);
|
||||
marker1.openPopup();
|
||||
expect(spy.called).to.be(false);
|
||||
marker2.openPopup();
|
||||
expect(spy.called).to.be(true);
|
||||
marker1.openPopup();
|
||||
marker1.closePopup();
|
||||
expect(spy.callCount).to.be(2);
|
||||
});
|
||||
});
|
@ -1,88 +0,0 @@
|
||||
|
||||
describe('TileLayer', function () {
|
||||
var tileUrl = '';
|
||||
|
||||
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("has the same zoomlevels as the tilelayer", function () {
|
||||
var maxZoom = 10,
|
||||
minZoom = 5;
|
||||
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
L.tileLayer(tileUrl, {
|
||||
maxZoom: maxZoom,
|
||||
minZoom: minZoom
|
||||
}).addTo(map);
|
||||
|
||||
expect(map.getMaxZoom()).to.be(maxZoom);
|
||||
expect(map.getMinZoom()).to.be(minZoom);
|
||||
});
|
||||
});
|
||||
|
||||
describe("accessing a tilelayer's properties", function () {
|
||||
it('provides a container', function () {
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
var layer = L.tileLayer(tileUrl).addTo(map);
|
||||
expect(layer.getContainer()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a tilelayer is added to a map that already has a tilelayer", function () {
|
||||
it("has its zoomlevels updated to fit the new layer", function () {
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 15}).addTo(map);
|
||||
expect(map.getMinZoom()).to.be(10);
|
||||
expect(map.getMaxZoom()).to.be(15);
|
||||
|
||||
L.tileLayer(tileUrl, {minZoom: 5, maxZoom: 10}).addTo(map);
|
||||
expect(map.getMinZoom()).to.be(5); // changed
|
||||
expect(map.getMaxZoom()).to.be(15); // unchanged
|
||||
|
||||
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 20}).addTo(map);
|
||||
expect(map.getMinZoom()).to.be(5); // unchanged
|
||||
expect(map.getMaxZoom()).to.be(20); // changed
|
||||
|
||||
|
||||
L.tileLayer(tileUrl, {minZoom: 0, maxZoom: 25}).addTo(map);
|
||||
expect(map.getMinZoom()).to.be(0); // changed
|
||||
expect(map.getMaxZoom()).to.be(25); // changed
|
||||
});
|
||||
});
|
||||
describe("when a tilelayer is removed from a map", function () {
|
||||
it("has its zoomlevels updated to only fit the layers it currently has", function () {
|
||||
var tiles = [ L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 15}).addTo(map),
|
||||
L.tileLayer(tileUrl, {minZoom: 5, maxZoom: 10}).addTo(map),
|
||||
L.tileLayer(tileUrl, {minZoom: 10, maxZoom: 20}).addTo(map),
|
||||
L.tileLayer(tileUrl, {minZoom: 0, maxZoom: 25}).addTo(map)
|
||||
];
|
||||
map.whenReady(function () {
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(25);
|
||||
|
||||
map.removeLayer(tiles[0]);
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(25);
|
||||
|
||||
map.removeLayer(tiles[3]);
|
||||
expect(map.getMinZoom()).to.be(5);
|
||||
expect(map.getMaxZoom()).to.be(20);
|
||||
|
||||
map.removeLayer(tiles[2]);
|
||||
expect(map.getMinZoom()).to.be(5);
|
||||
expect(map.getMaxZoom()).to.be(10);
|
||||
|
||||
map.removeLayer(tiles[1]);
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(Infinity);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,94 +0,0 @@
|
||||
describe("Marker", function () {
|
||||
var map,
|
||||
spy,
|
||||
icon1,
|
||||
icon2;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div')).setView([0, 0], 0);
|
||||
icon1 = new L.Icon.Default();
|
||||
icon2 = new L.Icon.Default({
|
||||
iconUrl: icon1._getIconUrl('icon') + '?2',
|
||||
shadowUrl: icon1._getIconUrl('shadow') + '?2'
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setIcon", function () {
|
||||
it("changes the icon to another image", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: icon1});
|
||||
map.addLayer(marker);
|
||||
|
||||
var beforeIcon = marker._icon;
|
||||
marker.setIcon(icon2);
|
||||
var afterIcon = marker._icon;
|
||||
|
||||
expect(beforeIcon).to.be(afterIcon);
|
||||
expect(afterIcon.src).to.contain(icon2._getIconUrl('icon'));
|
||||
});
|
||||
|
||||
it("changes the icon to another DivIcon", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: new L.DivIcon({html: 'Inner1Text' }) });
|
||||
map.addLayer(marker);
|
||||
|
||||
var beforeIcon = marker._icon;
|
||||
marker.setIcon(new L.DivIcon({html: 'Inner2Text' }));
|
||||
var afterIcon = marker._icon;
|
||||
|
||||
expect(beforeIcon).to.be(afterIcon);
|
||||
expect(afterIcon.innerHTML).to.contain('Inner2Text');
|
||||
});
|
||||
|
||||
it("removes text when changing to a blank DivIcon", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: new L.DivIcon({html: 'Inner1Text' }) });
|
||||
map.addLayer(marker);
|
||||
|
||||
marker.setIcon(new L.DivIcon());
|
||||
var afterIcon = marker._icon;
|
||||
|
||||
expect(marker._icon.innerHTML).to.not.contain('Inner1Text');
|
||||
});
|
||||
|
||||
it("changes a DivIcon to an image", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: new L.DivIcon({html: 'Inner1Text' }) });
|
||||
map.addLayer(marker);
|
||||
var oldIcon = marker._icon;
|
||||
|
||||
marker.setIcon(icon1);
|
||||
|
||||
expect(oldIcon).to.not.be(marker._icon);
|
||||
expect(oldIcon.parentNode).to.be(null);
|
||||
|
||||
expect(marker._icon.src).to.contain('marker-icon.png');
|
||||
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
|
||||
});
|
||||
|
||||
it("changes an image to a DivIcon", function () {
|
||||
var marker = new L.Marker([0, 0], {icon: icon1});
|
||||
map.addLayer(marker);
|
||||
var oldIcon = marker._icon;
|
||||
|
||||
marker.setIcon(new L.DivIcon({html: 'Inner1Text' }));
|
||||
|
||||
expect(oldIcon).to.not.be(marker._icon);
|
||||
expect(oldIcon.parentNode).to.be(null);
|
||||
|
||||
expect(marker._icon.innerHTML).to.contain('Inner1Text');
|
||||
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
|
||||
});
|
||||
|
||||
it("reuses the icon/shadow when changing icon", function () {
|
||||
var marker = new L.Marker([0, 0], { icon: icon1});
|
||||
map.addLayer(marker);
|
||||
var oldIcon = marker._icon;
|
||||
var oldShadow = marker._shadow;
|
||||
|
||||
marker.setIcon(icon2);
|
||||
|
||||
expect(oldIcon).to.be(marker._icon);
|
||||
expect(oldShadow).to.be(marker._shadow);
|
||||
|
||||
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
|
||||
expect(marker._shadow.parentNode).to.be(map._panes.shadowPane);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,53 +0,0 @@
|
||||
describe('CircleMarker', function () {
|
||||
describe("#_radius", function () {
|
||||
var map;
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
map.setView([0, 0], 1);
|
||||
});
|
||||
describe("when a CircleMarker is added to the map ", function () {
|
||||
describe("with a radius set as an option", function () {
|
||||
it("takes that radius", function () {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 }).addTo(map);
|
||||
|
||||
expect(marker._radius).to.be(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and radius is set before adding it", function () {
|
||||
it("takes that radius", function () {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.setRadius(15);
|
||||
marker.addTo(map);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and radius is set after adding it", function () {
|
||||
it("takes that radius", function () {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.addTo(map);
|
||||
marker.setRadius(15);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and setStyle is used to change the radius after adding", function () {
|
||||
it("takes the given radius", function () {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.addTo(map);
|
||||
marker.setStyle({ radius: 15 });
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
describe("and setStyle is used to change the radius before adding", function () {
|
||||
it("takes the given radius", function () {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.setStyle({ radius: 15 });
|
||||
marker.addTo(map);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
describe('Circle', function () {
|
||||
describe('#getBounds', function () {
|
||||
|
||||
var circle;
|
||||
|
||||
beforeEach(function () {
|
||||
circle = L.circle([50, 30], 200);
|
||||
});
|
||||
|
||||
it('returns bounds', function () {
|
||||
var bounds = circle.getBounds();
|
||||
|
||||
expect(bounds.getSouthWest().equals([49.998203369, 29.997204939])).to.be.ok();
|
||||
expect(bounds.getNorthEast().equals([50.001796631, 30.002795061])).to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
@ -1,91 +0,0 @@
|
||||
describe('Polygon', function () {
|
||||
|
||||
var c = document.createElement('div');
|
||||
c.style.width = '400px';
|
||||
c.style.height = '400px';
|
||||
var map = new L.Map(c);
|
||||
map.setView(new L.LatLng(55.8, 37.6), 6);
|
||||
|
||||
describe("#initialize", function () {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polygon = new L.Polygon(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
expect(polygon._latlngs).to.not.eql(sourceLatLngs);
|
||||
});
|
||||
|
||||
it("can be called with an empty array", function () {
|
||||
var polygon = new L.Polygon([]);
|
||||
expect(polygon.getLatLngs()).to.eql([]);
|
||||
});
|
||||
|
||||
it("can be initialized with holes", function () {
|
||||
var originalLatLngs = [
|
||||
[ //external rink
|
||||
[0, 10], [10, 10], [10, 0]
|
||||
], [ //hole
|
||||
[2, 3], [2, 4], [3, 4]
|
||||
]
|
||||
];
|
||||
|
||||
var polygon = new L.Polygon(originalLatLngs);
|
||||
|
||||
//getLatLngs() returns only external ring
|
||||
expect(polygon.getLatLngs()).to.eql([L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setLatLngs", function () {
|
||||
it("doesn't overwrite the given latlng array", function () {
|
||||
var originalLatLngs = [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
];
|
||||
var sourceLatLngs = originalLatLngs.slice();
|
||||
|
||||
var polygon = new L.Polygon(sourceLatLngs);
|
||||
|
||||
polygon.setLatLngs(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
});
|
||||
|
||||
it("can be set external ring and holes", function () {
|
||||
var latLngs = [
|
||||
[ //external rink
|
||||
[0, 10], [10, 10], [10, 0]
|
||||
], [ //hole
|
||||
[2, 3], [2, 4], [3, 4]
|
||||
]
|
||||
];
|
||||
|
||||
var polygon = new L.Polygon([]);
|
||||
polygon.setLatLngs(latLngs);
|
||||
|
||||
//getLatLngs() returns only external ring
|
||||
expect(polygon.getLatLngs()).to.eql([L.latLng([0, 10]), L.latLng([10, 10]), L.latLng([10, 0])]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#spliceLatLngs", function () {
|
||||
it("splices the internal latLngs", function () {
|
||||
var latLngs = [
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6]
|
||||
];
|
||||
|
||||
var polygon = new L.Polygon(latLngs);
|
||||
|
||||
polygon.spliceLatLngs(1, 1, [7, 8]);
|
||||
|
||||
expect(polygon._latlngs).to.eql([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
});
|
||||
});
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user