How do I Access Maps on iOS?

This lesson describes how to use the launch url command to access Google Maps. Reference on how to use native controls for accessing Google Maps are also provided.

Introduction

Accessing maps on a mobile device can be pretty useful, especially if you are out and about or you find yourself lost in an unknown location. You can provide access to Google Maps from LiveCode, using launch url or native controls.

Native controls allow you to access web pages from within your LiveCode application. An implementation of this is covered in lesson: How do I use the Browser Control?. You can easily update this lesson to embed access to Google Maps. Try entering URL: http://maps.google.com into the text field and navigate around Google Maps.

If you do not want to embed the display of maps in your LiveCode application but would prefer to launch maps in a separate application that is installed on your mobile device, then you can use the launch url command. This command attempts to open the specified URL using an application that is already installed on the device. If an appropriate application is found, then the URL to be launched is passed to the application and your LiveCode application is exited. If no suitable application can be found, then a message is sent back to the LiveCode application, allowing you to handle the failed request.

Creating the Launch Button

Creating the Launch Button

Launching a web page or Google Maps from within LiveCode requires only a very few lines of code:

on mouseUp

launch url "http://maps.google.com"

if the result is "no association" then

answer "An application could not be launched for the requested url." with "Okay"

end if

// there is no need to continue here

// a successful launch would terminate the LiveCode application

end mouseUp

For demonstration purposes, this code is located in a button, as is shown in the figure of this step. If launch url was not able to resolve the URL request, the LiveCode application will raise a dialogue box indicating that the launch request failed. In this example, launch url is passing a valid URL, which should launch the web browser application on the mobile device.

Launching Google Maps

Launching Google Maps

All that remains is to select the button, created under the previous step, and navigate around Google Maps. The figure in this steps shows a view of Taiwan.

2 Comments

Moon

How can we configure the current location. that is mean if I click on the current location buttons it will give me a current location with the map.. is there any tutorials ?

Elanor Buchanan

Hi Moon

Have a look at this lesson on getting the location and using the digital compass.

https://runrev.screenstepslive.com/admin/lessons/30379

I hope that helps.

Kind regards

Elanor

Add your comment

E-Mail me when someone replies to this comment