eschwartz/backbone.googlemaps

Error initializing MarkerCollectionView

Closed this issue · 3 comments

I'm using the code in the readme:

places = new Backbone.GoogleMaps.LocationCollection([
      {
        title: "Walker Art Center",
        lat: 44.9796635,
        lng: -93.2748776
      }, {
        title: "Science Museum of Minnesota",
        lat: 44.9429618,
        lng: -93.0981016
      }
    ]);
    map = new googlemaps.Map($('.map-canvas')[0], {
      center: new googlemaps.LatLng(44.9796635, -93.2748776),
      zoom: 12,
      mapTypeId: googlemaps.MapTypeId.ROADMAP
    });
    markerCollectionView = new Backbone.GoogleMaps.MarkerCollectionView({
      collection: places,
      map: map
    });

Instantiating markerCollectionView fails with the following error:

"Uncaught TypeError: Cannot read property 'map' of undefined"

at the line

if(!this.options.map && !this.map) throw new Error("A map must be specified on MarkerCollectionView instantiation")

this.options is, in fact, undefined.

I'm seeing what you're doing out of context, but it looks like you're not constructing things correctly

new MarkerCollectionView({...})
and not new Backbone.GoogleMaps.MarkerCollectionView({ ...})

Same with LocationCollection...

@nintype - can you check if this issues is fixed in the most recent version? I believe 494bc93 may have fixed your problem.

I believe this issue is fix -- if you're still having problems, I can reopen.