jQuery getScript and Google Maps API Problem

Posted by k0ni on Stack Overflow See other posts from Stack Overflow or by k0ni
Published on 2010-06-03T12:32:40Z Indexed on 2010/06/03 12:34 UTC
Read the original article Hit count: 318

Filed under:
|
|
|

HI

I got a problem with loading the google maps api.

I got my own object with a function that initializes the map, and the google maps api gets loaded via jquery.getscript. but i always get an error message in the callback function:

var MyGMap = {
GMapScriptURL: "http://maps.google.com/maps?file=api&v=2&async=2&key=",
Map: null,
Geocoder: null,
InitiazlizeMaps: function () {
    if (GBrowserIsCompatible()) {
        this.Map = new GMap2(document.getElementById("map_canvas"));
        this.Map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        this.Geocoder = new GClientGeocoder();
    }
}

}

$(function(){ var CurrentKey = "MY_KEY";

$.getScript(MyGMap.GMapScriptURL + CurrentKey, function () {
    MyGMap.InitiazlizeMaps();
    // throws GMap2 is undefined

});

});

whats wrong? why is this not running?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX