     maxLon = Math.max.apply(Math, lons)
     minLon = Math.min.apply(Math, lons)
 
-    @fitToBounds([[maxLat,maxLon],[minLat,minLon]])
+    ProtectedPlanet.Maps.Bounds.setToBounds(@map, {
+      boundFrom: [maxLat,maxLon],
+      boundTo: [minLat, minLon]
+    })
 
   linkTo: (pa) ->
     "<a href=\"/#{pa.wdpa_id}\">#{pa.name}</a>"

class ProtectedPlanet.Maps.Search
  @showSearchResults: (map, url) ->
    return unless url?

    @getPoints(url, (points) =>
      markers = L.markerClusterGroup(
        showCoverageOnHover: false
      ).addLayers(points)
      map.addLayer(markers)
    )

  @getPoints: (url, callback) ->
    $.get(url, (protected_areas) =>
      markerList = []

      for pa in protected_areas

      callback(markerList)
    )

  fitToResults: (points) ->
    lats = points.map((p) -> parseFloat(p.the_geom_latitude))
    lons = points.map((p) -> parseFloat(p.the_geom_longitude))

