.getBounds().pad() not working with negative values
See original GitHub issueThis referes to a 2 year old issue found here: https://github.com/Leaflet/Leaflet/issues/2673
The problem: When passing negative values into the .pad() function, the result is not smaller than the current map container (-10 and 10 produce results that differ only slightly in size, but are both bigger than the map)
Steps to reproduce: Open the leaflet homepage map
Enter:
L.rectangle(map.getBounds().pad(-10)).addTo(map)
L.rectangle(map.getBounds().pad(10)).addTo(map)
into the console
Zoom out, see two rectangles bigger than the actual map at the time of drawing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Leaflet.js shrink getBounds() - Stack Overflow
Leafletjs has a function pad(x) for increasing the latLng bounds. How do I shrink it? I've tried putting a negative number in there...
Read more >ee.Image.not - Earth Engine - Google Developers
Demonstrates the ee.Image.Not method. * * This example uses positive integers; non-integer and negative * values are allowed.
Read more >Documentation - a JavaScript library for interactive maps
getBounds(), LatLngBounds. Returns the geographical bounds visible in the current map view. getMinZoom(), Number. Returns the minimum zoom level of the map ...
Read more >Built-in Macro Functions - ImageJ
Returns an array containing the names of available system fonts (example). getHeight() Returns the height in pixels of the current image.
Read more >PIXI.Container - PixiJS API Documentation
Sets the default value for the container property ... Also be aware of that this may not work nicely with the addChildAt() function, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think this is a bug, it’s just a misunderstanding of what the method does, and the fact that we are using the word “percentage” in the docstrings rather than “ratio”.
Some clarification in the docstrings for that method (e.g.
Returns bigger bounds created by extending the current bounds by a given ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50%. Negative values yield smaller bounds instead.
or something like that) would prevent this confusion in the future.@CalvinWilliams1012, maybe you would like to make such a change in the documentation?
@CalvinWilliams1012 I think #5748 looks good enough. You can always run
jake docs
to build the documentation and check for yourself 🙂