Skip to content

Commit

Permalink
Use a custom icon to create asset_path urls to icons
Browse files Browse the repository at this point in the history
Solves the temporary leaflet/rails asset icon path fiasco of
2016 / 2017
  • Loading branch information
mejackreed committed Feb 13, 2017
1 parent 9195e45 commit 6b7d137
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/javascripts/blacklight_heatmaps/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
//= require leaflet_solr_heatmap
//= require blacklight_heatmaps/blacklight_heatmaps
//= require blacklight_heatmaps/basemaps
//= require blacklight_heatmaps/icons
//= require_tree ./viewers
7 changes: 7 additions & 0 deletions app/assets/javascripts/blacklight_heatmaps/icons.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BlacklightHeatmaps.Icons = {
default: new L.Icon({
iconUrl: '<%= asset_path 'marker-icon.png'%>',
iconRetinaUrl: '<%= asset_path 'marker-icon-2x.png'%>',
shadowUrl: '<%= asset_path 'marker-shadow.png'%>'
})
};
8 changes: 7 additions & 1 deletion app/assets/javascripts/blacklight_heatmaps/viewers/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ Blacklight.onLoad(function () {
$el.data().basemapProvider
).addTo(map);

var features = L.geoJson(features).addTo(map);
var features = L.geoJson(features, {
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {
icon: BlacklightHeatmaps.Icons.default
})
}
}).addTo(map);

map.fitBounds(features.getBounds());
},
Expand Down

0 comments on commit 6b7d137

Please sign in to comment.