google maps - Cannot read property 'Query' of undefined -
in code snippet `
1) function gvizselect(tableid) { 2) var uri = "select geometry " + tableid + " name = 10095"; 3) var querytext = "http://www.google.com/fusiontables/gvizdata?tq=" + encodeuricomponent(uri); 4) var query = new google.visualization.query(querytext); 5) query.send(getdata); 6) }
`
i have confirmed querytext url produce proper response set when browsed directly; line 4 generating following error; "uncaught typeerror: cannot read property 'query' of undefined."
here complete html file demonstrates error receiving
<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>indianatrails.com</title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type=text/javascript> google.load('visualization', '1', { 'packages':['corechart', 'table', 'geomap'] } ); var tableid = '1zxsfevzwvm_pute8q5thfwmyr0ncgqzbsdcvqds'; var uri = "select geometry " + tableid + " name = 10095"; var querytext = "http://www.google.com/fusiontables/gvizdata?tq=" + encodeuricomponent(uri); var query = new google.visualization.query(querytext); query.send(getdata); </script> <body> <h1>test</h1> </body> </html>
i @ loss (after several days reading documentation , examples) figure out why not working. appreciated!
if using google.load(), need wait until script loaded before using it. can set call function (google.setonloadcallback).
<script type=text/javascript> // set callback run when google visualization api loaded. google.setonloadcallback(runquery); google.load('visualization', '1', { 'packages':['corechart', 'table', 'geomap'] } ); function runquery() { var tableid = '1zxsfevzwvm_pute8q5thfwmyr0ncgqzbsdcvqds'; var uri = "select geometry " + tableid + " name = 10095"; var querytext = "http://www.google.com/fusiontables/gvizdata?tq=" + encodeuricomponent(uri); var query = new google.visualization.query(querytext); query.send(getdata); } </script>
of course error getdata not defined (because isn't)
Comments
Post a Comment