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.


stevenz

2802 posts

Uber Geek


#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
stevenz

2802 posts

Uber Geek


  #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





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15



Geekzone Live »

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



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.