Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon with no points causes javascript error #6664

Closed
captain-igloo opened this issue May 14, 2019 · 1 comment
Closed

Polygon with no points causes javascript error #6664

captain-igloo opened this issue May 14, 2019 · 1 comment
Labels

Comments

@captain-igloo
Copy link

  • [*] I've looked at the documentation to make sure the behavior is documented and expected
  • [*] I'm sure this is a Leaflet code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • [*] I've searched through the issues to make sure it's not yet reported

Steps to reproduce

  1. create a polygon with no points
  2. add it to the map
  3. call setStyle({weight: 1})

See https://jsfiddle.net/q5x3bsy0/

Expected behavior
I expect no javascript error. There is no error with leaflet 1.4.0.

Current behavior
This results in a javascript error: "Cannot read property 'min' of undefined"

Environment

  • Leaflet version:1.5.1
  • Browser (with version): Chromium 73
  • OS/Platform (with version): Ubuntu Linux 18.04

Additional context
Possibly a duplicate of #6662

Minimal example reproducing the issue

var mymap = L.map('map');
var polygon = L.polygon([]);
polygon.addTo(mymap);
polygon.setStyle({
	weight: 1
});

Please create an example using https://leafletjs.com/edit.html or any other jsfiddle-like site.
https://jsfiddle.net/q5x3bsy0/

  • [*] this example is as simple as possible
  • [*] this example does not rely on any third party code
@opoto
Copy link

opoto commented May 18, 2019

Same issue here.
The proposed fix from #6662 solves it on my side.

NielsHolt added a commit to FCOO/Leaflet that referenced this issue Dec 14, 2019
naedx added a commit to naedx/Leaflet that referenced this issue May 14, 2020
This is a copy of commit #19b0fb3cac7f6fbdae6c15a02dee9da824f1112b
mourner pushed a commit that referenced this issue Oct 29, 2021
* Fix issue #6662 and #6664

* Add unit test for Path weight set error

* Simplify Polyline weight set test case

* Alternative fix for setting weight after empty Polyline is added to the map

* Add unit test for setting weight after empty Polygon is added to the map

* Return when empty Polyline is being rendered

* More general formulation for test

* Minor refactoring to make tests more uniform

Co-authored-by: fodor0205 <fodor0205@gmail.com>
Co-authored-by: johndoe <johnd0e@mail.ua>
@mourner mourner closed this as completed Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants