Launching Apple Maps and Google Maps with route directions
In previous recipes, we looked at detecting apps, launching them, and passing data to them in the form of a search query in Apple Maps. Now, let's look at passing something more sophisticated, say a route query. In this recipe, we're going to launch some popular mapping applications via a URL.
How to do it...
Let's go back to the app.js
file in Studio and add some more code. First, we need to add a new label, so add this under your label2
definition:
var label3 = Ti.UI.createLabel({ left: 30, top: 200, text: "Navigate from London to Edinburgh" });
Next, we need to add the label to the window. So, add the next line of code under the code that adds the first two labels:
win.add(label3);
Now, we need to add the code that will launch the route directions. According to the Apple Maps URL scheme, it accepts the saddr
and daddr
parameters to define a start address and an end address. So let's add the...