Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:24:19+00:00 2026-06-01T18:24:19+00:00

Nothing I’ve tried seems to work. I found these two links and thought they’d

  • 0

Nothing I’ve tried seems to work.
I found these two links and thought they’d be helpful, but that hasn’t worked either.
Dynamically load JavaScript with JavaScript
https://developers.google.com/loader/

Here’s roughly what my Greasemonkey script looks like currently:

var init_map = function() {
    new google.maps.Geocoder().geocode({address:'1125 NW 12th Ave, Portland, OR'},function(result){
        alert(result);
    });
}

function loadMaps() {
    GM_log("loadMaps called");
    google.load("maps", "3", {"callback" : init_map, "other_params":"key=foo&sensor=false"});
}

function loadScript(filename,callback){
  var fileref=document.createElement('script');
  fileref.setAttribute("type","text/javascript");
  fileref.onload = callback;
  fileref.setAttribute("src", filename);
  if (typeof fileref!="undefined"){
    document.getElementsByTagName("head")[0].appendChild(fileref);
  }
}

$(document).ready(
    function() {
        GM_log("document ready");
        loadScript('http://www.google.com/jsapi?key=ABQIAAAAfoo',function(){
            loadMaps();
        });
    }
);

I’ve found that if I don’t include
// @require http://www.google.com/jsapi?key=ABQIAAAAfoo
in the Greasemonkey script, I get a google is undefined error. If I do include it, init_map() never gets called. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:24:20+00:00Added an answer on June 1, 2026 at 6:24 pm

    I flagged this question as duplicate of how to use the google maps api with greasemonkey to read a table of addresses and trace the route? but the mod “found no evidence to support it”.

    So i will just copy-paste what i did in my question, since its not a duplicate…
    Nah, just kidding 🙂

    Lets start with your last statement:

    I’ve found that if I don’t include // @require
    http://www.google.com/jsapi?key=ABQIAAAAfoo in the Greasemonkey
    script, I get a google is undefined error. If I do include it,
    init_map() never gets called. Any suggestions?

    Yes.
    First, the google maps API should not be loaded as a @require. Instead, do it like this

    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);
    

    Second, add google = unsafeWindow.google, otherwise you get the “google is undefined” error.
    So, your code should start like this

    var init_map = function() {
        google = unsafeWindow.google
        new google.maps.Geocoder().geocode . . . . . .
    

    About the rest of your code… well, just click on the link above and there you will find how to create a DIV on the fly, add the map to it, append the DIV to the page in a fixed position, etc.

    Feel free to copy whatever you want.

    Greasemonkey scripts are free anyway 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Found similar questions but nothing that covers exactly what I need. I kept it
Google returns me just nothing useful on these keywords. But I know there is
I have searched and nothing that I have found hits directly on what I
Nothing seems to work so far. I got to see with pnginfo the following
know nothing about php, but I have this script that reads a folder and
I googled it but nothing is that straight forward, I am sure others must
Looking around I found nothing that addresses my issue so here goes. I have
Note: this question has nothing to do with Knockout.js, but it's about the selectedOptions
All my searches returned nothing and I find it odd that there aren't any
i know nothing about medical records but im sure there's great opportunity in it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.