Launching Maps and Displaying a Location

Moderators: LCNeil, heatherlaine, kevinmiller, elanorb

Post Reply
elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 249
Joined: Fri Feb 24, 2006 9:45 am

Launching Maps and Displaying a Location

Post by elanorb » Thu Mar 27, 2014 12:30 pm

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
Elanor Buchanan
Software Developer
LiveCode

prasun
Posts: 1
Joined: Thu Mar 27, 2014 6:45 pm

Re: Launching Maps and Displaying a Location

Post by prasun » Thu Mar 27, 2014 7:34 pm

Thanks Elanor,

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

Thanks agian.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Launching Maps and Displaying a Location

Post by Simon » Thu Mar 27, 2014 7:44 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Launching Maps and Displaying a Location

Post by Dixie » Thu Mar 27, 2014 8:18 pm

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...

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 249
Joined: Fri Feb 24, 2006 9:45 am

Re: Launching Maps and Displaying a Location

Post by elanorb » Fri Mar 28, 2014 11:38 am

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
Elanor Buchanan
Software Developer
LiveCode

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 785
Joined: Fri Aug 15, 2008 7:15 am

Re: Launching Maps and Displaying a Location

Post by bangkok » Tue Apr 29, 2014 7:45 am

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.
Attachments
GOOGLE MAP2.zip
(1.84 KiB) Downloaded 303 times

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Launching Maps and Displaying a Location

Post by LCNeil » Tue Apr 29, 2014 10:29 am

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 163 times
Kind Regards,


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

Ray Tham
Posts: 3
Joined: Sun Apr 27, 2014 1:17 am

Re: Launching Maps and Displaying a Location

Post by Ray Tham » Wed Apr 30, 2014 1:45 am

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

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 211
Joined: Fri Feb 01, 2013 1:31 am
Location: Palo Alto, CA put williamdjamieso into tEmail / put n@gmail.com after tEmail/ revmail tEmail
Contact:

Re: Launching Maps and Displaying a Location

Post by William Jamieson » Tue Aug 12, 2014 8:55 pm

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!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Launching Maps and Displaying a Location

Post by Simon » Tue Aug 12, 2014 9:32 pm

Hi Will,
We got this working;
http://forums.livecode.com/viewtopic.php?f=53&t=21295

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 211
Joined: Fri Feb 01, 2013 1:31 am
Location: Palo Alto, CA put williamdjamieso into tEmail / put n@gmail.com after tEmail/ revmail tEmail
Contact:

Re: Launching Maps and Displaying a Location

Post by William Jamieson » Fri Aug 15, 2014 12:51 am

Oh awesome! Wow Simon. You are really on top of your game here with Livecode. Another win for you!

Cheers!

Post Reply

Return to “idea2app and Coding School”