Files
openfoodnetwork/app/assets/javascripts/darkswarm/services/map.js.coffee
Rohan Mitchell 3527ae6ea2 Update comment
2015-07-10 15:51:57 +10:00

20 lines
707 B
CoffeeScript

Darkswarm.factory "OfnMap", (Enterprises, EnterpriseModal, visibleFilter) ->
new class OfnMap
constructor: ->
@enterprises = @enterprise_markers(Enterprises.enterprises)
enterprise_markers: (enterprises) ->
@extend(enterprise) for enterprise in visibleFilter(enterprises)
# Adding methods to each enterprise
extend: (enterprise) ->
new class MapMarker
# We cherry-pick attributes because GMaps tries to crawl
# our data, and our data is cyclic, so it breaks
latitude: enterprise.latitude
longitude: enterprise.longitude
icon: enterprise.icon
id: enterprise.id
reveal: =>
EnterpriseModal.open enterprise