Browse files

Clearing of markers

  • Loading branch information...
1 parent a5324d0 commit 6eecdf5fc28a2a16aa2a8b84c1cab32466ab6bd0 @sebastiandeutsch committed Apr 28, 2012
View
6 app/assets/javascripts/application.js.coffee
@@ -5,11 +5,13 @@
# start the app
jQuery ($) ->
- map = new GoogleMaps('map-canvas')
-
+ window.map = new GoogleMaps('map-canvas')
+ window.markers = []
+
$.getJSON '/companies.json', (data) ->
for startup in data
markerWithPopup = new MarkerWithPopup(map, startup)
+ window.markers.push(markerWithPopup.marker)
return
return
View
18 app/assets/javascripts/google_maps/filter_panel.coffee
@@ -0,0 +1,18 @@
+jQuery ($) ->
+ $('form#company_search input').change (e) ->
+ params = $('form#company_search').serialize()
+ $.ajax({
+ url: "/companies.json",
+ data: params
+ context: document.body
+ }).done((data) ->
+ # clear all markers
+ for marker in window.markers
+ marker.setMap(null);
+
+ # clear all markers
+ for startup in data
+ markerWithPopup = new MarkerWithPopup(window.map, startup)
+ window.markers.push markerWithPopup.marker
+ )
+ return

0 comments on commit 6eecdf5

Please sign in to comment.