Commit Graph

473 Commits

Author SHA1 Message Date
ghybs
d6fc47d70e Fix(DivIcon): revert #5517 to avoid appending a single node instead of generating content (#5574)
* Docs(Marker): explain checks for re-using icon element

when the marker is modified with an icon of the same type (i.e. an image icon with an image icon, or a DivIcon with a DivIcon), or checks for NOT re-using the icon element when modifying with an icon of a different type (i.e. an image icon with a DivIcon, or the reverse).

* Revert "Div icon accept node element as option (#5517)"

This reverts commit ba7bfb5011.

Conflicts:
	spec/suites/layer/marker/MarkerSpec.js
2017-06-25 14:11:57 +02:00
Per Liedman
a3ec8047b3 Add className option for ImageOverlay (#5555) 2017-06-22 16:25:15 +02:00
Per Liedman
b23d83f464 Don't turn enter keypress into clicks on map (#5507)
* Don't turn enter keypress into clicks on map

But still preserve functionality to open marker's popup through
enter keypress when focused.

Fixes #5499.

* Clean code

Thanks @egoroof

* Change name of keypress handler to _onKeyPress

* Add unit test
2017-06-02 11:18:46 +02:00
Matt Grande
1120c46ed9 Add precision parameter to all toGeoJSON functions (#5444)
* Add precision parameter to all toGeoJSON functions

* Replace usage of toPrecision with Utils.formatNum

* Always default to six decimal places

* Fix docs

* Allow precision of 0
2017-05-31 14:06:58 +02:00
MGMsystems
ba7bfb5011 Div icon accept node element as option (#5517)
* Added option to allow DOM elements inside a DIV icon

* Removed white line

* Adapted so that the dom element can be passed with the html option

* Update DivIcon.js

Changed documentation to state HTMLElement
2017-05-22 09:57:21 +02:00
Iván Sánchez Ortega
873d4cab31 Handle edge case of empty bounds on _getBoundsCenterZoom (#5157)
* Handle edge case of empty bounds on _getBoundsCenterZoom

* Unit test for map._getBoundsCenterZoom
2017-05-11 22:33:46 +02:00
ghybs
f677f9c6d2 Feat(Bounds): add new methods for 2 missing corners (#5488)
* Feat(Bounds): add getTopLeft & getBottomRight methods

as suggested in #5475, for consistency with `LatLngBounds` methods which already provide methods for the 4 possible corners.
Also include the docstrings.

* Docs(Bounds): add comments to identify corners

in BoundsSpec.

* Test(Bounds): add tests for existing corner methods

namely getBottomLeft and getTopRight.
Checked that expecting different values make the tests fail.

* Test(Bounds): add spec for 2 new corner methods

namely getTopLeft and getBottomRight.
Closes #5475 together with previous PR #5487.

* Refactor(Bounds): return this.min(max) instead of new Point

as TopLeft corner is tha same as this.min (BottomRight same as this.max).

* Docs(Bounds): add links to this.min(max)

to make it clearer that these methods are just shorthands to already available properties.
Furthermore, it implies that they output those properties directly, making a clue for the app developer that if he/she wants to modify them, they should be cloned before doing so in order to prevent unintentional behaviour.
2017-05-11 22:24:15 +02:00
Iván Sánchez Ortega
7e1740ecdf Better sanity checks for avoiding loading infinite tiles (#5479)
* Sanity check to prevent loading tiles when bounds are `Infinity`

* Make linter happy

* Better sanity checks for avoiding loading infinite tiles

* typo
2017-04-25 15:00:47 +02:00
Dave Leaver
27263b7afa Control.Layers: Only add layer events to layers when we are on the map. Fixes #5421 (#5422) 2017-03-28 23:10:29 +02:00
Tom Salisbury
96cfdd3a3d Added z-index support to ImageOverlay (#5418) 2017-03-28 10:54:24 +02:00
Tom Salisbury
8278ed393d Added error event to ImageOverlay layer and added tests for the new (#5416)
event and existing error handling. Also added missing
documentation for the load event.
2017-03-28 08:54:26 +02:00
Per Liedman
c18ac11efb Include L.Mixin.Events again; add deprecation notice (#5365)
Close #5358
2017-03-07 09:53:24 +01:00
Lewis Christie
0ed260c847 fix invalid geoJSON produced by nested LayerGroups (#5359) 2017-03-02 13:21:56 +01:00
ghybs
9e4f79d1e5 Fix(#5328): Layers Control can now become scrollable even if collapsed: false (#5348)
* Fix(#5328): Layers Control scrollable even if collapsed: false

the `expand()` method was called only when expanding the Layers Control through user action.
In the case of option `collapsed: false`, no event listener is attached (no user action expected to expand), therefore the control height is no longer adjusted compared to map container's height, whereas the only time it is done is at initialization, when the control is not yet inserted into the DOM, hence it does not have an actual height to check against.
Therefore added a hook on `addTo()` in order to run `expand()` AFTER the control has been insterted into the DOM.
The same issue happens when later adding more base layers / overlays to the Layers Control: it not collapsed, we should run again the height check (e.g. through the `expand()` method) to make sure we make it scrollable if necessary.
Therefore called `expand()` after each `_addLayer()`.
Actually checking first if the control is on map and if option `collapsed: false` in order to prevent calling `expand()` for nothing.

* Test(ControlLayers): 2 tests for collapsed: false being scrollable

(for issue #5328).
CAUTION: unlike most other tests, had to actually insert the map container into the DOM (i.e. `document.body`) for these tests to be useful, otherwise the height remains at 0.
This may lead to memory leak and tests hanging if done on too many tests (see Leaflet.markercluster tests issue, e.g. https://github.com/Leaflet/Leaflet.markercluster/pull/577)
2017-02-21 14:33:01 +01:00
Iván Sánchez Ortega
f57b5bf7ee Couple tests for Map.Keyboard.disable() 2017-02-14 13:15:50 +01:00
Iván Sánchez Ortega
c856c6090f Do not stop keypress on escape if no popup is open 2017-02-14 13:15:50 +01:00
Simon Legner
c5f7dc4ad3 ES2015 modules: Add index.js files to subdirectories/namespace (#5329)
* Add index.js files to subdirectories/namespace

This allows to streamline the import/export in the main file.

* Fix tests by switching to karma-rollup-plugin
2017-02-13 14:14:00 +01:00
Joachim Kuebart
1010451a66 Pull min/maxNativeZoom from TileLayer into GridLayer, as per #5316. (#5319)
* Pull min/maxNativeZoom from TileLayer into GridLayer, as per #5316.

* Add a couple unit tests for GridLayer's maxNativeZoom
2017-02-09 10:33:43 +01:00
Uzerus
cab880d4d8 type attribute not required in HTML5 2017-02-06 20:32:50 +01:00
Miguel Andrade
ad75456fa5 add margin to LatLngBounds.equals method (#5071)
* add margin to LatLngBounds equals method

* add tests
2017-02-02 16:55:30 +01:00
Iván Sánchez Ortega
ddc3a9ca61 Fix max/min calculation for getBoundsZoom (fixes #5136) (#5137)
* Fix max/min calculation for getBoundsZoom (fixes #5136)

* Added test for inside param of L.Map.getBoundsZoom()
2017-02-02 16:21:10 +01:00
Dave Leaver
5603a87c70 Remove marker.dragging when not on the map (#5295)
* Add some tests for #5293

* Fix enabling marker dragging while markers aren't on the map by removing the dragging object when not on the map.

This is a change of behavior (.dragging is only defined when a marker is on the map).

* Docs for dragging change
2017-02-02 10:14:39 +01:00
Vladimir Agafonkin
703ae02aa8 ES6 modules & Rollup (#4989)
* WIP ES6 modules & rollup

* WIP ES6 modules & rollup 2

* WIP ES6 modules & rollup 3

* WIP ES6 modules Browser

* WIP ES6 module fixes

* WIP ES6 modules: simpler browser exports

* WIP ES6: refactor CRS/Projection modules, CRS obj -> CRS.Base

* get rid of unnecessary index.js

* WIP ES6 modules, dom events and stuff

* Make linter happy, rollup to dist/

* revert to CRS namespace/class for now

* WIP rollup: export more stuff

* export controls

* rollup: export Layer

* rollup: export DomEvent

* rollup: export more layer types

* rollup: export Popup/Tooltip

* WIP: ES6-ify marker, icon, domutil, draggable.

* ES6-ify gridlayer, tilelayer.

* ES6-ify: Tweak imports-exports, code is now runnable!!

* ES6-ify: Fix scope in some DomUtils

* ES6-ify: Path, fix Popup

* ES6-ify: Lint & cleanup

* ES6-ify map handlers, more linting

* ES6-ify: Icon.Default namespacing

* ES6-ify: Renderers, CircleMarker

* ES6-ify: Circle, Polyline, LineUtil

* ES6-ify: Polygon, Rectangle, LineUtil, PolyUtil, linting

* ES6-ify: SVG.VML

* ES6-ify: DomEvent.Pointer, DomEvent.DoubleTap

* ES6-ify: Linting, make Karma play nice with Rollup

* ES6-ify: More work on fixing bits breaking some unit tests.

* ES6-ify: rollup the version number, fiddled with build scripts

* ES6-ify: Fiddle with test scripts

* ES6-ify: cleanup (refs to global L, imports from (DOM)Util), prevent cyclic loop on Map imports

* ES6-ify: More cleanup of (DOM)Util/Browser/DomEvent imports

* ES6ify: Use rollup's "legacy" option for ES3 (IE8) builds

* ES6-ify: Clean up build scripts, fix CONTRIBUTING.md instructions

* Typo

* ES6-ify: minor fixes and lefovers after rebasing on top of 1.0.2

* ES6-ify: upgrade to rollup 0.38 for proper IE8 builds, fix L.SVG.VML

* Make linter happy.

* ES6: Fixing typos and sxrew-ups after big rebase

* Fix symlink for debugging scripts

* ES6: Cleanup old build scripts

* ES6-ify: Update build system to include git rev in L.version

* ES6-ify: re-enable unit tests replacing L.Path with L.Polyline

* Export Path

* ES6ify: cleanup old banner file

* ES6-ify: whitespace in var declarations

* ES6-ify: Export toTransformation as L.transformation

* ES6-ify: cleanup L.transform exports

* ES6-ify: "import Util" in Transformation and SVG.VML
2017-01-30 11:35:16 +01:00
Markus
3ac37c29a4 Add L.transformation factory, allow creation from array (#5282)
* added transformation getter

* fixed lint, added editorconfig

* added CRS.Simple transformation values again

* removed editorconfig
2017-01-30 09:43:50 +01:00
Iván Sánchez Ortega
059a722b5b Implement wrapLatLngBounds (to fix #5149) (#5166)
* Implement wrapLatLngBounds (to fix #5149)

* Unit tests for wrapLatLngBounds
2017-01-13 16:39:01 +01:00
Iván Sánchez Ortega
b8b7281ee8 Added unit test for #5202 2016-12-21 14:49:47 +01:00
Marvin Bredal Lillehaug
884463bb09 Avoid getBoundsZoom return Infinity when using CRS with flipped axis (#5204)
* Create new bounds from projected coordinates rather than subtract in getBoundsZoom to avoid negative scale. Fixes #5195

* Fix unit test mocks

Apparently, mocking `project()` instead of `latLngToPoint()` magically works.

* Expected zoomlevel is 9, not 7
2016-12-19 12:40:22 +01:00
Gert Van Gool
9d6e6fcdf4 Fixes Layer.isPopupOpen when no popup is bound (#5106)
* Adds initial tests for L.Layer#popup

* Fixes Layer.isPopupOpen when no popup is bound

This fixes uncaught exception when checking whether a popup isOpen(),
when the layer has no popup bound to it.
2016-11-29 10:33:54 +01:00
Iván Sánchez Ortega
633182a836 Sanity check in LatLngBounds.contains (fixes #5132) (#5135) 2016-11-24 09:36:33 +01:00
Per Liedman
2253672051 Only collapse layer control if collapsed: true (#5131)
Close #5126
2016-11-23 10:49:59 +01:00
Julio Garcia
d303a7b681 Adding Unit Tests for minNativeZoom and maxNativeZoom 2016-11-18 15:45:23 +01:00
Iván Sánchez Ortega
4e979514c3 Add a 'sortLayers' option to L.Control.Layers (#4711)
* Add a 'sortLayers' option to L.Control.Layers

* Add a sortFunction option to L.Control.Layers

* Fix default sort function; modify test
2016-11-17 12:52:29 +01:00
Yohan Boniface
88d107ca96 Merge pull request #5087 from Leaflet/layers-collapse-alt
Always create L.Control.Layers as collapsed; expand if collapse option not set
2016-11-11 16:15:49 +01:00
Per Liedman
a656a0b9ec Add unit test 2016-11-11 15:54:05 +01:00
Iván Sánchez Ortega
8c22c4e385 Ensure zoom is within span when adding a layer with min/maxzoom, fixes #4915 (#4916)
* Ensure zoom is within span when adding a layer with min/maxzoom, fixes #4915.

* Add tests written by @theashyster

* Add tests to verify map's zoom is actually adjusted to layer's min/max
2016-11-11 10:46:31 +01:00
Iván Sánchez Ortega
fd78560036 L.GeoJSON.asFeature should pass through FeatureCollections (#5049)
* L.GeoJSON.asFeature should pass through FeatureCollections

* Add unit test to verify FeatureCollection toGeoJSON
2016-11-10 13:53:38 +01:00
ghybs
34dca3cfd9 Fix #5011 (canvas remove+add) (#5024)
Bug when using map option `preferCanvas: true` (canvas renderer for paths) and removing then adding back a vector within the same animation frame (typically in the same sequence, as done by Leaflet.markercluster at `"zoomend"` event, to remove layers and clusters outside visible bounds).
This commit clears the `_removed` flag from paths when they are added to the canvas.
Also added corresponding test suites.
2016-10-20 15:50:15 +03:00
Vladimir Agafonkin
fd8c2599ef fix icon url warnings in tests 2016-09-27 17:58:08 +03:00
Yohan Boniface
e28f7ae984 Do not fail when closing an interactive tooltip not yet added to the map (#4937) 2016-09-26 16:40:51 +03:00
Andris Nolendorfs
62fdf6f642 Fix handling of NaN in getScaleZoom (#4914)
* Fixed an issue when crs.zoom returns NaN in getScaleZoom

* Small documentation fixes
2016-09-15 09:46:53 +02:00
Iván Sánchez Ortega
63fd4edc76 wrap tileBounds if noWrap is false by @fyeah (#4908) 2016-09-12 16:59:21 +02:00
Per Liedman
ed1a612e6f Make paths insensitive to the order of its map's moveend handlers (#4855)
* Make Paths always update after renderer updates

Close #4851

* Add test

* Add docs for update event

* Remove listener when layer is removed
2016-08-31 17:58:46 +03:00
Per Liedman
017d29c4eb Just store array of listeners, count is no longer needed. (#4842)
* Just store array of listeners, count is no longer needed.

* Remove unused code
2016-08-25 17:23:58 +02:00
Yohan Boniface
7927708b40 Allow to create and open a tooltip without source (fix #4827) (#4836) 2016-08-25 15:29:20 +02:00
Per Liedman
cee8edeaf2 Fix listener removal even if an event is firing
Close #4840.
2016-08-25 15:20:51 +02:00
Per Liedman
59c6bb201c Use spies as listeners 2016-08-24 09:52:29 +02:00
Per Liedman
0c6dc2ce1e Make event firing reentrant
Close #4833
2016-08-24 09:26:53 +02:00
Iván Sánchez Ortega
e9957cfa02 Detect L.Icon.Default.imagePath using CSS. #4604, #3696, #4579 (#4605)
* CSS-based paths for L.Icon.Default. #4604, #3696, #4579

* Unit tests for default icons

* Make CSS icon path detection IE8-friendly

* Backwards compatibility for L.Icon.Default.imagePath override.

* Don't overwrite options
2016-08-22 16:40:03 +02:00
Steve
92baa9c73f Throw error on call to L.Polygon getCenter before map add (#4820)
* Throw error on call to L.Polygon getCenter before map add

References #4740

* add polyline handling, tests, and docstring
2016-08-15 17:01:41 +02:00
Iván Sánchez Ortega
09937e39b0 Add a _leaflet_id to the map container to fix #4806 (#4810) 2016-08-11 09:10:46 +02:00