Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:05:35+00:00 2026-06-07T10:05:35+00:00

We did some testing at the Apple Store, and we found out our geolocation

  • 0

We did some testing at the Apple Store, and we found out our geolocation code (getting latitude and longitude), is not working for iPhone, iPod Touch, or iPad. I did have to add extra code to get it to work for MacBook / iMac.

Anyone know code to get the latitude / longitude that works for sure on iPod Touch / iPhone / iPad devices?

CODE:

// needed for iPhone / iPad / iTouch
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDrORw0RI-1v-5BixC4T_zLEhcBBwGzyuQ&amp;sensor=true"></script>

// needed for iMac / MacBook
<script src="http://code.google.com/apis/gears/gears_init.js" type="text/javascript"></script>
<script src="http://gaychat.me/js/geo.js" type="text/javascript" ></script>

<script type="text/javascript"><!--
        var ua = navigator.userAgent.toLowerCase();
        var isAndroid = ua.indexOf("android") > -1;
        var isIPhone = ua.indexOf("iphone") > -1;
        var isIPod = ua.indexOf("ipod") > -1;
        var isBlackberry = ua.indexOf("blackberry") > -1;
        var isIPad = ua.indexOf("ipad") > -1;

        if (isIPhone || isIPod || isIPad) {
                function doGeo() {
                        var geolocator = new google.maps.Geocoder();

                        geolocator.geocode({},
                                function(results, status){
                                        var geocoding_url = "geocoding.php?lat=" + results[0].geometry.location.lat() + "&long=" + results[0].geometry.location.lng() + "&email=<?=$brosforbros_email;?>&key=<?=$session_key;?>";

                                        $.ajax({
                                                url: geocoding_url,
                                                success: function(data) {}
                                        });
                                }
                        )

                        /*function geo_success(position) {
                                prev_lat = position.coords.latitude;
                                prev_long = position.coords.longitude;

                                var geocoding_url = "geocoding.php?lat=" + position.coords.latitude + "&long=" + position.coords.longitude + "&email=<?=$brosforbros_email;?>&key=<?=$session_key;?>";

                                $.ajax({
                                        url: geocoding_url,
                                        success: function(data) {}
                                });
                        }

                        function geo_error() {

                        }

                        if (!!navigator.geolocation) {
                                wpid = navigator.geolocation.watchPosition(geo_success, geo_error, {enableHighAccuracy:true, maximumAge:30000, timeout:27000}); 
                        }*/
                }
        } else if (geo_position_js.init()) { // needed for MacBook's / iMac with Safari
                function doGeo() {
                        geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAccuracy:true});

                        function success_callback(p) {
                                geo_lat = p.coords.latitude.toFixed(3);
                                geo_long = p.coords.longitude.toFixed(3);

                                var url = 'geolocation.php?geo_user_id=<?=$user_id;?>&geo_email=<?=$user_email;?>&geo_lat=' + geo_lat + '&geo_long=' + geo_long;

                                $.ajax({
                                        url: url,
                                        context: document.body,
                                        success: function(data) {
                                        // UPDATE GEOLOCATION
                                        }
                                });
                        }

                        function error_callback(p) {
                                alert('error='+p.code);
                        }
                }
        } else {
                var gl;

                function getCookie(name) {
                        var start = document.cookie.indexOf(name + "=");
                        var len = start + name.length + 1;

                        if ((!start) && (name != document.cookie.substring(0, name.length))) {
                                return null;
                        }

                        if (start == -1) return null;

                        var end = document.cookie.indexOf(";", len);

                        if (end == -1) end = document.cookie.length;

                        return unescape(document.cookie.substring(len, end));
                }

                function displayPosition(position) {
                        geo_lat = position.coords.latitude;
                        geo_long = position.coords.longitude;

                        var url = 'geolocation.php?geo_user_id=<?=$user_id;?>&geo_email=<?=$user_email;?>&geo_lat=' + geo_lat + '&geo_long=' + geo_long;

                        $.ajax({
                                url: url,
                                context: document.body,
                                success: function(data) {
                                        // UPDATE GEOLOCATION
                                }
                        }); 
                }

                function displayError(positionError) {
                        //alert("error");
                }

                function doGeo() {
                        try {
                                if (typeof navigator.geolocation === 'undefined'){
                                gl = google.gears.factory.create('beta.geolocation');
                                } else {
                                gl = navigator.geolocation;
                                }
                        } catch(e) {}

                        if (gl) {
                                gl.getCurrentPosition(displayPosition, displayError);
                        } else {
                                //alert("Geolocation services are not supported by your web browser.");
                        }
                }
        }

        doGeo();
    </script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:05:37+00:00Added an answer on June 7, 2026 at 10:05 am

    I wrote that library. If you are really only deploying towards iOS then you can simply use basic javascript and bypass the library altogether:

    navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
    
    function foundLocation(position)
    {
     var lat = position.coords.latitude;
     var long = position.coords.longitude;
     alert('Found location: ' + lat + ', ' + long);
    }
    function noLocation() 
    {
     alert('Could not find location');
     }
    

    The lib helps with some funky behaviour of other platforms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Last evening I did some housekeeping on our code repository - basically moved the
I recently did some performance testing and analysis of an ASP.NET application using out-of-process
I did some testing with floating point calculations to minimize the precision loss. I
Did some searches here & on the 'net and haven't found a good answer
A few years ago, in the Windows environment, I did some testing, by letting
I just did some testing for Int PK join Vs Guid PK. Tables structure
I did some testing with C++ hypot() and Java Math.hypot . They both seem
Does anyone have any thoughts on this method? I have did some performance testing
Did some googling and couldn't find a clear answer on this. My assumption is
Why did some processor manifacturers decide to use Little endian Big endian Middle endian

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.