Files
openfoodnetwork/app/assets/javascripts/darkswarm/services/map.js.coffee
Maikel Linke 2fd25f6cc4 Injecting all enterprises into group page
The enterprises have related producers and hubs that need to be
dereferenced. Therefore, we need a bigger set of enterprises to be
loaded. Injecting all enterprises is simple and doesn't require changes
if the set of needed enterprise data is growing in future.
2015-04-10 17:42:54 +10:00

20 lines
714 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're whitelisting attributes because GMaps tries to crawl
# our data, and our data is recursive, so it breaks
latitude: enterprise.latitude
longitude: enterprise.longitude
icon: enterprise.icon
id: enterprise.id
reveal: =>
EnterpriseModal.open enterprise