     error: ->
       alert('Nastąpił błąd podczas wyszukiwania zabytków.')
 
+hasValidWaypoints = (waypoints) ->
+  waypoints.filter (waypoint) ->
+    not waypoint.isBlank()
+  .length > 1
+
 debouncedSearchRelics = jQuery.debounce ->
   if $('#search_params').length > 0
     search_params            = $.parseJSON $('#search_params').html()

    if ROUTE?
      updateWaypointInputs ROUTE, -> searchRelics()

  gmap.onNextMovement ->
  gmap.setCenter(new google.maps.LatLng(52, 20))
  gmap.setZoom(6)
  searchRelics()

    window.gmap = new google.maps.Map $('#map_canvas')[0],
      mapTypeId: google.maps.MapTypeId.HYBRID

  gmap.onNextMovement ->
  gmap.setCenter(new google.maps.LatLng(52, 20))
  gmap.setZoom(6)

  if renderOnly?
    do searchRelics
    return
