JSFiddle - React, Tailwind, and code Playground

by chadarsenault

JavaScript

geoloc_class = function() {

};

geoloc_class.prototype.init = function() {
	if(this.supports_geolocation()) {
		this.get_location();
	}
};

geoloc_class.prototype.supports_geolocation = function() {
	if ('geolocation' in navigator === false) {
	    return false;
    } else {
        return true;   
    }
};

geoloc_class.prototype.get_location = function() {
	navigator.geolocation.getCurrentPosition(this.get_position);
};

geoloc_class.prototype.get_position() = function(position) {
	console.log(position.coords.latitude);
};

$(document).ready(function() {
	geoloc = new geoloc_class();
	geoloc.init();
});