Pregunta

My map handler is

map_handler = Gmaps.build('Google', { markers: { maxRandomDistance: null }, builders: { Marker: InfoBoxBuilder} });

I already added in my layout:

<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js' type='text/javascript'></script>

and also I already added a file infoboxbuilder.js.cofee in my assets with this override:

class InfoBoxBuilder extends Gmaps.Google.Builders.Marker # inherit from base builder


 # override method
  create_infowindow: ->
    return null unless _.isString @args.infowindow

boxText = document.createElement("div")
boxText.setAttribute("class", 'yellow') #to customize
boxText.innerHTML = @args.infowindow
@infowindow = new InfoBox(@infobox(boxText))

@bind_infowindow()

  infobox: (boxText)->
    content: boxText
    pixelOffset: new google.maps.Size(-140, 0)
    boxStyle:
      width: "280px"

But when I load the site I get this javascript error with no map:

ReferenceError: InfoBoxBuilder is not defined
¿Fue útil?

Solución

Just realized your mistake

Replace

 class InfoBoxBuilder

With

class @InfoBoxBuilder

fyi, @ tells coffeescript to attach the object to the window object.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top