# Google Maps + Location CRASH on Android

**URL:** https://community.thunkable.com/t/google-maps-location-crash-on-android/30496
**Category:** Questions about Thunkable X
**Created:** [June 7, 2018, 5:15am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496 "2018-06-07T05:15:41Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Andrea\_Marchisio](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Andrea\_Marchisio](https://community.thunkable.com/u/Andrea_Marchisio)
#### Post date: [June 7, 2018, 5:15am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/1 "2018-06-07T05:15:41Z")

</div>

Hello,  
I’m trying to use maps components expecially zoom and center on the map but on ANDROID it crash. Only this component. I made test on Samsung S7 and S9. No problem with iOS.

I attached the blocks.

 ![Schermata%20del%202018-06-07%2007-01-10](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/3/73160f6504d7d8e5b8c0ab5d5b72a361c102d077.png)

---

<div class="post-metadata">

### Author: ![albert](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/albert/32/4077_2.png) [@albert](https://community.thunkable.com/u/albert)
#### Post date: [June 7, 2018, 7:47pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/2 "2018-06-07T19:47:58Z")

</div>

Hi there,

I believe you need to use the Map.OnMapReady instead of the Screen Starts block to trigger the event. The example below works:

![30%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/c/ac8c8825650a67003849f56e1c5649727078a634.png)

---

<div class="post-metadata">

### Author: ![Andrea\_Marchisio](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Andrea\_Marchisio](https://community.thunkable.com/u/Andrea_Marchisio)
#### Post date: [June 7, 2018, 10:11pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/3 "2018-06-07T22:11:23Z")

</div>

Hi,  
than you for your advice, “OnMapReady” is the right block but I get same error:

![Schermata%20del%202018-06-07%2023-58-21](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/8/185662d9f1049618a97c2e76547b0aa35bac7c1d.png)

 ![Screenshot_20180608-000255](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/d/bd052187d1170f7928bd6b3927b3b058ec3f56e3.jpg)

---

<div class="post-metadata">

### Author: ![Vicente\_F](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Vicente\_F](https://community.thunkable.com/u/Vicente_F)
#### Post date: [July 21, 2018, 2:26am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/4 "2018-07-21T02:26:39Z")

</div>

Hello and thank you for your time and patience. I tried several things and did what was posted but Thunkable keeps crashing every time I try to update in the map the latitude and longitude. By any chance if you made it work, can you post the full block image so we can try to replicate your example? Thank you again.

---

<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: [July 21, 2018, 7:12am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/5 "2018-07-21T07:12:32Z")

</div>

Hello,

“Thunkable keeps crashing every time” - do you run the application on Android?

---

<div class="post-metadata">

### Author: ![Andrea\_Marchisio](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Andrea\_Marchisio](https://community.thunkable.com/u/Andrea_Marchisio)
#### Post date: [July 21, 2018, 12:59pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/6 "2018-07-21T12:59:56Z")

</div>

Actech,  
the Maps continue to crash on Android devices (I already changed from more models); iOS is ok. Same blocks.  
I noticed that some month ago … please could you fix it?

Many thanks  
Andrea

![Schermata%20del%202018-07-21%2014-57-12](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/6/d6ad465657fa9428ef9b25fd2672d93cfa6a640b.png)

---

<div class="post-metadata">

### Author: ![Vicente\_F](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Vicente\_F](https://community.thunkable.com/u/Vicente_F)
#### Post date: [July 21, 2018, 1:06pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/7 "2018-07-21T13:06:40Z")

</div>

Yes i did. I meant to say, Thunkable crashes on Android devices in the blocks where the Map is set in Latitude and Longitude.

I was wondering if anyone made it work so it can paste the blocks image or if it is a problem of thunkable x with android.

Thank you again.

---

<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: [July 21, 2018, 1:18pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/9 "2018-07-21T13:18:20Z")

</div>

I am not a developer and therefore can’t fix it. Perhaps Albert will be able on this occasion to say something.

I can only suggest to wait for the hotfix or use Thunkable Classic for Android or use web api for work with Map.

---

<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: [July 21, 2018, 1:20pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/10 "2018-07-21T13:20:00Z")

</div>

I was trying to find a way to make these blocks work, but it looks like it’s an internal engine error.

---

<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: [July 21, 2018, 2:29pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/11 "2018-07-21T14:29:41Z")

</div>

Sample problem solution on Android.

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/7/97f7e1cf47cc4cdec1fa229693adc0b9ce8893b3.png)

Code (parts of the code should be properly divided according to the image). Insert your KEY API instead of the text API KEY.

```
data:text/html,<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <script src="https://maps.googleapis.com/maps/api/js?key=API KEY"></script>
    <style>
     	.map {
    		width: 100%;
    		height: 400px;
     	}
    </style>
    <div id="map" class="map"></div>
    <script>
    function initMap(){
    	var centerLatLng = new google.maps.LatLng(
    		56.2928515
    		,
    		43.7866641
    	);
    	var mapOptions = {
    		center: centerLatLng,
    		zoom: 8
    	};
    	var map = new google.maps.Map(document.getElementById("map"), mapOptions);
    	var marker = new google.maps.Marker({
    		position: centerLatLng,
    		map: map,
    		title: "Popup hint"
    	});
    }
    initMap();
    </script>
```

---

<div class="post-metadata">

### Author: ![Vicente\_F](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Vicente\_F](https://community.thunkable.com/u/Vicente_F)
#### Post date: [July 21, 2018, 3:09pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/12 "2018-07-21T15:09:20Z")

</div>

![58%20AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/f/9fa55abc0c6d4244f7cf947d3b86e19e3dd9d067.png)

Thank you actech. Because your approach i came with the following blocks that seem to work. The problem is that the map and the location sensor differ in the position because of different location provider i guess.

---

<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: [July 21, 2018, 5:20pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/13 "2018-07-21T17:20:22Z")

</div>

Your decision I like it too because of its simplicity. In the query string can specify a lot of interesting things. By the way, you can open Google Maps app (after ask for permission to access location).

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/d/1dc2257923ad16feb137994a87207301c7a8d687.png)

---

<div class="post-metadata">

### Author: ![Vicente\_F](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Vicente\_F](https://community.thunkable.com/u/Vicente_F)
#### Post date: [July 21, 2018, 5:32pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/14 "2018-07-21T17:32:49Z")

</div>

Thank you. Alternatively you can add different parameters to your URL besides location including zoom, type, etc… In Google Developer Guide you can find the URL parameters. If you need the map only without what Google maps brings to the web component(like traffic button), Here Maps is an option, although you will have to call it from your server.

---

<div class="post-metadata">

### Author: ![Andrea\_Marchisio](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Andrea\_Marchisio](https://community.thunkable.com/u/Andrea_Marchisio)
#### Post date: [July 25, 2018, 9:41am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/15 "2018-07-25T09:41:24Z")

</div>

Hello,  
question: if I have list of my stores with lat and long … is it possible get the list ordered by distance from my location?  
So I can build a listview of my stores.

Many thanks  
Andrea

---

<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: [July 25, 2018, 9:49am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/16 "2018-07-25T09:49:16Z")

</div>

Hello,

Yes. See the example [https://developers.google.com/maps/documentation/javascript/examples/distance-matrix](https://developers.google.com/maps/documentation/javascript/examples/distance-matrix)

You can also use the haversine formula, for example (I have not tested it):

```
function haversine_distance(coords1, coords2) {

     function toRad(x) {
         return x * Math.PI / 180;
    }

  var dLat = toRad(coords2.latitude - coords1.latitude);
  var dLon = toRad(coords2.longitude - coords1.longitude)

  var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
          Math.cos(toRad(coords1.latitude)) * 
          Math.cos(toRad(coords2.latitude)) *
          Math.sin(dLon / 2) * Math.sin(dLon / 2);

  return 12742 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}

```

Alex

---

<div class="post-metadata">

### Author: ![renren66](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@renren66](https://community.thunkable.com/u/renren66)
#### Post date: [July 27, 2018, 6:39am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/17 "2018-07-27T06:39:42Z")

</div>

Is it possible to place markers in the web viewer if I have the lat and long

---

<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: [July 27, 2018, 7:18am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/18 "2018-07-27T07:18:57Z")

</div>

Yes.

---

<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: [July 27, 2018, 9:55am UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/19 "2018-07-27T09:55:09Z")

</div>

Look at this (Google multiple markers - the Maps Static API)

[https://x.thunkable.com/projects/5b5acd7867d08b941b791926/project/properties/designer/](https://x.thunkable.com/projects/5b5acd7867d08b941b791926/project/properties/designer/)

---

<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:01pm UTC](https://community.thunkable.com/t/google-maps-location-crash-on-android/30496/20 "2024-11-08T12:01:03Z")

</div>


