Page 1 of 1

Launching Maps and Displaying a Location

Posted: Thu Mar 27, 2014 12:30 pm
by elanorb
Hi everyone

This question came up yesterday in the Webinar, we will be looking at this topic more in the next lesson, Location Services, but in the meantime here is a code snippet.

If you have a latitude and longitude, perhaps pulled from a database, you can use the following code which will launch google maps or display the map in a browser.

Code: Select all

on mouseUp
   put "55.953969" into tLatitude
   put "-3.198784" into tLongitude
   
   ## Construct the URL
   put "http://maps.google.com/maps?q=" & tLatitude & comma & tLongitude into tURL
   launch url tURL
end mouseUp
For more see the lesson How do I Access Maps on iOS?. This will also work on Android.

I hope that helps.

Kind regards

Elanor

Re: Launching Maps and Displaying a Location

Posted: Thu Mar 27, 2014 7:34 pm
by prasun
Thanks Elanor,

I am also interested in knowing how to display a list of locations ( long. Lat. ) on a map simultaneously.

Thanks agian.

Re: Launching Maps and Displaying a Location

Posted: Thu Mar 27, 2014 7:44 pm
by Simon
Hi prasun,
Welcome to the forum!

I think you are going to have to explain a bit more what you'd like because:

Code: Select all

   put "55.953969" into tLatitude
   put "-3.198784" into tLongitude
Is the lat/long.

Maybe you are asking about how to use fields?

Code: Select all

   put "55.953969" into field "lat"
   put "-3.198784" into field "long"
Just add those 2 fields to the card.

Simon

Re: Launching Maps and Displaying a Location

Posted: Thu Mar 27, 2014 8:18 pm
by Dixie
Prasun...

On which platform are you wanting to display maps ?... If it is the desktop, Mac OSX, Windows, then you will have to use 'google maps. It is not complicated to display them using revBrowser... again 'google maps' is your only choice if you want to display on Android, but on iOS you could use mergMK (monte goulding's external) to display 'apple's' map offering...

Re: Launching Maps and Displaying a Location

Posted: Fri Mar 28, 2014 11:38 am
by elanorb
Hi

I don't think there is a way to display multiple locations on a single, dynamic map by building a URL, not as far as I can find right now.

There are a couple of ways you can do it.

1. Using static maps, this just display a map as an image so you can't scroll, zoom etc but you can see multiple locations. See this StackOverflow post.

2. Create a map and then use the URL that points to the created map. This is a dynamic map but you do have to create it in advance.
See this article.

There is a Google Maps API which you can investigate.

For iOS there is an MergMK external available from MergEXT which provides a lot of functionality for using Google Maps.

For additional information on using browsers on Desktop and Mobile see these lessons.

How do I display a PDF in Rev?
How do I use the Browser Control?

I hope that helps.

Kind regards

Elanor

Re: Launching Maps and Displaying a Location

Posted: Tue Apr 29, 2014 7:45 am
by bangkok
Someone asked me to give more details about the solution to display several markers on a google map.

Here is a stack that will help.

Re: Launching Maps and Displaying a Location

Posted: Tue Apr 29, 2014 10:29 am
by LCNeil
Hi All,

Thats an awesome stack bangkok, thank for posting it.

Another LiveCode user (John) got in touch with us via support with some stacks that explain how to embed a Google map directly in your LiveCode stack(both desktop and iOS), instead of having to launch a browser. This might go hand-in-hand with what Bangkok shared.

Please find this stack attached below-
googleMapOSXiOS.zip
(5.06 KiB) Downloaded 320 times
Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Launching Maps and Displaying a Location

Posted: Wed Apr 30, 2014 1:45 am
by Ray Tham
Hi Bangkok,

Thanks for your Google Map2 which puts multiple locations containing:title, lat, lng data into a Google Map.

Can LiveCode be programmed to do additional Google Maps stuff such as:

(a) Enhance the title (ie. so that we can add the name of a retailer and/or address, which will include spaces in the text)
(b) An Info attribute to allow textual data to be added to each (ie. vehicle traffic flow and/or pedestrian flow)
(c) Make a marker clickable so that it changes color to indicate it is the Designated Marker (DM), then:
(1) Perform minor calculations to compute the distance of other markers that are less than or equal to 5km from the DM.
I have worked out the formulae for calculating the 5km square block around the DM, in which the remaining markers
must be tested against
(2) Change the color of the markers that lie within the square block around the DM to DARK GREEN
(3) Plot the square with the DM as center, the square will have each side 10km in length, make the square color LIGHT GREEN and OPAQUE

Should this be done in JavaScript and using Google Maps JavaScript API 3? Am I expecting too much from LiveCode?

Thanks

Ray

Re: Launching Maps and Displaying a Location

Posted: Tue Aug 12, 2014 8:55 pm
by William Jamieson
Hello.

I tried deploying the googleMapOSXiOS.zip stack to my Android phone and the result came up a map browser with map controls, but with a blank white page for a map. I could scroll, I could zoom, but I was not able to see anything. Do you think this is because the stack was made for iOS? By looking at the script, it did not look like there was anything that was iOS dependent (mobileControlCreate).

Any suggestions please let me know.

Thank you!

Re: Launching Maps and Displaying a Location

Posted: Tue Aug 12, 2014 9:32 pm
by Simon
Hi Will,
We got this working;
http://forums.livecode.com/viewtopic.php?f=53&t=21295

Simon

Re: Launching Maps and Displaying a Location

Posted: Fri Aug 15, 2014 12:51 am
by William Jamieson
Oh awesome! Wow Simon. You are really on top of your game here with Livecode. Another win for you!

Cheers!