Thursday 4 May 2017

Google Maps Geolocation not working on mobile Heroku app

I'm building an express app that I've deployed through heroku and I'm trying to allow users to "check-in" to a location using the Google Maps geolocation feature. Upon finding the geolocation, I send a request to my server that stores the check-in in a database.

It works on Chrome on my desktop both locally and on the deployed heroku site, but when I try it on chrome mobile it doesn't get the geolocation, it just hangs.

if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
            };

            infoWindow.setPosition(pos);
            infoWindow.setContent('Location found.');
            infoWindow.open(map);
            map.setCenter(pos);
            var url = window.location.toString().substring(0, window.location.toString().indexOf('eventCheckIn')) + 'validateCheckIn?userId='+ '' + '&eventId=' + '';
            $.get(url, function(response) {
              $('#info').hide();
              $('#success').show();
            });
          }, function() {
            handleLocationError(true, infoWindow, map.getCenter());
          });

Any ideas would be very much appreciated! Full Source code



via rubinca

No comments:

Post a Comment