Google Maps Intents

1,177 views
Skip to first unread message

Lee Tarry

unread,
May 22, 2017, 3:46:49 AM5/22/17
to DroidScript
I would like to use the location sample, to drop a pin on the lon/lat on google maps, would i use intents for this, or is their a better way of doing it?

Dave Smart

unread,
May 22, 2017, 6:13:19 AM5/22/17
to DroidScript
Hi Lee,

If the Google Maps app supports intents like that, then that would be one way of doing it.

The other way would be to uses the Google Maps API and put your own map in a webview in your app.  It's not difficult to do.

Or you could try using the 'leaflet' sample on this forum

Lee Tarry

unread,
May 22, 2017, 6:25:44 AM5/22/17
to DroidScript
Thanks Dave,

I basically want to track a route so i can press start and every second it would drop a pin on tge lat, lng position until i press stop, ill have a look for the leaflet sample.

if not im probably better doing a webview, as i dont know if the intents will allow me to drop multiple pins.


thanks again.

K R

unread,
May 31, 2017, 4:12:00 PM5/31/17
to DroidScript
Have you had any success with this?

Lee Tarry

unread,
May 31, 2017, 4:52:14 PM5/31/17
to DroidScript
Im affraid not, i dont think google maps intents would work with this so, like dave said, the API would be the way to go, but im not very good with APIs yet, its on the list of things i want to learn.

Charles Wilt

unread,
May 31, 2017, 11:04:55 PM5/31/17
to DroidScript
    var packageName = "com.google.android.apps.maps";
    var className = null;
    var action = "android.intent.action.VIEW";
    var uri =  "geo:0,0?q="+temp_lat+","+temp_lon;
    app.SendIntent( packageName, className,action,null,uri);


Lee Tarry

unread,
Jun 1, 2017, 2:38:21 AM6/1/17
to DroidScript
Hi Charles,

I cant figure out what that's doing?

It just sends me to an undefined address in Belgium.

i have tried;
function On Start()
{
loc
= app.CreateLocator(GPS);
loc
.setRate (3);
loc
.Start();
var data = 0;
var temp_lat = data.latitude
var temp_lon = data.longitude
navigateTo
(temp_lat,temp_lon);

function navigateTo()
{

is there something i'm missing?

Charles Wilt

unread,
Jun 1, 2017, 6:49:03 AM6/1/17
to DroidScript
Thats odd as it works fine for me.

Try this...
    var packageName = "com.google.android.apps.maps";
    var className = null;
    var action = "android.intent.action.VIEW";
    var uri =  "geo:0,0?q="+temp_lat+","+temp_lon+'(Coords)';
    app.SendIntent( packageName, className,action,null,uri);


Lee Tarry

unread,
Jun 1, 2017, 8:02:36 AM6/1/17
to DroidScript
it may just be me charles, 
that gets my current location but it doesn't drop pins.
cheers anyway!

K R

unread,
Jun 1, 2017, 3:57:40 PM6/1/17
to DroidScript
I was working on the same type of feature that I managed to slightly accomplish before. I happened to delete the little snippets of code i wrote not too long ago. In the code i managed to get multiple markers at once. However, I did not use any intents, It worked through a webview loading the urls manually to get more than one marker...

K R

unread,
Jun 1, 2017, 4:04:31 PM6/1/17
to DroidScript
You might have to deal with api's to accomplish that goal. in starting you will need to request an api key from google and plug it in to html and load it through a webview verses intents...im only a novice but i had it working at least once.

K R

unread,
Jun 1, 2017, 4:19:07 PM6/1/17
to DroidScript

/////this should get you going a bit..I know its hard to see because of the wrapping..get your api key amd plug it in as the "key" variable along with your variable for "lat"and "lng"...i hope this help at least a little bit...it wont accomplish your live tracking but you may be able to have it frequently update if you log your positions and find a way to pop them back out in that html form..


var key "your api key";////put your api key here


var lat = "";////// push latitude in here
var lng = "";/////// push longitude in here


var html ="<html><head>";
html += "<meta name='viewport' content='initial-scale=1, user-scalable=no'>";
html += "<meta charset='utf-8'>";
html += "<title>Where are we</title>";
html += "<style>html, body { height: 100%; margin: 0; padding: 0; } #map { height: 100%; } </style>";
html += "</head><body><div id='map'></div><script>";
html += "function initMap() {";


html += "var myLatLng = {lat: "+lat+","+"lng:"+lng+"};";
html += "var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: myLatLng });";
html += "var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';";
html += "var marker = new google.maps.Marker({ position: myLatLng, map: map, icon: image,title: 'Hello World!' });}";


html += " </script><script async defer src='https://maps.googleapis.com/maps/api/js?key="+key +"&callback=initMap'>";
html += " </script></body></html>";
web.LoadHtml( html, "file:///Sys/" );

Charles Wilt

unread,
Jun 1, 2017, 10:30:31 PM6/1/17
to DroidScript
Both snippets of code drop pins for me.

Lee Tarry

unread,
Jun 2, 2017, 8:33:10 AM6/2/17
to DroidScript
crazy, ill give it another go.

Charles Wilt

unread,
Jun 3, 2017, 10:04:23 AM6/3/17
to DroidScript
You can only drop a single pin with intents.
Reply all
Reply to author
Forward
0 new messages