Wednesday, 6 April 2016

Is it possible to test navigator.geoLocation working on localhost?

Hey peeps,Okay, so, I'm building a MEAN app that uses the GoogleMaps API, and I'd like to make use of HTML5's geolocation to open the map at the right location initially.I was just wondering if anyone has been able to test this locally at all? I can't seem to get it to run...var location; //attempt to get user's geoLocation if(navigator.geoLocation) navigator.geoLocation.getCurrentPosition(locationSuccess, locationFail); else locationFail(); //if geoLocation was enabled function locationSuccess(position){ location = { lat : position.coords.latitude, lng : position.coords.longitude }; } //geo location not enabled / failed / just use dummy data for testing function locationFail(){ location = { lat : 51.5135, lng : -0.0937 } } Any help here would be awesome.Thanks, peeps!-P

Submitted April 06, 2016 at 07:24PM by pookage

No comments:

Post a Comment