Maps question

how can I trace the path between two points?

I search in API and I don’t found anything like that to use

someone knows anything about it?
thanks [import]uid: 23063 topic_id: 17147 reply_id: 317147[/import]

please, someone knows if thhis is possible? [import]uid: 23063 topic_id: 17147 reply_id: 64667[/import]

no one knows? [import]uid: 23063 topic_id: 17147 reply_id: 65179[/import]

I don’t think its possible with the current API. A workaround could be to use a Web View with your local html file containing a google map.

see documentation here on how to embed google maps for mobile apps:
http://code.google.com/apis/maps/documentation/javascript/
And here for how to use polylines (which are a type of overlay in the Google maps API) on the map:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Polylines

Hope this helps [import]uid: 33608 topic_id: 17147 reply_id: 65183[/import]

@amirfl7

thank you dude, I will check this links
Dhennrich [import]uid: 23063 topic_id: 17147 reply_id: 65186[/import]

can you tell me how you sent your lat, log to your webSite to change and mark the map?

thanks [import]uid: 23063 topic_id: 17147 reply_id: 65314[/import]

if you want to mark a specific lat long location use the code described here:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Markers
to find the user’s current location use w3c geo location as described on the same webpage:
http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation

You don’t have to work with an online website, the html file you create with the google map implementation can be placed in your resources directory (where you store main.lua) and bundled with the app. (however, the user has to be online anyway for the maps to load) [import]uid: 33608 topic_id: 17147 reply_id: 65318[/import]

great!
and another thnig… i seen in code that you need to set the lat. lot to make the lines

it can’t be done automatically? [import]uid: 23063 topic_id: 17147 reply_id: 65319[/import]

What do you mean automatically? You have to tell the api where you want the lines to start and end. [import]uid: 33608 topic_id: 17147 reply_id: 65322[/import]

I thought that this was to determine the lines in the map:

var flightPlanCoordinates = [  
 new google.maps.LatLng(37.772323, -122.214897),  
 new google.maps.LatLng(21.291982, -157.821856),  
 new google.maps.LatLng(-18.142599, 178.431),  
 new google.maps.LatLng(-27.46758, 153.027892)  
 ];  

http://code.google.com/intl/pt-BR/apis/maps/documentation/javascript/overlays.html#Polylines

but if I only need to determine the start point and end point, it’s great!

realy man… you save my day

THANK YOU [import]uid: 23063 topic_id: 17147 reply_id: 65323[/import]

Glad i could help,
Cheers [import]uid: 33608 topic_id: 17147 reply_id: 65325[/import]

Amirfl7, I was also wondering how to do this so thsnks for those responses! With this setup, you then have code in both lua and in javascript (within the html file). Would you know how the two different sets of code could send events to each other?

For example, within the lua code, I may want to change the center position of the map so I would want the lua part to send an event to the javascript part so that the map changed its center position.

Would you know if this is possible or does all the functionality now have to get coded into the javascript part?

Thanks
Eric [import]uid: 29384 topic_id: 17147 reply_id: 65797[/import]

You can try to send messages to your html page from the target URL with GET variables (such as: myMap.html?lat=37.2&long=-120.0), but I don’t think you can update the map from the lua code without reloading the webview.
[import]uid: 33608 topic_id: 17147 reply_id: 65863[/import]

Thanks, Amirfl7. I was afraid that would be the answer. Having to reload the webview each time would look horrible. [import]uid: 29384 topic_id: 17147 reply_id: 66095[/import]

You might be able to do it all through the javascript/html side of the program, depending on what exactly you are trying to accomplish. [import]uid: 33608 topic_id: 17147 reply_id: 66098[/import]

Yes, but then I’m not really using Corona… I actually already have a Corona app on iPhone which makes use of the maps API. Someone approached me to do a very similar app for Android. “Easy!” I thought until I realised that the maps API is for iOS only and not for Android.

So I’m looking for alternative ways of displaying and controlling a map. I basically want to be able to have a map displayed then for the lua code to be able to change the center point and the zoom level of the map.

I might have to say no to the project which would be sad as it would be $$$. :frowning:

Of course, if Ansca were to decide to support (Google) maps on (Google) Android in the next week or two, then that would be great!

Actually, if there was a way to control the javascript from lua, that would be even better since I would be able to overlay a polyline on top of the map, which the current maps API doesn’t allow. [import]uid: 29384 topic_id: 17147 reply_id: 66115[/import]

EDIT: nevermind [import]uid: 23063 topic_id: 17147 reply_id: 66125[/import]

question:

I can’t make it works

  
  
[html]  
  
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">  
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<title>Google Maps JavaScript API v3 Example: Polyline Simple</title>
  
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css">
  
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>  
<script type="text/javascript"><br><br> function initialize() {<br> var myLatLng = new google.maps.LatLng(-29.861041,-50.083237);<br> var myOptions = {<br> zoom: 10,<br> center: myLatLng,<br> mapTypeId: google.maps.MapTypeId.TERRAIN<br> };<br><br> var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);<br><br> var flightPlanCoordinates = [<br> new google.maps.LatLng(-29.87228,-50.139885),<br> new google.maps.LatLng(-29.861041,-50.083237)<br>];<br> var flightPath = new google.maps.Polyline({<br> path: flightPlanCoordinates,<br> strokeColor: "#FF0000",<br> strokeOpacity: 1.0,<br> strokeWeight: 2<br> });<br><br> flightPath.setMap(map);<br> }<br></script>  
  
  

  
  
  
[/html]  
  

the polyline don’t respect the road
so how can I use this polylines to trace the path between 2 points? I only get an straight [import]uid: 23063 topic_id: 17147 reply_id: 66144[/import]

I tried to run your code on my browser (firefox), and initially it didn’t work at all, I found that the script address was wrong. try to use:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>  

instead of:

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>  

As for tracking a road, It’s a whole different problem. You may have to use the directions API. I’m not very familiar with it, but maybe this can help:
http://code.google.com/apis/maps/documentation/javascript/services.html#RenderingDirections
[import]uid: 33608 topic_id: 17147 reply_id: 66159[/import]

Thank you again, maybe this http://code.google.com/intl/pt-BR/apis/maps/documentation/javascript/examples/directions-panel.html can help me

now I just need to put current user location into this code to make it work

I tried to add current user locate before but didn’t work =(
anyway, Thanks again [import]uid: 23063 topic_id: 17147 reply_id: 66163[/import]