Google Maps api access possibilities for iphone? (processing javascript without UIWebView)


I want to access some data from Google maps. the only way possible is using JS for that. I'm not trying to access it through a webview.


  • I have point 1 (lat,lng) and point 2 (lat,lng). I want to use Google maps api to determine what the driving distance is between those 2.

So in other words I want to use the Google maps api at server-side.

Now when I try to load the data for that html page (that uses document.write() for parsing the distance) I get the Javascript instead of the Javascript being processed.

Can I in any way let the Javascript process through Objective-C ? PHP?

My ultimate goal is to send a request with post vars with the different points and get my data back in JSON for every distance between 2 points


You need UIWebView to run the JavaScript. Here's way I prefer:

  1. Subclass a UIWebView, and add it to the subview of UIView (so you can control your UI gesture on UIView at the same time)
  2. Ask UIWebView to load your PHP webpage that handles the JavaScript you want to use.
  3. You use stringByEvaluatingJavaScriptFromString: to execute the script in your App.
  4. Finally, sever side PHP webpage can respond your script execution.

There's small sample/project in Google Code does the trick: iphone-google-maps-component, the guy uses a UIWebView to load the custom version Google Maps, and provides a set of Objective-C methods to control the map.

By : digdog

You need to have some container on your server to execute the Javascript in. Just loading the Javascript from a HTTP request does not execute it.

Have you looked at CloudMade's routing APIs. They sound like a better solution for your requirements

<xsl:variable name="nodeList" select="a[b[@type='foo' and @value=1]]"/>

<xsl:for-each select="$nodeList">
    <xsl:value-of select="."/>

This video can help you solving your question :)
By: admin