eschwartz / backbone.googlemaps

A Backbone JS extension for interacting with the Google Maps API (v3.10)
MIT License
139 stars 55 forks source link

Error initializing MarkerCollectionView #25

Closed nintype closed 10 years ago

nintype commented 10 years ago

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.

halcyonandon commented 10 years ago

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...

eschwartz commented 10 years ago

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

eschwartz commented 10 years ago

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