     $('.edit-undo').click (evt) ->
       evt.preventDefault()
       evt.stopPropagation()
-      if drawnItems.getLayers().slice(-1)[0]?.editing?._enabled
-        drawnItems.removeLayer(drawnItems.getLayers()[-1..][0])
+      if @drawnItems.getLayers().slice(-1)[0]?.editing?._enabled
+        @drawnItems.removeLayer(@drawnItems.getLayers()[-1..][0])
       else
         $('ul.leaflet-draw-actions a[title^="Delete"]')[0].click()
 

class window.LeafletMap
  @CyclestreetsUrl: "https://www.cyclestreets.net"
  @default_marker_anchor: [30 / 2, 42]
  @drawnItems: new L.FeatureGroup()

  constructor: (center, opts) ->
    @domId = opts.domid || 'map'

    @drawFeatureId(circle, "circle")

  drawFeature: (layer) =>
    @drawnItems.addLayer layer
    if @deletePopup
      domelem = document.createElement('a')
      domelem.innerHTML = "#{CONSTANTS.i18n.delete}?</a>"
      domelem.onclick = =>
        @drawnItems.removeLayer layer
        @drawnLayerChanged()
      @drawnItems.bindPopup(domelem)
    @drawnLayerChanged()

  drawnLayerChanged: =>
    @geoInput.changeVal JSON.stringify(@drawnItems.toGeoJSON())
    $("a[title='Save changes.']")[0].click() if @_editing
    $('.leaflet-draw-edit-edit')[0].click()

  addDraw: (feature) =>
    @drawnItems = new L.FeatureGroup()
    $('.icon-save').toggle()

    @map.addLayer @drawnItems
    drawControl = new L.Control.Draw {
      position: 'topright'
      edit: {
        featureGroup: @drawnItems
        edit: { selectedPathOptions: { fillColor: '#00008B', maintainColor: true } }
      }
      draw: {
