Google Maps API - click marker and pass info to Livecode
Posted: Wed May 25, 2016 8:14 pm
I posted this in the beginners forum and have had 50 views and no replies. Can anyone here help? I'm trying to urgently resolve this for a student and I'm at a loss.
I have a Google map with markers in a browser object in an iOS app and I want to be able to click on the markers and have them pass their marker title to Livecode.
I dynamically create markers in a repeat loop from Livecode:
I have this following Javascript function in the HTML page used to create a marker on the Google Map:
So when I click on a marker I am opening an alert window showing the title of the marker. Great - but how can I pass this marker title back to Livecode, to use eg. to display an image related to the marker?
I'm not sure to how to actually do this (possible?) or how to ask Google. Any help in this really appreciated. Thanks.
Kind regards, Paul.
I have a Google map with markers in a browser object in an iOS app and I want to be able to click on the markers and have them pass their marker title to Livecode.
I dynamically create markers in a repeat loop from Livecode:
Code: Select all
put specialFolderPath("engine") & "/billboards.csv" into pathToFile
put url ("file:" & pathToFile) into tContents
put 1 into i
repeat for each line tLine in tContents
put item 14 of tLine into lat
put item 13 of tLine into lng
put item 18 of tLine into titleName
// Call Javascript function within the loaded map HTML page
MobileControlDo browserID, "execute", ("setMarkerAt(" && lat & "," & lng & "," & i & ")")
add 1 to i
end repeat
Code: Select all
function setMarkerAt(lat, lng, i){
var markerPos=new google.maps.LatLng(lat, lng);
var titleName = i.toString() //i is just an index number to identify markers when clicked using marker.getTitle()
var marker=new google.maps.Marker({
position:markerPos,
map:map,
title:titleName
});
marker.setMap(map);
marker.addListener('click', function() {
window.alert(marker.getTitle());
});
}
I'm not sure to how to actually do this (possible?) or how to ask Google. Any help in this really appreciated. Thanks.
Kind regards, Paul.