How to calculate a new bounding box that is 80% of the actual bounding box returned by google map?
First I suggest you to take a look at the docs of the geometry library
Then here are the steps that are recommended:
- Measure the horizontal and vertical dimensions of the bounds.
- Multiply both of them by 0.1 thus you will get the 10% value of each.
- Calculate the distance you will use to offset the new bounds' corner coordinates by calculating the hypotenuse of the triangle where the two legs are the two 10% values. So it will look like leg1 to the pwr of 2 + leg2 to the pwr of 2 = hypotenuse to the pw of 2 Simple pithagoras theorem.
- Now that you have the hypotenuse value, you can use that as an offset distance from the two corners of the bounds: the southwestern and northeastern. Use > computeOffset(from:LatLng, distance:number, heading:number, radius?:number) from the google library i referenced above. When calculating the offset by the southwestern corner, use a heading value of 45° and by the northeastern, use 225°
- The above steps will result in having two new latlngs that you can use to form your new, reduced bounds object. You can test the functionality by drawing rectangle objects, using these bounds.
I think it will be exactly what you need.