Hi SparkOut!
Thanks for taking a look. The addMarker handler is doing its job...it is putting the correct values into latitude, longitude, and title (using pPosition and pTitle). Additionally, I changed to "add 1 to tCounter" in "loadSelectedResult" and that did not change the results I am getting.
I continue to think the trouble is in the "getMarkerCode" function, specifically in where the "add 1 to tCounter" and "end repeat" is placed. I changed my database (now "databaseGetMarkerCode") just to make it unique from the other database that gets the address and lat/long in the "loadSelectedResult" handler in the card script. Below is from my google maps api substack.
function getMarkerCode pName
if sMarkers[pName] is empty then
return "error: no such marker."
else
local tMarkerCode, tPlaceJson, tPlaceArray
put databaseGetMarkerCode() into tData ## each line of tData contains the zIndex numerical value. There are 3 lines.
put empty into tLocArray
put 1 into tCounter
set the itemDel to tab
repeat for each line tLine in tData
put item 1 of tLine into tLocArray[tCounter]["zIndex"]
put "var " & pName & " = new google.maps.Marker({" & CR into tMarkerCode
put "icon: '
https://chart.googleapis.com/chart?chst ... tter&chld= " & tLocArray[tCounter]["zIndex"] & "|FE6256|000000|'," & CR after tMarkerCode
put "position: new google.maps.LatLng(" & sMarkers[pName]["pos"] & ")," & CR after tMarkerCode
put "map: map," & CR after tMarkerCode
put "title:'" & sMarkers[pName]["title"] & "'," & CR after tMarkerCode
put "});"& CR after tMarkerCode
put getPlaceByLatLong(sMarkers[pName]["pos"]) into tPlaceJson
put jsonToArray(tPlaceJson) into tPlaceArray
##put tPlaceArray["results"][1]["formatted_address"]
put "(function (marker) {"&CR after tMarkerCode
put "google.maps.event.addListener(marker, 'click', function (e) {"&CR after tMarkerCode
put "infobox.setContent('<div id=" & quote & "infobox" & quote & " >'+'<p>'+" & quote & tPlaceArray["results"][1]["formatted_address"] "e & "+'</p>'+'</div>');" & CR after tMarkerCode
put "infobox.open(map, marker);"&CR after tMarkerCode
put "markCentered(marker.position);"&CR after tMarkerCode
put "});" & CR after tMarkerCode
put "})(" & pName & ");"&CR after tMarkerCode
add 1 to tCounter
end repeat
end if
return tMarkerCode
end getMarkerCode
I currently have 3 records or lines in my database. Depending on where the "add 1 to tCounter" and "end repeat" lines are located, I get 1 of 2 results...
Result A -- only the results from line 1 of the record is being used...therefore tLocArray[1]["zIndex"] appears in all 3 of the markers. OR
Result B -- only the results from line 3 of the record is being used...therefore tLocArray[3]["zIndex"] appears in all 3 of the markers.
I may have to add more "if/then" statements to get it to work.