Displaying Google Maps (current location) using iPad GPS

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Fri Jan 10, 2014 7:15 am

Hi Guys,

I am quite new to the livecode scene and want to know if this is possible.
I am trying to get the current location of the device (iPad) running the app and display it inside the app using the google maps API.

I already have a working HTML page which shows the current location if you run it inside a browser but it does not want to work inside the livecode app.
I have tried a few other example stacks but with no success.

Here is an example of some of the code in the stack:

global browserID
on mouseUp
put revBrowserOpen (the windowId of this stack, "url here") into browserID
revBrowserSet browserID, "scrollbars", false
revBrowserSet browserID, "showborder", true
revBrowserSet browserID, "rect",rect of image "browserimage"
put mobileCurrentLocation() into tLocation
answer tLocation -- This was to see if I cannot pass on the current co-ords to the html page instead of it relying on the internal sensor, I receive no answer though..
end mouseUp


Thanks

Regards.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Simon » Fri Jan 10, 2014 7:39 am

Hi Kevvy,
Welcome to the forum.

I take it you've seen that mobileCurrentLocation() returns an array with lat and long.
So you just grab them and tag them on the end of the URl.
e.g. http://maps.google.com/maps?q=55.953969,-3.198784

Simon
Edit.. You can't view an array with the answer dialog.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Fri Jan 10, 2014 8:43 am

Thanks Simon :)

I tried the following:

put mobileCurrentLocation() into tLocation
put tLocation['latitude'] into lati
answer "Latitude:" & lati

And it returned blank on my iPad. Do you have to initialise location tracking first somewhere ?

Thanks again for the help.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Simon » Fri Jan 10, 2014 8:49 am

Yes, you have to mobileStartTrackingSensor.

Here:
http://lessons.runrev.com/s/lessons/m/4 ... al-compass
Tons of stuff to read in the Lessons.
You should start with them.

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

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Fri Jan 10, 2014 9:49 am

thanks Simon, I got the tracking working and sending the lat and long on to the google maps page. However for the life of me I cannot get the browser image displaying on my iPad. It displays on my windows box but not on my mac box (both have a connection to the internet and that specific php page which generates the map.

does anyone have any ideas to display an image of a webpage inside an iOS application ? :(

Regards

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Simon » Fri Jan 10, 2014 10:23 am

What happens when put the URL into iPad's Safari?

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

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Fri Jan 10, 2014 11:38 am

Simon wrote:What happens when put the URL into iPad's Safari?

Simon
it opens up fine. i found the browser control tutorial which I am working through to see if i can find a solution.

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Displaying Google Maps (current location) using iPad GPS

Post by LC4iOS » Fri Jan 10, 2014 11:53 pm

Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Mon Jan 20, 2014 1:02 pm

thanks for the replies, I just cant get it working :(

I basically have a rectangle which i want to display the current location via google maps in this rectangle.
I do have a working php page which runs on my web server and displays the current location or location given, but how to let this display live in the rectangle ?

thanks again.


Kevvy.

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Displaying Google Maps (current location) using iPad GPS

Post by LC4iOS » Mon Jan 20, 2014 11:07 pm

I am thinking the rectangle you are referring to should be the live code browser control

have a look at the sample app in the hyperlink I posted immediately above
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Tue Jan 21, 2014 6:08 am

LC4iOS wrote:I am thinking the rectangle you are referring to should be the live code browser control

have a look at the sample app in the hyperlink I posted immediately above
Thanks for the reply, I couldn't use that example as the stack would not open. It says that it is corrupted.

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Displaying Google Maps (current location) using iPad GPS

Post by LC4iOS » Tue Jan 21, 2014 6:47 am

http://ftp.runrev.com/forums/viewtopic. ... 83&p=79766

I'm thinking the mobile objects might not be available in the non-licensed / community versions of LiveCode.

Maybe someone with the 6.5 commercial version of LiveCode would be so kind as to download and try to open.

To test mobile apps on the desktop you have to run it thru the simulator.

To test mobile apps on the device you have to have
1. a licensed version of LiveCode
2. a paid Apple iOS developers membership
3. an incredible amount of patience and time and effort
for stepping thru word by word on step by step procedures
(i've written some recently on this forum)
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Displaying Google Maps (current location) using iPad GPS

Post by LC4iOS » Tue Jan 21, 2014 7:21 am

LCMaps8ForLC6.5

I copied all the controls from my Licensed LC.5.5.5 over to a new MainStack in Livecode 6.5 Community.

Tested opening in LC 6.5 Community without error.
Have not tested any further as I don't have a LiveCode 6.5 Professional license.

See how you go.
Attachments
LCMaps9ForLC6.5.livecode.zip
(4.15 KiB) Downloaded 322 times
Last edited by LC4iOS on Tue Jan 21, 2014 9:25 am, edited 1 time in total.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: Displaying Google Maps (current location) using iPad GPS

Post by Kevvy » Tue Jan 21, 2014 8:23 am

Thanks a mil!!, it is opening on my side now, I will have a look and see if i can get it working on my side.

Post Reply