Now that we've loaded the Google Maps API successfully, we can implement our data models.
By now, you should be familiar with most of the code that we'll be using to implement our data models, and so we won't include the full code listing. You can get the full code by downloading the code package for the book or viewing the online GitHub repository.
The Place
object is defined in www/js/app/models/place.js
. Most of the code is mundane, the majority of it deals with creating the various properties as seen in the model graphic. There are a couple of interesting pieces of code, however.
setPosition
is an interesting method:
self.setPosition = function ( position ) { var tempPosition = {}; var properties = [ "latitude", "longitude", "altitude","heading", "speed" ]; var setProperty = function ( property ) { if ( typeof position.coords !== "undefined" ) { if ( typeof position.coords[property] !== "undefined" ) {tempPosition.coords[property...