# How to get all the marker on the map to near to current location in range of 4 kms

**URL:** <https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046>\
**Category:** Questions about Thunkable X\
**Created:** [October 24, 2019, 4:13pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046 "2019-10-24T16:13:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tijender\_Singh](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tijender\_Singh](https://community.thunkable.com/u/Tijender_Singh)\
**Post date:** [October 24, 2019, 4:13pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/1 "2019-10-24T16:13:54Z")

</div>

how to get all the marker on the map to near to current location in range of 4 kms

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 24, 2019, 8:55pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/2 "2019-10-24T20:55:04Z")

</div>

If you want a simple approximate solution, then you can use this:

1 km in latitude - approximately 0,00898°

Calculates the distance between the markers and the check, it is less than 4 km.

---

<div class="post-metadata">

**Author:** ![Tijender\_Singh](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tijender\_Singh](https://community.thunkable.com/u/Tijender_Singh)\
**Post date:** [October 24, 2019, 9:15pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/3 "2019-10-24T21:15:08Z")

</div>

Thanks for your reply actech.

I am little confused here

Let say current latitude and longitude is 53.004572726 and 10.63838378 respectively and I want this to be center and in radius of 4 km all the makers which are stored in firebase should be pinned on map

Let say if some one mark his/her location and it falls under 4km range then it should be pinned

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 25, 2019, 8:00am UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/4 "2019-10-25T08:00:36Z")

</div>

For simplicity, we assume that the surface of the earth is a sphere (1 km latitude = 1 km longitude) and a plane. You are able to calculate the distance between two points on the plane? ([https://www.mathsisfun.com/algebra/distance-2-points.html](https://www.mathsisfun.com/algebra/distance-2-points.html)).

You have the latitude and longitude of two points. Calculate distance between them and compare it with 4 \* 0,00898 ° = 0.03592. If the distance is less than 0.03592, the marker falls in the range of 4 km.

---

<div class="post-metadata">

**Author:** ![Tijender\_Singh](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tijender\_Singh](https://community.thunkable.com/u/Tijender_Singh)\
**Post date:** [October 25, 2019, 8:36am UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/5 "2019-10-25T08:36:51Z")

</div>

Thank you once again Actech for you reply. 🙂 it helped me to understand in better way

i got your point that we can calculate the distance between user location and the co-ordinates stored in the firebase but in that case the search needs to compare every coordinates stored in the firebase with the user location how can i narrow down the search to reduce the time. lets say we have more than 100,000 records in the firebase and near to user location there are only 10 markers. so checking 100,000 records will waste a lot of time

here is the link of UI

[https://www.immobilienscout24.de/Suche/S-T/Wohnung-Miete/Umkreissuche/Hamburg\_2dEilbek/22089/2471/2622035/Eilenau/-/5/2,00-/-/EURO--1000,00?enteredFrom=one\_step\_search&viewMode=MAP#/?boundingBox=53.495012%2C9.845549%2C53.643845%2C10.230071](https://www.immobilienscout24.de/Suche/S-T/Wohnung-Miete/Umkreissuche/Hamburg_2dEilbek/22089/2471/2622035/Eilenau/-/5/2,00-/-/EURO--1000,00?enteredFrom=one_step_search&viewMode=MAP#/?boundingBox=53.495012%2C9.845549%2C53.643845%2C10.230071)

this is what i want to achieve in my app.

 ![map](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/8/381036a1182f378036e2a86700fd8324fba62ff8.jpeg)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 25, 2019, 11:41am UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/6 "2019-10-25T11:41:53Z")

</div>

To reduce the number of markers necessary to break the squares (areas). For example, you break all the markers on the 10-100 area. After that, you must first define the area in which the target marker and then search for all markers in this region, which are not further 4 km.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 25, 2019, 12:09pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/7 "2019-10-25T12:09:03Z")

</div>

Another more effective way to search with the index without a breakdown on the region.

It is necessary to arrange the order all the markers coordinates and assign them to the index. When selecting a target marker you define the index and then perform a search for markers of the index up and down. Searching stops when the list of boundaries or leaving the marker coordinates of the 4 km area.

The disadvantage of this method is that it does not allow an arbitrary target point. The target point must be in the base and have an index.

---

<div class="post-metadata">

**Author:** ![Tijender\_Singh](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Tijender\_Singh](https://community.thunkable.com/u/Tijender_Singh)\
**Post date:** [October 25, 2019, 1:05pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/8 "2019-10-25T13:05:53Z")

</div>

Thank you again Actech for your help.

what i am thinking is.  
when a user mark its location then it should be stored in firebase by using postcode of the area… and all the further entries of that particular postcode should store as a list in that key…

and when map is opened all the marker of that particular postcode should be loaded in the map in addition to two more postcode so that some area is covered.

if you think its a good solution. please help me to know if there is a Api or a way to have postcode via co-ordinates… Thanks again 🙂

or also suggest me a way to enhance this approach further

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [October 25, 2019, 7:08pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/9 "2019-10-25T19:08:29Z")

</div>

To solve your problem better to use a ready API, such as Google Map and Geometry Library google.maps.geometry.spherical.computeDistanceBetween

But Thunkable X no easy way to exchange data between the WebViewer and App.

---

<div class="post-metadata">

**Author:** ![trawellit](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/trawellit/32/66464_2.png) [@trawellit](https://community.thunkable.com/u/trawellit)\
**Post date:** [October 18, 2020, 8:12pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/10 "2020-10-18T20:12:58Z")

</div>

Hello, I have the same problem, but with cultural heritage and monuments. Did you find a solution?  
Thanks

---

<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:** [October 18, 2020, 9:20pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/11 "2020-10-18T21:20:24Z")

</div>

I would use Backendless for your dB. It is the perfect solution for this!

Alternatively, you could run a haversine formula on all Geo points as they relate to your current GL point and then order them and display the data that way

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 19, 2020, 6:37am UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/12 "2020-10-19T06:37:03Z")

</div>

What I’ve done in my project, which finds the nearest air quality sensor to your location, is to calculate the distance between the current location and every other location in a spreadsheet using the haversine formula. See [Calculate distance travelled](http://community.thunkable.com/t/calculate-distance-travelled/565278/14).

---

<div class="post-metadata">

**Author:** ![trawellit](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/trawellit/32/66464_2.png) [@trawellit](https://community.thunkable.com/u/trawellit)\
**Post date:** [October 19, 2020, 7:08am UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/13 "2020-10-19T07:08:59Z")

</div>

Thanks, I will try.

Anyway I’m not able to understand the API…so, by now, I want to avoid to use them

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:08pm UTC](https://community.thunkable.com/t/how-to-get-all-the-marker-on-the-map-to-near-to-current-location-in-range-of-4-kms/287046/14 "2024-11-08T12:08:35Z")

</div>


