Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




2784 posts

Uber Geek
+1 received by user: 121


Topic # 29524 10-Jan-2009 15:33
Send private message

I've got a html file with a bit of javascript in it which asks for some GPS coordinates and converts them into standard latitude/longitude, and then opens up googlemaps with the coordinates to show you where it is. This works fine from the iphone, but it'd be a lot tidier if I could get it to feed the results to the built-in Maps application instead of the googlemaps website. Any idea how I could do this from within an html file?

I'm not sure why the GPS uses some sort of different measurement, but it does, and it's a pain. This is so I can take the response from a GPS tracking unit in a car and immediately find out where it is if it goes "missing".

In case anyone is interested, here's the code - I know it's probably not very efficient, and it's ugly, but it does what I need. You can easily take the "conversion" part out of it to get a quick Googlemaps lat/long launcher.


<html lang="en"><head><title>GPS to Google Maps Converter Thing</title>
    <script type="text/javascript">
    function google_maps_url() {
      var div = document.getElementById('url');
      var lon = document.getElementById('longitude').value;
      var lat = document.getElementById('latitude').value;
      var map_lat =((lat/100-lat%100/100) + Math.round(((lat % 100) / 60)*1000000)/1000000);
      var map_lon =((lon/100-lon%100/100) + Math.round(((lon % 100) / 60)*1000000)/1000000);
      div.innerHTML = "<a href=\"http://maps.google.co.nz/?f=q&geocode=&q="+ map_lat +","+ map_lon +"&z=19\">Latitude: "+ map_lat  +", Longitude: "+ map_lon +"</a>";
      return false;
    }
    </script></head><body>
<form id="map" action="" method="post">
GPS Latitude: <input name="latitude" id="latitude" value="-4111.123456" type="text"><br>
GPS Longitude: <input name="longitude" id="longitude" value="17446.456789" type="text"><br>
<input name="commit" value="Convert" onclick="return google_maps_url(this);" type="button">
</form><div id="url"></div></body></html>

Create new topic


2784 posts

Uber Geek
+1 received by user: 121


  Reply # 188603 10-Jan-2009 16:40
Send private message

Gah, typical. If I use "maps.google.com" instead of "maps.google.co.nz" then the iPhone automatically intercepts the link and launches it in Maps.app instead of Safari. Problem solved. Automating it so it launches with the link instead of  necessitating clicking on the link is a different story, apparently:

UIApplication *app = [UIApplication sharedApplication];
[app openURL:[[NSURL alloc] initWithString: @"http://maps.google.com/maps?g=London"]];

Will do the job, but I've no idea how to implement it. This works and it's universal rather than iPhone specific as it stands, so
it's probably the better bet anyway without having to do device detection scripting etc which is way beyond my ken.


Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Geekzone Live »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.