How to have newly created database read into code
Posted: Tue Mar 08, 2016 1:48 am
Hello all! Any help with this would be greatly appreciated.
I created a database in my stack script, using DB Browser for SQLite, and I need the table to be read by the code in the substack where I have the google Maps API. The first column of the table is "Location name", the next 2 columns are the longitude & latitude , and the final column is the zIndex. I have the global variables "gDatabaseID" and "gLocationList". I query the database and put the result into gLocationList.
function databaseGetLocations
put revDataFromQuery(tab,return,gDatabaseID,tCreateListSQL) into gLocationList
return gLocationList
end databaseGetLocations
In my substack for the google Maps API, I use the command "updateCard" to put gLocationList into sLocations. The code in the google maps api substack is below:
function getMarkerCode pName
if sMarkers[pName] is empty then
return "error: no such marker."
else
local tMarkerCode, tPlaceJson, tPlaceArray
--put "for (var i = 0; i < locations.length; i++) {"
--put "var myLatLng = new google.maps.LatLng(sLocations[1], sLocations[2]),"; ## when I use this code, I don't get any results
put "var " & pName & " = new google.maps.Marker({" & return into tMarkerCode
put "icon: 'https://chart.googleapis.com/chart?chst ... tter&chld=' + i + '|FE6256|000000|'," & return after tMarkerCode ## want zIndex # to show in Marker
put "position: new google.maps.LatLng(" & sMarkers[pName]["pos"] & ")," & return after tMarkerCode
--put "position: myLatLng," & return after tMarkerCode ## would like for the position to be read from "myLatLng" instead of from position code on live above
put "map: map," & return after tMarkerCode
--put "title: sLocation[0]," & "'" & return after tMarkerCode ## would like this to come from database table
put "title:'" & sMarkers[pName]["title"] & "'," & return after tMarkerCode
--put "zIndex: sLocations[3]," & return after tMarkerCode ## would like this to come from database table
put "});"& return after tMarkerCode
put getPlaceByLatLong(sMarkers[pName]["pos"]) into tPlaceJson
put jsonToArray(tPlaceJson) into tPlaceArray
##put tPlaceArray["results"][1]["formatted_address"]
put "(function (marker) {"&return after tMarkerCode
put "google.maps.event.addListener(marker, 'click', function (e) {"&return after tMarkerCode
put "infobox.setContent('<div id=" & quote & "infobox" & quote & " >'+'<p>'+" & quote & tPlaceArray["results"][1]["formatted_address"] "e & "+'</p>'+'</div>');" & return after tMarkerCode
put "infobox.open(map, marker);"&return after tMarkerCode
put "markCentered(marker.position);"&return after tMarkerCode
put "});" & return after tMarkerCode
put "})(" & pName & ");"&return after tMarkerCode
return tMarkerCode
end if
end getMarkerCode
The goal is to only have to update the database tables so that the results flow automatically into tMarkerCode, and for the markers to have distinct labels (e.g. 1, 2, 3, etc.). Also want the titles and positions to come from whats in the database tables.
I created a database in my stack script, using DB Browser for SQLite, and I need the table to be read by the code in the substack where I have the google Maps API. The first column of the table is "Location name", the next 2 columns are the longitude & latitude , and the final column is the zIndex. I have the global variables "gDatabaseID" and "gLocationList". I query the database and put the result into gLocationList.
function databaseGetLocations
put revDataFromQuery(tab,return,gDatabaseID,tCreateListSQL) into gLocationList
return gLocationList
end databaseGetLocations
In my substack for the google Maps API, I use the command "updateCard" to put gLocationList into sLocations. The code in the google maps api substack is below:
function getMarkerCode pName
if sMarkers[pName] is empty then
return "error: no such marker."
else
local tMarkerCode, tPlaceJson, tPlaceArray
--put "for (var i = 0; i < locations.length; i++) {"
--put "var myLatLng = new google.maps.LatLng(sLocations[1], sLocations[2]),"; ## when I use this code, I don't get any results
put "var " & pName & " = new google.maps.Marker({" & return into tMarkerCode
put "icon: 'https://chart.googleapis.com/chart?chst ... tter&chld=' + i + '|FE6256|000000|'," & return after tMarkerCode ## want zIndex # to show in Marker
put "position: new google.maps.LatLng(" & sMarkers[pName]["pos"] & ")," & return after tMarkerCode
--put "position: myLatLng," & return after tMarkerCode ## would like for the position to be read from "myLatLng" instead of from position code on live above
put "map: map," & return after tMarkerCode
--put "title: sLocation[0]," & "'" & return after tMarkerCode ## would like this to come from database table
put "title:'" & sMarkers[pName]["title"] & "'," & return after tMarkerCode
--put "zIndex: sLocations[3]," & return after tMarkerCode ## would like this to come from database table
put "});"& return after tMarkerCode
put getPlaceByLatLong(sMarkers[pName]["pos"]) into tPlaceJson
put jsonToArray(tPlaceJson) into tPlaceArray
##put tPlaceArray["results"][1]["formatted_address"]
put "(function (marker) {"&return after tMarkerCode
put "google.maps.event.addListener(marker, 'click', function (e) {"&return after tMarkerCode
put "infobox.setContent('<div id=" & quote & "infobox" & quote & " >'+'<p>'+" & quote & tPlaceArray["results"][1]["formatted_address"] "e & "+'</p>'+'</div>');" & return after tMarkerCode
put "infobox.open(map, marker);"&return after tMarkerCode
put "markCentered(marker.position);"&return after tMarkerCode
put "});" & return after tMarkerCode
put "})(" & pName & ");"&return after tMarkerCode
return tMarkerCode
end if
end getMarkerCode
The goal is to only have to update the database tables so that the results flow automatically into tMarkerCode, and for the markers to have distinct labels (e.g. 1, 2, 3, etc.). Also want the titles and positions to come from whats in the database tables.