Currently working on a weather app implementation within CodePen. The app functions properly when running on localhost, requesting permission to use navigator.geolocation and displaying the weather upon acceptance. However, I've encountered an issue where CodePen does not prompt for permission.
For those interested, here is the link:
http://codepen.io/asamolion/pen/BzWLVe
Provided below is the JavaScript function:
function getWeather() {
'use strict';
$('#getWeatherButton').hide();
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var url = 'http://api.openweathermap.org/data/2.5/weather?APPID=53ac88144e6ee627ad0ed85277545ff9';
//var url = 'example.js';
var apiCall = url + '&lat=' + position.coords.latitude + '&lon=' + position.coords.longitude;
//window.location.href = apiCall;
$.getJSON(apiCall, function (json) {
setSkycon(parseInt(json.weather[0].id, 10));
$('#location').html(json.name + ', ' + json.sys.country);
var temp = (Math.round((json.main.temp - 273.15) * 100) / 100);
$('#temp').html(temp + '<span id="degree">°</span><span id="FC" onclick="convert()">C</span>');
$('#condition').html(json.weather[0].main);
});
});
}
};
Any insights on why CodePen fails to prompt for permission would be greatly appreciated!