Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeps loading location on Android #132

Open
ewooonk opened this issue Dec 19, 2017 · 0 comments
Open

Keeps loading location on Android #132

ewooonk opened this issue Dec 19, 2017 · 0 comments

Comments

@ewooonk
Copy link

ewooonk commented Dec 19, 2017

The web-app keeps reloading the location on Android and ignores maximumAge. Therefore the overlay is shown more or less all the time.

Proposed solution

function changelocation(location)
{
    var now = new Date();
    if(lastUpdateTime && now.getTime() - lastUpdateTime.getTime() < 15000){
        console.log("Ignoring position update");
        return;
    }
    lastUpdateTime = now;
   if (location.coords.latitude!=$("body").data("mapcenterlat") || location.coords.longitude!=$("body").data("mapcenterlong"))
      {
      $("body").data("mapcenterlat", location.coords.latitude);
      $("body").data("mapcenterlong", location.coords.longitude);
      map.removeLayer(circle);
      circle = L.circle([$("body").data("mapcenterlat"), $("body").data("mapcenterlong")],40*5, {
      color: 'green',
      fillColor: '#0f0',
      fillOpacity: 0.1
      }).addTo(map);
      map.setView(new L.LatLng($("body").data("mapcenterlat"), $("body").data("mapcenterlong")), $("body").data("mapzoom"));
      if (window.ga) ga('send', 'event', 'geolocation', 'latlong', $("body").data("mapcenterlat")+","+$("body").data("mapcenterlong"));
      savegeolocation();
      }
}

See also: https://stackoverflow.com/questions/35294154/cordova-geolocation-watchposition-frequency-is-higher-than-the-options-allow-it/35310256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant