Search code examples
javascriptjqueryfirefoxweather-api

simpleweatherjs plugin: Firefox asks me to share my location but wont display current temperature


Hi I have a working weather script from simpleweatherjs I find it weird because from the samples that I found there everything works on diff browser but when I customized the plugin by combining autoupdate and geolocation and with the help from our fellow member here at stack I have manage to make it run but only on chrome because when I tested it at firefox it only asks me if I want to share location after I allowed it nothing happend

Here is the whole code

    <script type="text/javascript">

    $(document).ready(function() {
        getWeather();
        setInterval(getWeather, 6000);
    });

    function getWeather() {

        navigator.geolocation.getCurrentPosition(function(position) {

            var location = (position.coords.latitude + ',' + position.coords.longitude);
            var woeid = undefined;

            $.simpleWeather({
                location: location,
                woeid: woeid,
                unit: 'c',
                success: function(weather) {
                    html = '<h2><i class="icon-'+weather.code+'"></i>' + weather.temp + '&deg;' + weather.units.temp + '</h2>';
                    html += '<ul><li>' + weather.city + ', ' + weather.region + '</li>';
                    html += '<li class="currently">' + weather.currently + '</li></ul>';

                    $("#weather").html(html);
                },
                error: function(error) {
                    $("#weather").html('<p>' + error + '</p>');
                }
            });
        });
    }
</script>

Can someone please tell me where did I go wrong here?


Solution

  • Developer of simpleWeather here. I've had a few people report this issue and several others that don't have any problems. I did a little digging and there seems to be issues with Firefox and geolocation for some people. I found this post from Mozilla Support and several issues here on stackoverflow about the problem. Not sure if that solution solves your problem.