     ApiResource 'services'
 
   .factory 'Map', ($filter) ->
-    (id) =>
+    (id, clustering) =>
       osmLayer = L.tileLayer(
         'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
         attribution: '(c) OpenStreetMap')

        'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
        attribution: '(c) Esri')

      markerLayer = L.featureGroup()

      map = L.map id,
        center: new L.LatLng -6.3153, 35.15625

        html = '<div class="popup">' + header + fields + '</div>'

      @clearMarkers = () ->
        if clustering
          markerLayer.RemoveMarkers()
        else
          markerLayer.clearLayers()

      @addWaterpoint = (wp, popup) ->
        [lng,lat] = wp.location.coordinates
        if clustering
          m = new PruneCluster.Marker lat, lng, popup
          m.category = categoryMap[wp.status_group]
          markerLayer.RegisterMarker m
        else
          m = L.marker L.latLng(lat,lng),
            stroke: false
            opacity: 0.8
            fillColor: statusColor(wp.status_group)
          if popup
            m.bindPopup popup
          markerLayer.addLayer(m)

      @zoomToMarkers = () ->
        if clustering
          markerLayer.FitBounds()
        else
          bounds = markerLayer.getBounds()
          if bounds.isValid()
            map.fitBounds(bounds)

      return this

