Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
evanritscher
10,209 PointsImplementing callback in geolocation request
I'm trying to access the browser's location and know that I need to implement a callback function but can't seem to get it right.
What obvious thing am I missing so that I can correctly access the lat and long of the browser?
$(document).ready(function () {
function success(position) {
var userLatitude = position.coords.latitude
var userLongitude = position.coords.longitude
}
function goFind() {
navigator.geoLocation.getCurrentPosition(success, error);
console.log(userLatitude)}
goFind()
});
1 Answer
Chyno Deluxe
16,936 PointsgetCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
-- Console warning on non-HTTPS server.
Geolocation has been deprecated by Google for non HTTPS proxies. If you are not on a server with SSL then that might be the problem.