Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds,
 int width, int height, int padding);

What is the difference between bounds and the width/height ints?

Official doc says that

Returns a CameraUpdate that transforms the camera such that the specified latitude/longitude bounds are centered on screen within a bounding box of specified dimensions at the greatest possible zoom level.

But to me is not clear. Could you semplify it for me ? Thanks

The LatLngBounds object represents a bounding box on the Earth's surface. The width and height parameters represent a bounding box on the phone's screen. This method takes the LatLngBounds and zooms the camera such that the entire bounds fits within a rectangle of width width and height height and centers the map on that rectangle.

Padding is the space between the edges of the rectangle and the edges of the LatLngBounds. Essentially, it just allows you to zoom out or provide some surrounding area in terms of pixels, as opposed to having to figure out how much space you want in latitude and longitude and adjusting your bounds. – Elan Hamburger Jul 21, 2017 at 14:09

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.