views:

688

answers:

1

I'm using google map API along with the MarkerManager. I load the 2 javascript libraries by JQuery.

Here is my Javascript:

function initialize() {
    $.getScript('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js');
    $.getScript('http://maps.google.com/maps?file=api&v=2&async=2&callback=mapLoaded&sensor=true_or_false&key=ABC');

}
function mapLoaded() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(18, -77.4), 13);
        map.setUIToDefault();

        var mgr = new MarkerManager(map);
        mgr.addMarkers(getWeatherMarkers(), 5); //gets some marker from another function
        mgr.refresh();

    }
}

The error I get in firebug javascript debugger is:

GBounds is not defined [Break on this error] GBounds.prototype.containsPoint = function(point) {\nmarkerma...109501758 (line 377)

me.getMapGridBounds_ is not a function [Break on this error] me.shownBounds_ = me.getMapGridBounds_();\n markerma...109501758 (line 106)

This error also occurs if I load the javascript library statically.

Thanks,

+2  A: 

There are two problems with your code that I see.

First, you are not using the newest verson of MarkerManager. Use the new one here:

http://gmaps-utility-library-dev.googlecode.com/svn/tags/markermanager/1.1/src/markermanager.js

Second, the MarkerManager library requires the GoogleMaps API to be loaded first.

Start by switching the order (I don't think this will work):

$.getScript('http://maps.google.com/maps?file=api&v=2&async=2&callback=mapLoaded&sensor=true_or_false&key=ABC');
$.getScript('http://gmaps-utility-library-dev.googlecode.com/svn/tags/markermanager/1.1/src/markermanager.js');

But more likely, you will need something like this:

function initialize() {
    $.getScript('http://maps.google.com/maps?file=api&v=2&async=2&callback=mapLoaded&sensor=true_or_false&key=ABC');
}
function mapLoaded() {
    $.getScript('http://gmaps-utility-library-dev.googlecode.com/svn/tags/markermanager/1.1/src/markermanager.js', function(){
      if (GBrowserIsCompatible()) {
          map = new GMap2(document.getElementById("map_canvas"));
          map.setCenter(new GLatLng(18, -77.4), 13);
          map.setUIToDefault();

          var mgr = new MarkerManager(map);
          mgr.addMarkers(getWeatherMarkers(), 5); //gets some marker from another function
          mgr.refresh();
      }          
    });
}
Doug Neiner