apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Can't load TransitLayer #266

Closed dgmstuart closed 12 years ago

dgmstuart commented 12 years ago

When I try and load the google maps Transit layer I get Uncaught TypeError: undefined is not a function in relation to var layer = new google.maps.TransitLayer();.

BicyclingLayer() and TrafficLayer() work correctly: those layers are loaded onto the map.

This may well be an issue with the maps API rather than the gem (or just a failure in my JS skills), but I can't find anything about issues with this layer and I thought it was worth checking whether there might be some conflict in the gem (?).

Can anyone reproduce this?

Here's my view:

= map(@json)

- content_for :scripts do
  :javascript
    Gmaps.map.callback = function() {  
      var layer = new google.maps.TransitLayer();
      layer.setMap(Gmaps.map.serviceObject);
    }

The following DO work: var layer = new google.maps.BicyclingLayer(); var layer = new google.maps.TrafficLayer();

The area I'm looking at is this: http://swingoutlondon.co.uk/map

Great gem by the way - really helped clean up my code a lot.

apneadiving commented 12 years ago

Sorry for the delay, just dived into this.

The issue stems from the google maps api version I'm using: 3.8.

The layer you want exists in 3.9 but I didn't check 3.9 full compatibility yet.

At first glance you could simply change 3.8 to 3.9 here https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/lib/gmaps4rails/view_helper.rb#L8

dgmstuart commented 11 years ago

That's great! Thanks so much for looking into this.

I'm being lazy and using 2.0.0.pre to include this, but it's working fine. Thanks again.