         # TODO: for now id's are always numeric -> make this an interface property
         # TODO: make value an interface property
         valueById.set(+eval("d.#{defaults.mappingValue.inData}"), +d.value)
-      mapGroup.selectAll('path')
+      scope.mapGroup.selectAll('path')
         .attr('class', (d) -> quantize(valueById.get(+eval("d.#{defaults.mappingValue.inMap}"))))
         # TODO: use default value when quantize does not return a value
 

angular.module('ldEditor').directive 'choropleth', ($timeout, ngProgress) ->

  svg = null
  mapGroup = null

  defaults =
    projection: d3.geo.mercator()

    svg.attr('height', ratio * svgHeight)


  removeExistingMap = (mapGroup) ->
    mapPaths = mapGroup.selectAll('path')
      .data([])
    mapPaths.exit().remove()
