0

trying to get google visualisation API to work in greasemonkey (firefox) i tried to just use:

  // @require          http://www.google.com/jsapi

but then i get an Error: google.visualization is undefined

after adding:

//  google.load('visualization', '1', {packages: ['table']});

i get the Error: $ is not defined

am i requiring the wrong thing? please help.

thanks in advance for useful answers!

plastic cloud
  • 241
  • 1
  • 4
  • 12

1 Answers1

1

i had a similar question concerning the Google Maps API.

in my case, i had to append the API to the page with

API_js_callback = "http://maps.google.com/maps/api/js?sensor=false&region=BR&callback=initialize";

var script = document.createElement('script');
    script.src = API_js_callback;
    var head = document.getElementsByTagName("head")[0];
    (head || document.body).appendChild(script);

and google had to be called as unsafeWindow.google, so i added google = unsafeWindow.google as well.

initialize = setTimeout(function () {
    google = unsafeWindow.google;
    directionsService = new google.maps.DirectionsService();
    directionsDisplay = new google.maps.DirectionsRenderer();
    .
    .
    .

check the full code and explanation here: how to use the google maps api with greasemonkey to read a table of addresses and trace the route?

Community
  • 1
  • 1
RASG
  • 5,988
  • 4
  • 26
  • 47