- Written by: ilmarkerm
- Category: Blog entry
- Published: October 20, 2010
There is an interesting W3C Draft, that enables websites to just simply ask web browser to report the users geographical location, and then the web browser will try the best available location method, like GeoIP, WIFI location or GPS. I have currently tested it on Firefox 3.6 and Google Chrome; Internet Explorer 8.0 does not support it yet.
W3C Geolocation API Draft
Mozilla documentation for Geolocation
How to use it in APEX?
If you are just interested in recording the users location, then using an on-demand application process should be the easiest solution:
First, create two application items: USER_LOC_LATITUDE and USER_LOC_LONGITUDE. They are used for storing users location.
Then, create an On Demand application process SAVE_USER_LOCATION. Create your necessary application logic in that process to handle the user location. The user location is available through application items USER_LOC_LATITUDE and USER_LOC_LONGITUDE.
To continuously monitor user position, use the function navigator.geolocation.watchPosition instead of navigator.geolocation.getCurrentPosition.
Resolving coordinates to location name
Here is one package, that uses GeoNames.org database for resolving the location name. The package requires Oracle 11.2.
The geolocation package
One helper package, HTTP_UTIL, for downloading XML over HTTP