Personalization: Accessing Geolocation

Browser Compatibility

The Geolocation API works on the following browser versions and all of their successor editions: Firefox 3.5, Google Chrome, Opera 10.6, Internet Explorer 9.0, and Safari 5.

Setting up the Javascript

Put this javascript into your main.js or inline on page in <script> tags, save, and open your site preview.

Accessing Latitude and Longitude

To test the script above is working, open your browser developer console and type geoFindMe(); and hit return. If the above script was installed correctly, your browser should prompt you for permission to access your location. Allow permission. After allowing permission you should see a popup dialog box with your latitude and longitude.

The success() function shows you how to access the latitude and longitude values from the position object. Write your custom scripts in there and have fun!