question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.getBounds().pad() not working with negative values

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanSanchezcommented, Aug 31, 2017

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?

0reactions
IvanSanchezcommented, Aug 31, 2017

@CalvinWilliams1012 I think #5748 looks good enough. You can always run jake docs to build the documentation and check for yourself 🙂

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found