   BOUNDS_CONTAINS_BUFFER: 0.41
 
   createLayer: (latlng, options)->
+    if latlng instanceof Wheelmap.PopupController
+      options = latlng.getProperties('wheelchair', 'icon')
+      latlng = latlng.get('location')
+
+      console.log(options, latlng)
+
     new L.Marker latlng,
       riseOnHover: true
       icon: Wheelmap.MarkerLayer.createIcon(options)

  getLayer: (nodeId)->
    @get('geoJSONLayer').getLayers().findBy('feature.properties.id', parseInt(nodeId, 10))

  _openPopup: (nodeId)->
    map = @get('map.layer')
    marker = @getLayer(nodeId)

    if marker?
      marker.setZIndexOffset(marker.options.riseOffset)

      @$nodeView = $('.node-popup-view')
      @$nodeViewPrev = @$nodeView.prev()

      map.openPopup @$nodeView[0], marker.getLatLng(),
        className: 'node-popup'
        offset: [0, -24]
        closeOnClick: false
        closeButton: false

  _closePopup: (nodeId)->
    map = @get('map.layer')
    marker = @getLayer(nodeId)

    if marker?
      marker.setZIndexOffset(0)

      @$nodeViewPrev.after(@$nodeView)
      @$nodeView = null
      @$nodeViewPrev = null

      map.closePopup()

  _onClick: (event)->
    nodeId = null

    poppingNode = @get('poppingNode')

    if poppingNode?
      nodeId = poppingNode.get('id')

      if @popupNodeId == nodeId
        unless @getLayer(poppingNode.get('id'))?
          # There is no marker with this id so reset url
          @sendPopupAction(null, true)

        return

      @popupNodeId = nodeId
      Ember.run.scheduleOnce('afterRender', @, @_openPopup, nodeId)
      # @TODO add this only for mobile devices with lower bandwidth
      # Ember.run.scheduleOnce('afterRender', @get('map'), 'set', 'isLoading', false)
      Ember.run.scheduleOnce('afterRender', poppingNode, 'send', 'opened')
  ).observes('poppingNode.id')

