Map of Cities initialized to current position-working sample

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Map of Cities initialized to current position-working sample

Post by BarrySumpter » Wed Apr 18, 2012 10:57 pm

Aren't solutions so simple?
I feel like such a hack.
It took me hours n hours to finally get this to work.

I started with the map of cities sample app contributed by Dixie.

With references to:
how-do-i-use-core-location-in-revmobile
http://lessons.runrev.com/s/lessons/m/4 ... -revmobile
And converted the sample to Android.
Converted app alread posted in this forum somewhere.

Don't know why my previous tests wouldn't work.
It might have something to do with where the resizeStack was placed.
More likely lack of experience.

I've added Melbourne to the alphabetic list of cities.
I've added Current Location to the alphabetic list of cites into the first position.
Ive added Lat Lng text fields to the title bar.

LcNav.html has to be a file.
I tried to have is as a text field
but wouldn't work as the url nor when I saved the text field as a file.
I don't know why.

.
Attachments
LCMaps3Current.zip
(11.35 KiB) Downloaded 387 times
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Map of Cities initialized to current position-working sample

Post by BarrySumpter » Thu Apr 19, 2012 12:36 am

Further research variations on this technique:
developers.google.com/maps/documentation/javascript/examples/
https://developers.google.com/maps/docu ... /examples/

Set Centre as home:
google-developers.appspot.com/maps/documentation/javascript/examples/control-custom-state
https://google-developers.appspot.com/m ... stom-state
I want to
Over lay a pointer on android browser to point to center so I can see the centre position of the map
move map behind to place on exact map position (say specific street corner or park or bike path entrance)
then get lat lng
then send to bike riding buddies to meet me here

Bicycling Layer as well!
google-developers.appspot.com/maps/documentation/javascript/examples/layer-bicycling
https://google-developers.appspot.com/m ... -bicycling

Anything with Directions

Distance Calc!
google-developers.appspot.com/maps/documentation/javascript/examples/distance-matrix
https://google-developers.appspot.com/m ... nce-matrix

places-autocomplete
google-developers.appspot.com/maps/documentation/javascript/examples/places-autocomplete
https://google-developers.appspot.com/m ... tocomplete

and the weather
google-developers.appspot.com/maps/documentation/javascript/examples/layer-weather
https://google-developers.appspot.com/m ... er-weather

OK completely overwhelmed with all the things google offers with google maps. WOW
:mrgreen:

Found something to keep me occupied for the next 6 weeks. LOL
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Map of Cities initialized to current position-working sa

Post by BarrySumpter » Tue Apr 24, 2012 7:11 am

BarrySumpter wrote: ...
LcNav.html has to be a file.
I tried to have is as a text field
but wouldn't work as the url nor when I saved the text field as a file.
I don't know why.

.
The HTML can be a text field.
And does NOT have to be an HTML file.

mobileControlDo id, "load", baseUrl, htmlText
Loads as page consisting of the given htmlText with the given baseUrl (wraps the
loadHtmlString method of UIWebView).

Code: Select all

...
put field txtMyHTMLText into myHTMLText
mobileControlDo sbrowserID, "load", "", myHTMLText
...
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

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

Re: Map of Cities initialized to current position-working sa

Post by LC4iOS » Wed Dec 11, 2013 12:46 pm

Just sharing ...

I stumbled on this looking for a solution to the Compass sample app from RunRev.
I couldn't get it to initialize the GPS.

I don't recall changing anything to it to work in iOS except StandAloneSettings.


I found this technique very interesting and super easy to use.
I've just popped the HTML into a text field so I don't have to keep up why the .html file.

Code: Select all

on showCityChoice cityShowing
   
   -- answer "showCityChoice: " & cityShowing
   
   if cityShowing = 0 then 
      -- answer "cityshowing = 0"
      exit showCityChoice
   end if
   
   
   
   
   
   -- changed theHTMLFile to field txtMyHTMLText
   
   
   
   --   put specialFolderPath("documents") & "/lcNav.html" into thehtmlFile
   
   --   /* change the latitude & longditude in the html file to display the chosen city */
   --   put URL("file:" & thehtmlFile) into theData
   --   put "var myLatlng = new google.maps.LatLng(" & item 2 to 3 of line cityShowing of fld "cityLocations" & ");" into line 16 of theData
   
   --   -- answer theData
   
   --   put theData into URL ("file:" & thehtmlFile)
   
   --   put "file://" & specialFolderPath("documents") & "/lcNav.html" into theURL
   --   replace space with "%20" in theURL
   
   --   mobileControlSet browserID, "url", theURL
   
  
   put field txtMyHTMLText into myHTMLText
   
   put "var myLatlng = new google.maps.LatLng(" & item 2 to 3 of line cityShowing of fld "cityLocations" & ");" into line 16 of myHTMLText
   
   mobileControlDo browserID, "load", "", myHTMLText
   
end showCityChoice

Attachments
LCMaps8Current.livecode.zip
Just change the Standalone Settings back to Android if interested.
(174.69 KiB) Downloaded 304 times
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: Map of Cities initialized to current position-working sa

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

I'm thinking the HTML file is used to store the last requested gps position.
So on next open the map defaults to the last save gps position saved in the HTML file by opening it first thing.
Maybe not.
Can't recall if I update the gps positioning the HTML script before displaying the first time.
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

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

Re: Map of Cities initialized to current position-working sa

Post by Dixie » Tue Jan 21, 2014 1:46 am

LC4IOS...

This is from a stack that I wrote a long time ago, and I think it was with google maps API 2... it looks like people changed it for what they wanted it to do... the HTML file contains the HTML for the google map to place it on screen and so that you can enter the coordinates of the location you wish to view, drop markers and such... google have changed things around a little from a couple of years ago, but the card script still works after a little tweaking for the v3 API...

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

Re: Map of Cities initialized to current position-working sa

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

Hi Dixie,
Thanks for that reply.
That sample project was an excellent example of lateral thinking.
And has heaps n heaps of potential for expansion.
Many thanks.
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

Post Reply