Can iPhone web apps get GPS position?

前端 未结 4 1383
情深已故
情深已故 2021-01-30 14:49

Is there an easy way to design a website to facilitate an iphone user providing gps coordinates to the site?

I am wondering if there m

相关标签:
4条回答
  • 2021-01-30 15:28

    I've don this without any programming. You can:

    1. Download the iPhone app "Basic GPS" from iPhone Store.
    2. Start an account at Twitter.com (if you don't already got one).
    3. Start an e-mail-to-twitter account at Twittermail.com.
    4. In Basic GPS settings use your secret e-mail address from Twittermail.
    5. At Twitter.com/widgets click "Other" to get your HTML-code for publishing your Tweets elsewhere.
    6. Put this HTML code on your homepage.
    7. In Basic GPS you just click the blue "I" (on) button, "Email" and "Send" to send your position to Twittermail, which publish it on Twitter. And Twitter will automaticly publish it on your homepage.

    See a working axample at http://CharlieBloom.com. Only the 3 latest (customizeable) Tweets are visible, click on "Follow me on Twitter" to se "My position ....." and a Google Maps-link. Positions are updated on my website 2-3 minutes after I have sent them.

    Best regards, Charlie Bloom

    0 讨论(0)
  • 2021-01-30 15:33

    Here's a snippet on how to read location from the iPhone. Looks like it requires 3.0:

     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');
     }
    

    See: http://mapscripting.com/how-to-use-geolocation-in-mobile-safari

    By the way, if you want to use web code on the iPhone, there are a couple middle-ground solutions you could try that don't force you to create a native app but allow you to wrap your site in an app and get access to GPS and other native features.

    • PhoneGap: http://phonegap.com/
    • Appcelerator: http://www.appcelerator.com/products/titanium-mobile/
    0 讨论(0)
  • 2021-01-30 15:34

    Check out the app SendLocation under navigation by Jouni Erola.

    Its a simply app that will send out the lat & lon of the iPhone to YOUR server. Simply enter your server url to receive the location as HTTP-GET methid

    0 讨论(0)
  • 2021-01-30 15:40

    Yes, but the accuracy is pretty bad. I just built a web form that posts GPS settings from the watchPosition() function to my database and then maped the results. While paddling down a local river it got only two of seven posts correct. The rest were outside the river, and two of those were about a mile away! I'm now looking for a better solution.

    Here's the code I use to update the form fields:

    <script type="text/javascript">
    function getGPSLocation()
    {
      if(navigator.geolocation)
      {
       navigator.geolocation.watchPosition(onGeoSuccess);
      } else {
       alert("Your browser or device doesn't support Geolocation");
      }
    }
    
    function onGeoSuccess(position) {
      document.getElementById("Latitude").value =  position.coords.latitude;
      document.getElementById("Longitude").value = position.coords.longitude;
    }
    </script>
    

    And this is the form. Update to suite your needs.

    <form>
    <img src="spacer.gif" OnLoad="getGPSLocation();">
    <input type="Text" name="Latitude" id="Latitude" value="">
    <input type="Text" name="Longitude" id="Longitude" value="">
    </form>
    
    0 讨论(0)
提交回复
热议问题