     mapPaths.enter().append('path')
       .attr('d', path)
 
+
+  # sets the viewBox attribute on the svg element to cover the whole map
+  # dynamically adjusts the snippet height to the ratio to the viewBox
+  resizeMap = (svg, bounds) ->
+    svgHeight = bounds[1][1] - bounds[0][1]
+    svgWidth = bounds[1][0] - bounds[0][0]
+    svg.attr('viewBox', "#{bounds[0][0]} #{bounds[0][1]} #{svgWidth} #{svgHeight}")
+    ratio = $(svg.node()).width() / svgWidth
+    svg.attr('stroke-width', (1 / ratio) )
+    svg.attr('height', ratio * svgHeight)
+
+
+  deducePathProjection = (projection) ->
+    if projection
+      path = d3.geo.path().projection(eval("d3.geo.#{projection}()"))
+    else
+      path = d3.geo.path().projection(eval("d3.geo.#{defaults.projection}()"))
+
+    return path
+
+
+  #    #############################################
+  #      Data Visualization
+  #    #############################################
 
   renderData = (scope, data, mappingPropertyOnData, valueProperty, mappingPropertyOnMap, valFn) ->
     return if typeof data != 'object'

        mapInstance.dataPointsWithMissingRegion.push(entry)


  # sets the viewBox attribute on the svg element to cover the whole map
  # dynamically adjusts the snippet height to the ratio to the viewBox
  resizeMap = (svg, bounds) ->
    svgHeight = bounds[1][1] - bounds[0][1]
    svgWidth = bounds[1][0] - bounds[0][0]
    svg.attr('viewBox', "#{bounds[0][0]} #{bounds[0][1]} #{svgWidth} #{svgHeight}")
    ratio = $(svg.node()).width() / svgWidth
    svg.attr('stroke-width', (1 / ratio) )
    svg.attr('height', ratio * svgHeight)


  deducePathProjection = (projection) ->
    if projection
      path = d3.geo.path().projection(eval("d3.geo.#{projection}()"))
    else
      path = d3.geo.path().projection(eval("d3.geo.#{defaults.projection}()"))

    return path


  deduceMinValue = (data, valueProperty, allMappingPropertiesOnMap, mappingPropertyOnData) ->
    minValue = d3.min data, (d) ->
      propertyOnData = d[mappingPropertyOnData] || d[defaults.mappingPropertyOnData]

        +d[valueProperty] || +d[defaults.valueProperty]


  # either quantize or ordinal depending on type of data
  deduceValueFunction = (data, valueProperty, quantizeSteps, allMappingPropertiesOnMap, mappingPropertyOnData, mapId) ->
    mapInstance = mapMediatorService.getUIModel(mapId)
    if mapInstance.getValueType() == 'categorical'
