Location sensor alternative

hi all can someone suggest an alternative to location sensor , i have tried many extensions but all of them are very slow

i found a script on w3schools to get location , can i run this is app inventor somehow

<!DOCTYPE html>

<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

var x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;


Why won't you use location sensor component ?

its too slow

Do you want to create an extension for this code

who me ? i dont have any idea how to create extensions

I can create, but what is the problem and why you showed us the code?

the html code? the problem is that the location sensor is too slow and i want to get coordinates from location sensor but it takes upto 1 minute thats why i was finding a alternative i tried many extensions but they are too slow

1 Like

If you use the gps receiver, the receiver MUST get a satellite fix. The initial fix may take 30 to 60 seconds; subsequent fixes will take about 20 seconds or less depending on many factors.

Have you read Using the Location Sensor the section that explains that?

The html file does work in the webviewer, asks user for permission to access Location (Location services need to be ON) No reason why this method would be any quicker than built-in blocks / component method, so may as well use the built in method.

5 posts were split to a new topic: How can I use the WebViewString?

You could try something like this that uses WIFI/network instead of the gps receiver hardware.
If you are WIFI connected, it should provide an instantaneous location response.

This works on my 4.2 phone with passive provider. It might also work with network provider. It does not work with my 8.1 Android. :cry:

Be sure to unlock the Provider when you are finished experimenting.

Does the example help?