In a previous article, the Google Gears geo-location technology has been introduced to demonstrate how to retrieve the location from the Internet browser.
I have found the following information from the Apple Web site:
- A PDF document providing information regarding geographic location classes.
IPhone Web application illustration
The WebApp.Net micro framework has been used for this evaluation.
You can call directly the navigator.geolocation.watchPosition function without any initialization…the navigator object is already known by the Safari…
- getCurrentPosition returns the current position in the displayLocation callback.
- watchLocation is used to track the IPhone location. Each time a new location is available, the displayLocation callback is triggered. This method is returning a watchId used to stop the tracking.
- clearWatch is used to stop the tracking started with the watchLocation.
The getCurrentPosition and watchLocation can have up to 3 parameters in input:
- The success location callback is returning a Position object.
I have only checked that longitude, latitude and accuracy was returned, i need to complete the tests for altitude and speed. For the heading (direction) i think that this information is not returned with the current IPhone.
- The error callback is returned in case of error
- The PositionOptions object has 3 parameters
Starting the WebApp
When starting the application for the first time, the Safari browser displays a popup. You need to confirm that you agree to give your location. After multiple uses, the popup does not appear anymore.
In this sample application, the location is displayed in a popup.
The W3C standard API provided with IPhone 3.0 SDK is very easy to use and provides a position through multiple sources (GPS, WIFI, BTS…).
Any Geocoding API is provided by Safari to retrieve an address from this location.
This interesting feature is available with the Google Gears API…
During my evaluation (with the Beta version), the Safari browser was frozen multiple times and i need to restart the mobile…
The application sample will be available in a near future…