Skip to content

Commit

Permalink
Merge pull request #27 from sul-dlss/custom-colors
Browse files Browse the repository at this point in the history
add ability to pass through color ramp from CatalogController configu…
  • Loading branch information
Darren Hardy committed Jul 6, 2016
2 parents 13389b2 + 1973990 commit 016b90b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/assets/javascripts/blacklight_heatmaps/viewers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Blacklight.onLoad(function () {
var requestUrl = $el.data().searchUrl + '&format=json';
var geometryField = $el.data().geometryField;
var template = $el.data().sidebarTemplate;
var colorRamp = $el.data().colorRamp;

var map = L.map($el[0].id).setView([0, 0], 1);
var basemap = L.tileLayer($el.data().basemap, {
Expand All @@ -27,6 +28,7 @@ Blacklight.onLoad(function () {
var solrLayer = L.solrHeatmap(requestUrl, {
field: geometryField,
maxSampleSize: 50,
colors: colorRamp,
}).addTo(map);

var sidebar = L.control.sidebar('index-map-sidebar', {
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/blacklight/maps_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def index_map_data_attributes
basemap: blacklight_config.basemap,
search_url: request.url,
geometry_field: blacklight_config.geometry_field,
sidebar_template: sidebar_template
sidebar_template: sidebar_template,
color_ramp: blacklight_config.view.heatmaps.color_ramp
}
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/blacklight_heatmaps/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def configuration
"\n config.basemap = 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png'" \
"\n config.show.partials.insert(1, :show_leaflet_map)" \
"\n config.view.heatmaps.partials = []" \
"\n #Heatmap color ramp. For best results, use http://colorbrewer2.org or http://tristen.ca/hcl-picker/#/hlc/5/1" \
"\n config.view.heatmaps.color_ramp = ['#ffffcc', '#a1dab4', '#41b6c4', '#2c7fb8', '#253494']" \
"\n"
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/helpers/blacklight/maps_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
expect(helper.index_map_div)
.to have_css '[data-basemap="http://www.example.com/{z}/{x}/{y}.png"]'
expect(helper.index_map_div).to have_css '[data-sidebar-template]'
expect(helper.index_map_div).to have_css '[data-color-ramp]'
end
end
describe '#sidebar_template' do
Expand Down

0 comments on commit 016b90b

Please sign in to comment.