Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I have a problem with the Google Maps API and displaying KML files. The file is valid KML and displays fine if I put the URL into maps.google.com, however, if I go like this on my own site:

code:
map.clearOverlays();
map.addOverlay(GGeoXml("http://domain/path/to/file.kml"));
Nothing shows on the map. If I try to run the functions in Safari's Inspector console, I get:

code:
> map.addOverlay(GGeoXml("http://domain/path/to/file.kml"));
  null
  TypeError: Result of expression 'e.lk' [undefined] is not a function.
e.lk is in Google's mod_kml_api.js file. Anyone have experience with this?

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Supervillin posted:

should be
code:
map.addOverlay(new GGeoXml("http://domain/path/to/file.kml"));
GGeoXml is a constructor, you have to use new.

Geez, I looked at that drat thing so long I went blind. Thanks, it works as advertised now :)

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I'm dynamically adding a .js file to the header of a page, the .js file is out of my control so I cannot change it.

The last thing it does is register an event listener like so:
code:
window.addEventListener("load", initializationStuff, false);
Since the window is already loaded, the event doesn't fire, but I want it to. I've tried
code:
var event = document.createEvent(); 
event.initEvent('load'); 
document.dispatchEvent(event);
but that gave me a NOT_SUPPORTED_ERR.

Am I doing it wrong? I tried googling a bit and there doesn't seem to be a way in DOM to check if any events are registered, so I cannot check if it's actually set up are not, is that correct?

edit: NM I'm retarded at javascript. I figured it out (it should be createEvent("HTMLEvents"))

Carthag Tuek fucked around with this message at 00:22 on Aug 8, 2009

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Mercator posted:

Why not call initializationStuff yourself? No need to muck about with events because the DOM has already been initialized.
I tried but it said undefined, probably cause it's a function reference that gets passed to the event handler. The js file is weird like that, the whole thing is wrapped in an unnamed function as well.

Anyway, this is what I was working on, a greasemonkey script that makes youtube no longer require flash:

http://userscripts.org/topics/32424

If someone wants to run with it, go ahead.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply