Page 1 of 1
markers in google maps?
Posted: Wed Dec 12, 2012 11:14 am
by link76
I would like to insert markers in google maps, how to do?
Code: Select all
on mouseUp
--get revBrowserOpen(the windowId of this stack, "http://maps.google.it/maps?near=piazza+duomo+milano&hl=it&t=m&z=13&output=embed")
get revBrowserOpen(the windowId of this stack, "http://maps.google.it/maps?q=milano&hl=it&t=m&z=13&iwloc=near&output=embed")
if it is an integer then
put it into tBrowserId
revBrowserSet tBrowserId, "rect", the rect of image "browser"
revBrowserSet tBrowserId, "showborder","true"
--
else
answer "There was an error: " && it --if the browser doesn't start, show the error.
end if
end mouseUp
thank you
Re: markers in google maps?
Posted: Wed Dec 12, 2012 5:02 pm
by bangkok
But if you need dynamic map (with zoom etc.) then I see only one solution :
-livecode generates the html page with all javascript inside (along with your dynamic data)
-and then open this local file with your browser :
Code: Select all
launch url "file:"&tPath&"/map.html"
Re: markers in google maps?
Posted: Thu Dec 13, 2012 8:25 am
by link76
bangkok wrote:
But if you need dynamic map (with zoom etc.) then I see only one solution :
-livecode generates the html page with all javascript inside (along with your dynamic data)
-and then open this local file with your browser :
Code: Select all
launch url "file:"&tPath&"/map.html"
how to create html page with live code ?
Re: markers in google maps?
Posted: Thu Dec 13, 2012 9:29 am
by bangkok
link76 wrote:
how to create html page with live code ?
It's very easy.
-take a standard html page (with javascript) that manages the creation of a google map and the creation of markers
-remove the variable parts, replaced them with special "tags"
-then in LiveCode your script will "fill in" this script with data (by replacing the tags)
-save the file and initiate the command launch
Here is the "core" html page i use. You'll notice the 2 tags [DATA1] [DATA2]
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PC Pro - Google Maps Simple Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
$(document).ready(function () {
// Define the latitude and longitude positions
[DATA1]
// Set up options for the Google map
var myOptions = {
zoom: 6,
center: latlngPos1,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Define the map
map = new google.maps.Map(document.getElementById("map"), myOptions);
// Add the marker
[DATA2]
});
</script>
</head>
<body>
<div id="map" style="width:800px;height:800px;margin-top:10px;"></div>
</body>
</html>
And here my script :
Code: Select all
put fld "coreScript" into lamorce
put empty into lesData1
put empty into lesData2
set itemdelimiter to tab
--- here my data, name of the marker and geocode of the marker, one per line
repeat with i = 1 to the number of lines of aTraiter
put item 1 of line i of atraiter into leNom
put item 2 of line i of atraiter into lesCoordonnees
put "var latlngPos"&i&" = new google.maps.LatLng("&lesCoordonnees&");"&cr after lesData1
put "var marker = new google.maps.Marker({"&cr after lesData2
put "position: latlngPos"&i&","&cr after lesData2
put " map: map,"&cr after lesData2
put "title: ""e&leNom"e&"});"&cr after lesData2
end repeat
---we replace the tags with our data
replace "[DATA1]" with lesData1 in lamorce
replace "[DATA2]" with lesData2 in lamorce
--then save the file as a html file, and launch into browser
put the effective filename of this stack into tPath
set the itemDelimiter to slash
delete last item of tPath
put "file:"&tPath&"/map.html" into myFile
put lamorce into url myFile
launch url "file:"&tPath&"/map.html"
To help you, I attach a html file generated by my script (with 3 markers).
Re: markers in google maps?
Posted: Sat Apr 20, 2013 2:54 pm
by archer2009BUSknbj
I'm looking to embed a Google Map into an App I'm creating for Android - I just downloaded the map.html file and it ran perfectly in my windows 7 web browser
But what I don't know how to do is create a box in LiveCode that displays the map, and also is there a way to make it so if a person clicks on the marker with their finger it takes them to a certain Card in LiveCode
What I want is for the markers to represent people, and when you click on the marker it takes you to that person's profile page which is a Card in LiveCode
I did try working through a lesson I found on the RunRev website that is supposed to display the KickStarter website but it didn't work for me on my windows PC and wouldn't allow me to create an APK File for Android
Re: markers in google maps?
Posted: Thu Jun 20, 2013 1:09 am
by Subas
dear Bangkok.
wanted your advice on this topic. If I have a set of gps position in a text file (long/lat) any idea how can I read this text file in real-time to update Google map based on your example? those log/lat will then put the marks based on this text file.
regards
Re: markers in google maps?
Posted: Thu Jun 20, 2013 7:40 am
by bangkok
Hello,
Good idea to refresh this thread (Google Map API has changed).
So here is a stack to :
-type an address
-get the geocode from google map
-and then create the map (local html with javascript file, sent to your browser)
Re: markers in google maps?
Posted: Sat Jun 22, 2013 7:29 am
by Subas
Dear Bangkok.
Thank you for the stack. I will test it out and request for advice if I am not sure how to use it.
Best regards
Subas
Re: markers in google maps?
Posted: Tue May 06, 2014 3:26 am
by Ray Tham
Hi Bangkok,
Just downloaded your Map.Zip file and tried to run it, its fails to do anything. The Lat & lat fields come up blank and so cannot create a map. Any idea what's happening?
Thanks .. Ray
Re: markers in google maps?
Posted: Tue May 06, 2014 7:02 am
by bangkok
Ray Tham wrote:
Just downloaded your Map.Zip file and tried to run it, its fails to do anything. The Lat & lat fields come up blank and so cannot create a map. Any idea what's happening?
Download the new version here (posted on april 29) :
http://forums.runrev.com/download/file.php?id=3548
http://forums.runrev.com/viewtopic.php? ... 74#p102422
Re: markers in google maps?
Posted: Wed Sep 24, 2014 2:41 am
by genie
Hello Bangkok,
Thank you for the stack. One question... how to I handle when a marker in the HTML is clicked? Is it possible that the stack goes to another card when a particular marker is clicked?
Thanks,
Genie