I'm trying to create a bookmarklet that loads Google Maps dynamically and displays it in a dialog overlay. It works fine when I run it on the same site (localhost in this case) that the bookmarklet JavaScript is loaded from, but not when I go to a third-party site like NYTimes.com for example. I don't see any HTTP errors in Firebug, but when the bookmarklet code tries to instantiate a new google.maps object, the console shows the following message:
TypeError: google.maps is undefined
Is what I'm attempting an illegal cross-domain call or might there be something wrong with my implementation?
This is the code that's loading the maps script from my bookmarklet bootloader:
var mapsScript = document.createElement("script");
mapsScript.type = "text/javascript";
mapsScript.src = "http://maps.googleapis.com/maps/api/js?libraries=places&key=KEY&sensor=true&callback=CALLBACK";
document.body.appendChild(mapsScript);
Later, the callback has the following line:
var center = new google.maps.LatLng(la, ln);