I’ve covered basic examples of using Google Maps and Geolocation using HTML5 and JavaScript, but if you’re looking for advanced knowledge, the Instant HTML5 Geolocation How-to eBook is for you. This 60-page book by Ben Werdmuller covers real-world examples of using Geolocation in your website or application, and includes sample code to help you get started.
The source code is the book isn’t the easiest to read, but luckily you can download the complete source code from the publisher’s website. Note that some of the PHP code covered in the book is also outdated, which is a little disappointing. For example, the sample code uses the old (and now depreciated as of PHP v5.5) MySQL extension, instead of the far superior MySQLi extension.
It would have been useful if line numbers were included in the source code, so you can easily see which lines were wrapping. When copying out the JavaScript code, this could be a nuisance as errors will be thrown by the browser if extra line-breaks are found in the code. I’m a seasoned PHP developer, but even I had trouble reading some of the source code thanks to the excessive use of indentation and lack of line numbers.
The eBook has a great example of tracking the user’s location in realtime, and the author gives clear indications of the limitations of using a web-based approach for geolocation. The author has also done a good job of laying out the book in a consistent way, with each section clearly titled. The only oddity I noticed was that the book has Chapters in the content page, but there is only one chapter in the book!
Overview of the eBook:
- Understanding the Geolocation API (Simple)
- Setting up the application (Simple)
- Getting the user’s location (Intermediate)
- Displaying the user’s location using the Google Maps API (Intermediate)
- Displaying the user’s location using a KML feed (Intermediate)
- Tracking and updating the user’s location (Intermediate)
It’s handy having a eBook to reference when creating geolocation apps, but it’s quite a steep price for something that can also be found in the public domain. Googling for source code to copy-and-paste will certainly save you time, but this eBook does provide valuable information about geolocation, use of APIs and other background information.
If you’re interested, you can purchase the eBook from Packt Publishing – at time of writing, the eBook is available for a discounted price of £6.79 and available in a range of formats, including epub and PDF. I’ve uploaded the ePub version to my Google Play account so I can reference it on my Nexus 7 tablet using Play Books. I can also read it online via Google Play.