N'affiche la carte que pour les evt géocodés

This commit is contained in:
echarp 2014-08-23 17:21:11 +02:00
parent dadb6cd521
commit 8ee752a306
3 changed files with 2 additions and 4 deletions

View File

@ -7,15 +7,12 @@ $(document).ready ->
).addTo map
$.getJSON '/maps.json', (json) ->
points = []
L.geoJson(json,
onEachFeature: (feature, layer) ->
points += [feature.geometry.coordinates[0], feature.geometry.coordinates[1]]
# Does this feature have a property named popupContent?
if (feature.properties && feature.properties.popupContent)
layer.bindPopup(feature.properties.popupContent)
).addTo map
console.log L.bounds(points[0], points[1])
$('.events #map').each ->

View File

@ -6,7 +6,7 @@ class MapsController < ApplicationController
respond_to do |format|
format.html
format.json do
render json: Event.moderated.future.map { |event| event.to_json }
render json: Event.moderated.future.geo.map { |event| event.to_json }
end
end
end

View File

@ -48,6 +48,7 @@ class Event < ActiveRecord::Base
end)
scope :region, -> region { where 'region = ? or locality', region }
scope :tag, -> tag { where 'tags like ?', "%#{tag}%" }
scope :geo, -> { where 'latitude is not null and longitude is not null' }
before_validation on: :create do
self.submission_time = DateTime.now