ebook img

Pro iOS Geo: Building Apps with Location Based Services PDF

321 Pages·2013·12.82 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro iOS Geo: Building Apps with Location Based Services

Pro iOS Geo Building Apps with Location Based Services Giacomo Andreucci Pro iOS Geo: Building Apps with Location Based Services Copyright © 2013 by Giacomo Andreucci Portions of this book are inspired by Applicazioni iOS e Android con Google Maps (Edizioni FAG Milano) by Giacomo Andreucci published September 2011. This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN 978-1-4302-4704-3 ISBN 978-1-4302-4705-0(eBook) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. President and Publisher: Paul Manning Lead Editor: Steve Anglin Developmental Editor: James Markham Technical Reviewer: Nishant Prant Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan Ertel, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh Coordinating Editor: Katie Sullivan Copy Editor: Jill Steinberg Compositor: Spi Global Indexer: Spi Global Artist: Spi Global Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. To the awesome rock bands that I have listened to all my life, from U2 to Truffle Shuffle! Contents at a Glance About the Author ...............................................................................................................xiii About the Technical Reviewer ............................................................................................xv Acknowledgments ............................................................................................................xvii Introduction .......................................................................................................................xix (cid:78) Part 1: Introduction ......................................................................................1 (cid:78) Chapter 1: Getting started .................................................................................................3 (cid:78) Part 2: Web Apps ........................................................................................21 (cid:78) Chapter 2: Map-based Web App Basics: Hello World ......................................................23 (cid:78) Chapter 3: Map Controls and Styles ................................................................................43 (cid:78) Chapter 4: Creating a GUI for the App with jQuery Mobile ..............................................77 (cid:78) Chapter 5: Overlays .........................................................................................................95 (cid:78) Chapter 6: Implementing Geolocation ...........................................................................145 (cid:78) Part 3: Hybrid Apps ..................................................................................173 (cid:78) Chapter 7: Creating Hybrid Apps ...................................................................................175 v vi Contents at a Glance (cid:78) Part 4: Native Apps with Apple Map Kit ...................................................201 (cid:78) Chapter 8: Introduction to the Core Location Framework .............................................203 (cid:78) Chapter 9: Introduction to Apple Maps and the Map Kit Framework ............................237 (cid:78) Chapter 10: Displaying Objects on the Map...................................................................261 (cid:78) Appendix A: Understanding the Terms Of Service .........................................................299 Index .................................................................................................................................305 Contents About the Author ...............................................................................................................xiii About the Technical Reviewer ............................................................................................xv Acknowledgments ............................................................................................................xvii Introduction .......................................................................................................................xix (cid:78) Part 1: Introduction ......................................................................................1 (cid:78) Chapter 1: Getting started .................................................................................................3 Comparing Desktop Computer Maps and Mobile Maps ................................................................3 Reviewing Mobile Geo Apps Services ...........................................................................................6 Designing Guidelines for Optimal Usability of Map-Based Apps ...................................................7 Self-Adaptability of the App ...................................................................................................................................9 Usability of the App’s GUI .......................................................................................................................................9 Usability of Map Contents ....................................................................................................................................11 The Primary Options to Develop Map-Based Apps for iOS ..........................................................12 Developing Web Apps with Google Maps .............................................................................................................12 Developing a Native App with Apple Maps ..........................................................................................................15 Testing Map-Based Apps .............................................................................................................17 Testing Methodologies .........................................................................................................................................17 Monitoring Tools ..................................................................................................................................................18 Summary .....................................................................................................................................19 vii viii Contents (cid:78) Part 2: Web Apps ........................................................................................21 (cid:78) Chapter 2: Map-based Web App Basics: Hello World ......................................................23 Reviewing the Resources ............................................................................................................23 Mobile Safari .......................................................................................................................................................23 Simulator or Real Devices ...................................................................................................................................25 Web Servers ........................................................................................................................................................26 Editors .................................................................................................................................................................26 Standalone App or Part of an Existing Website ....................................................................................................27 Hello World ..................................................................................................................................29 Adapting Hello World to iOS Devices ...................................................................................................................37 Redirecting iOS Users with JavaScript ................................................................................................................42 Summary .....................................................................................................................................42 (cid:78) Chapter 3: Map Controls and Styles ................................................................................43 Using Map Controls .....................................................................................................................43 Default Controls ...................................................................................................................................................43 Non-Default Controls ...........................................................................................................................................48 Enabling and Disabling Controls ..........................................................................................................................49 Configuring Controls ............................................................................................................................................52 Positioning Controls .............................................................................................................................................55 Creating Custom Controls on the Map .........................................................................................57 Creating the Container <div> .............................................................................................................................59 Defining the Three Controls .................................................................................................................................59 Methods (and Controls) to Set the MapOptions Object ........................................................................................64 Understanding Selectors and Stylers ..................................................................................................................67 Approach 1: Set a .styles Property of the Map’s MapOptions Object ............................................................71 Approach 2: Create a Styled Map Type ................................................................................................................72 Styled Maps Wizard .............................................................................................................................................74 Some Final Recommendations When Using Styles .....................................................................75 Summary .....................................................................................................................................76 Contents ix (cid:78) Chapter 4: Creating a GUI for the App with jQuery Mobile ..............................................77 What is jQuery Mobile? ...............................................................................................................77 Setting Up the Project .................................................................................................................79 Using a CDN Server .............................................................................................................................................80 Hosting Files ........................................................................................................................................................81 Implementing jQuery Mobile in Our App ......................................................................................81 Creating the Basic Structure of the Template ......................................................................................................82 Adding an Info Button ..........................................................................................................................................86 Showing a Splash Screen While Tiles Are Loading ......................................................................90 Specifying a Launch Image .........................................................................................................92 Complete Code ............................................................................................................................93 Summary .....................................................................................................................................93 (cid:78) Chapter 5: Overlays .........................................................................................................95 General Methods For Manipulating Overlays ..............................................................................97 Adding Overlays to the Map .................................................................................................................................97 Removing and Deleting Overlays From the Map..................................................................................................98 Three Methods to Display POIs On a Map .................................................................................103 Method 1: Using the Marker Constructor..........................................................................................................103 Method 2: Using the KmlLayer Constructor .....................................................................................................121 Method 3: Using the FusionTableslayer Constructor ...................................................................................126 Summary ...................................................................................................................................144 (cid:78) Chapter 6: Implementing Geolocation ...........................................................................145 Understanding Geolocation .......................................................................................................145 The W3C Geolocation API ...................................................................................................................................145 W3C Geolocation API Current Support ...............................................................................................................146 Implementing the W3C Geolocation API ....................................................................................146 The getCurrentPosition() Method .............................................................................................................148 The watchPosition() method .......................................................................................................................154 x Contents Putting Things Together .............................................................................................................157 The HTML File ....................................................................................................................................................158 The CSS File ......................................................................................................................................................163 The JavaScript File ............................................................................................................................................164 Promoting and Maintaining Your App ........................................................................................169 Submitting the App to the App Store .................................................................................................................171 Summary ...................................................................................................................................171 (cid:78) Part 3: Hybrid Apps ..................................................................................173 (cid:78) Chapter 7: Creating Hybrid Apps ...................................................................................175 Creating a Hybrid App With Xcode .............................................................................................175 Creating a Web View (UIWebView) ............................................................................................176 Setting Up the Project ........................................................................................................................................176 Using the Storyboard Tool to Create the Web View ............................................................................................180 Declare the Web View in the Code .....................................................................................................................184 Implementing the Web View ..............................................................................................................................187 Checking for an Internet Connection .........................................................................................189 Open Links in an External App ...................................................................................................191 Adding App Icon and Launch Image for the App Store ..............................................................194 Using PhoneGap ........................................................................................................................198 Geting Started in PhoneGap ...............................................................................................................................198 Summary ...................................................................................................................................199 (cid:78) Part 4: Native Apps with Apple Map Kit ...................................................201 (cid:78) Chapter 8: Introduction to the Core Location Framework .............................................203 Main Core Location Services .....................................................................................................203 Setting Up the Framework ........................................................................................................204 The Standard Location Service .................................................................................................206 Hello World Standard Location Service: One-Shot Position ...............................................................................206 Receiving Location Updates ..............................................................................................................................219 Handling Location Errors ...................................................................................................................................228

Description:
Deepen your app development skills with Pro iOS Geo. This book shows you how to use geolocation-based tools to enhance the iOS apps you develop. Author Giacomo Andreucci describes different ways to integrate geo services, depending on the kind of app you're looking to develop: a web app, a hybrid ap
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.