Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By : Kerri Shotts
Book Image

PhoneGap 3.x Mobile Application Development HOTSHOT

By: Kerri Shotts

Overview of this book

<p>PhoneGap allows you to use your existing knowledge of HTML, CSS, and JavaScript to create useful and exciting mobile applications.<br /><br />This book will present you with 12 exciting projects that will introduce you to the dynamic world of app development in PhoneGap. Starting with their design and following through to their completion, you will develop real-world mobile applications. Each app uses a combination of core PhoneGap technologies, plugins, and various frameworks covering the necessary concepts you can use to create many more great apps for mobile devices.</p>
Table of Contents (21 chapters)
PhoneGap 3.x Mobile Application Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing our data models


Now that we've loaded the Google Maps API successfully, we can implement our data models.

Getting on with it

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...