# Automatic map scaling

**URL:** https://community.thunkable.com/t/automatic-map-scaling/1660457
**Category:** Questions about Thunkable X
**Tags:** googlemaps
**Created:** [December 26, 2021, 12:18am UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457 "2021-12-26T00:18:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lavrynenko](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/lavrynenko/32/108213_2.png) [@lavrynenko](https://community.thunkable.com/u/lavrynenko)
#### Post date: [December 26, 2021, 12:18am UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/1 "2021-12-26T00:18:50Z")

</div>

Friends, I have another question: how to implement automatic scaling of Google maps?

Situation: There is the current location of the user, which we show on the map. After that, we create two or three labels at some distance from the user. The task: to automatically mass scale the map so that it would show both the user’s location and all the placemarks on the map.

Now I easily display the user’s current location on the map (thanks to the creators of Thunkable), and all the necessary labels - but if the label goes beyond the visible field of the map - until the user zooms out on his own - the label is not visible.

How can this be done?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [December 26, 2021, 8:54am UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/2 "2021-12-26T08:54:07Z")

</div>

Use the `zoom level`  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f8be124acea7255c8f8ec8af6775f478438f10b3.png) to change the view.

---

<div class="post-metadata">

### Author: ![lavrynenko](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/lavrynenko/32/108213_2.png) [@lavrynenko](https://community.thunkable.com/u/lavrynenko)
#### Post date: [December 26, 2021, 3:12pm UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/3 "2021-12-26T15:12:43Z")

</div>

This option, yes, I know - but it is not very good, because if the labels are far from each other, I may not guess with the scaling and make it too large or too small … ☹

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 26, 2021, 3:30pm UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/4 "2021-12-26T15:30:45Z")

</div>

Hey @lavrynenko 👋

I think there’s 4 questions to answer here

1. How far apart are my two furthest POI

2. How do figure ^^^^ this out?

3. How many km wide is the map at each zoom level

4. Based on the above, what zoom level would encompass all my POi

If you can answer these, you can achieve this “auto scaling” behavior.

---

<div class="post-metadata">

### Author: ![lavrynenko](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/lavrynenko/32/108213_2.png) [@lavrynenko](https://community.thunkable.com/u/lavrynenko)
#### Post date: [December 26, 2021, 3:36pm UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/5 "2021-12-26T15:36:09Z")

</div>

By the way, this is a very interesting option! Thanks! I will conduct experiments 🙂

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [December 26, 2021, 4:25pm UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/6 "2021-12-26T16:25:00Z")

</div>

The `MAP` object in Google has a method called `fitbounds()` which can be used a JavaScript code to first add all markers in a list (LatLngBond) and then call fitbounds() passing this list as the parameters. This will autozoom the map to fit all markers.

This can be done in a `Web Viewer`.

> [@jared](#):
>
> How far apart are my two furthest POI

Interestingly, the `fitbounds()` method allows passing only two coordinates which are the two furthest point, the documentation names them as NE and SW to display the complete markers without having to add all of them to the list.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [March 26, 2022, 4:25pm UTC](https://community.thunkable.com/t/automatic-map-scaling/1660457/7 "2022-03-26T16:25:26Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
