class Public::CitiesController < ApplicationController
  def index
    @annonce = Annonce.new
    
    
    if params[:cp] and params[:cp].size > 3
      @cities = @cities || City.where("codes_postaux = ?", params[:cp].to_s)
    else
      @cities = City.where(:nom_commune => params[:cp])
    end
  end
  
  def search
    @country = "mq"
    @place = params[:place]
    
    @result = nil
    params[:where] = "#{params[:lat]},#{params[:lng]}"

    result = Geocoder.search(params[:where]).each do |result|
      if result.city and result.country 
    
        
        @result = result
        break
        
      end
    end
    
    
    
  end
end
