JSFiddle - React, Tailwind, and code Playground
by morrison
HTML
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
JavaScript
function User(id) {
this.id = id;
this.locations = [];
this.getId = function() {
return this.id;
}
this.addLocation = function(latitude, longitude) {
this.locations[this.locations.length] = new google.maps.LatLng(latitude, longitude);
};
this.lastLocation = function() {
return this.locations[this.locations.length - 1];
};
}
function Users() {
this.users = {};
this.generateId = function() {
return Math.random();
};
this.createUser = function() {
var id = this.generateId();
this.users[id] = new User(id);
return this.users[id];
};
this.getUser = function(id) {
return this.users[id];
};
}
var users = new Users();
var user = users.createUser();
user.addLocation(0,0);
user.addLocation(0,1);