Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

iPhone - GeoLocation

Options
  • 23-06-2010 3:37pm
    #1
    Registered Users Posts: 8,004 ✭✭✭


    Hi Folks,

    I'm looking for a good way to show a map with the users posiotion highlighted in iPhone. I have limited experience with Java which seems to be the way to call.

    The script I found at the moment is this:
    <script>
    function handler(location) {
    var message = document.getElementById("message");
    message.innerHTML ="<img src='http://maps.google.com/staticmap?center=&quot; + location.coords.latitude + "," + location.coords.longitude + "&size=300x200&maptype=map&zoom=16&key=GoogleAPIKey' />";
    message.innerHTML+="<p>Longitude: " + location.coords.longitude + "</p>";
    message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>";
    message.innerHTML+="<p>Accuracy: " + location.coords.accuracy + "</p>";
    }
    navigator.geolocation.getCurrentPosition(handler);
    </script>

    It works really well. However, is there anyway to take the variables of Longitude and Latitude, and place them in a form field automatically? i.e. To upload your location?

    Thanks,

    ironclaw.


Comments

  • Closed Accounts Posts: 24 zoudards


    That's Javascript not Java ...

    Yes, you can add the location.coords.longitude (or any other var value) to any other HTML element. There you chose to incorporate them to the innerHTML of the element with the id "message". If you have a form element (like an input with type="text"), you can assign anything to its value property. That's the way to go if you want to assign anything to an element of a form.

    http://www.ryerson.ca/JavaScript/lectures/forms/textinput.html , that might help ;), it's quite a broad subject

    Check out w3schools and how the DOM works

    hth
    Zoudards


Advertisement