JSFiddle - React, Tailwind, and code Playground

by Christian Gambardella

HTML

<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://gambardella.info/jquery.geolocation.js"></script>
<button id="getWeather" type="button">get weather</button>

JavaScript

// ask for location and weather
$('#getWeather').click(function() {

    $.geolocation.find(function(location) {
        console.log(new google.maps.Geocoder());
        
        
        var geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(location.latitude, location.longitude);
    
        geocoder.geocode({'latLng': latlng}, function() {
            if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                    // we found the location
                
                    console.log(results);
                
                } else {
                    // no location found
                    alert("No results found");
                }
            } else {
                // geocoder failed
                alert("Geocoder failed due to: " + status);
            }
        });
    });
    //return false;
    
    
});