Skip to content

Commit

Permalink
enable map to point towards fingerprinted assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Jet committed May 3, 2021
1 parent f04ff0e commit c257770
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
11 changes: 10 additions & 1 deletion app/decorators/map_markers_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
class MapMarkersDecorator < Draper::CollectionDecorator

def self.public_composter_marker
'public_composter_marker.png'
end

def self.private_composter_marker
'private_composter_marker.png'
end

def to_map_marker_json
to_json(only: [:id, :latitude, :longitude], methods: [:map_marker_display, :icon_url])
to_json(only: [:id, :latitude, :longitude, :public], methods: [:map_marker_display])
end

end
5 changes: 0 additions & 5 deletions app/decorators/site_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def edit_composting_site_path
condominium_site? ? edit_condominium_site_path(site) : edit_site_path(site)
end

def icon_url
asset_name = self.public? ? 'public_composter_marker.png' : 'private_composter_marker.png'
image_path(asset_name)
end

def map_marker_display
content = content_tag(:h6, content_tag(:b, name))
content += label_and_content(label: 'Adresse', content: raw(format_address))
Expand Down
7 changes: 5 additions & 2 deletions app/views/shared/_leaflet_site_map.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ javascript:
}).addTo(mymap);
var data = #{markers_data};
var publicSiteIconPath = '#{image_path(MapMarkersDecorator.public_composter_marker)}';
var privateSiteIconPath = '#{image_path(MapMarkersDecorator.private_composter_marker)}';
data.forEach((site, i) => {
if (site.latitude == null) {
return;
}
var siteIconPath = site.public ? publicSiteIconPath : privateSiteIconPath;
var composterIcon = L.icon({
iconUrl: site.icon_url,
iconUrl: siteIconPath,
iconSize: [24, 24],
});
console.log(composterIcon)
Expand Down
5 changes: 4 additions & 1 deletion app/views/shared/_leaflet_sites_map.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ javascript:
}).addTo(mymap);
var data = #{markers_data};
var publicSiteIconPath = '#{image_path(MapMarkersDecorator.public_composter_marker)}';
var privateSiteIconPath = '#{image_path(MapMarkersDecorator.private_composter_marker)}';
data.forEach((site, i) => {
if (site.latitude == null) {
return;
}
var siteIconPath = site.public ? publicSiteIconPath : privateSiteIconPath;
var composterIcon = L.icon({
iconUrl: site.icon_url,
iconUrl: siteIconPath,
iconSize: [24, 24],
});
var marker = L.marker([site.latitude, site.longitude], {icon: composterIcon}).addTo(mymap);
Expand Down

0 comments on commit c257770

Please sign in to comment.