blacklight_heatmaps 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -0
- data/app/assets/javascripts/blacklight_heatmaps/basemaps.js +24 -0
- data/app/assets/javascripts/blacklight_heatmaps/blacklight_heatmaps.js +9 -1
- data/app/assets/javascripts/blacklight_heatmaps/default.js +1 -0
- data/app/assets/javascripts/blacklight_heatmaps/viewers/index.js +7 -3
- data/app/assets/javascripts/blacklight_heatmaps/viewers/show.js +3 -3
- data/app/helpers/blacklight/maps_helper.rb +1 -1
- data/app/views/catalog/_show_leaflet_map_default.html.erb +1 -1
- data/lib/blacklight_heatmaps/version.rb +1 -1
- data/lib/generators/blacklight_heatmaps/install_generator.rb +2 -1
- data/spec/features/configurable_basemap_spec.rb +30 -0
- data/spec/features/index_page_map_spec.rb +11 -3
- data/spec/features/show_page_map_spec.rb +1 -1
- data/spec/helpers/blacklight/maps_helper_spec.rb +2 -2
- data/spec/views/catalog/_show_leaflet_map_default.html.erb_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34bf3d4054840fa836d9d5124f96c49fba40682
|
4
|
+
data.tar.gz: 4cacc16ee841628ab63fed4ed7b2f072ce3340a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0728f7fbf1a5980b8deaa924199f9c03ef31a031addd41b5d7356fd0e1099a29e88b0710e12c2da6191b75efaaaa27b77f4431a48fb9c31b061887ef1e30bb0e
|
7
|
+
data.tar.gz: f2e7af9957508046a24836ca8f3630ea693fcddf11dda70630d52b13958f6bb4fba3acf18d93ad01a2f66df4b9428c381b49b72fb5eb3976257a216db772ffc4
|
data/README.md
CHANGED
@@ -34,6 +34,7 @@ rails generate blacklight_heatmaps:install
|
|
34
34
|
|
35
35
|
## Getting started
|
36
36
|
|
37
|
+
### Indexing data
|
37
38
|
BlacklightHeatmaps expects your data to be indexed as a [Spatial Recursive Prefix Tree](https://cwiki.apache.org/confluence/display/solr/Spatial+Search#SpatialSearch-RPT) type. The plugin currently supports data indexed in formats:
|
38
39
|
|
39
40
|
- `x y` Syntax. example: "-121.631609 36.688128"
|
@@ -41,6 +42,38 @@ BlacklightHeatmaps expects your data to be indexed as a [Spatial Recursive Prefi
|
|
41
42
|
|
42
43
|
Additional formats could be added by extending `BlacklightHeatmaps::GeometryParser`
|
43
44
|
|
45
|
+
### Customizing the basemap
|
46
|
+
|
47
|
+
By default three different basemaps are included with BlacklightHeatmaps. You can modify these by changing the configuration value in the `CatalogController`.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# Basemaps configured include: 'positron', 'darkMatter', 'OpenStreetMap.HOT'
|
51
|
+
config.basemap_provider = 'OpenStreetMap.HOT'
|
52
|
+
```
|
53
|
+
|
54
|
+
BlacklightHeatmaps allows you to customize your basemap further to any Leaflet TileLayer subclass. This includes WMS layers, TileLayers, etc. Checkout [Leaflet Providers](https://github.com/leaflet-extras/leaflet-providers) for more ideas on basemaps you can use.
|
55
|
+
|
56
|
+
To customize the basemap, make sure that you extend the `BlacklightHeatmaps.Basemaps` object to include your basemap selection:
|
57
|
+
|
58
|
+
```javascript
|
59
|
+
BlacklightHeatmaps.Basemaps[' OpenStreetMap.BlackAndWhite'] = L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
|
60
|
+
maxZoom: 18,
|
61
|
+
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
62
|
+
});
|
63
|
+
```
|
64
|
+
|
65
|
+
### Customizing the color display
|
66
|
+
The heatmap color ramp is also customizable. This setting can be modified in `CatalogController` by passing in an array of hexadecimal color values as strings.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
#Heatmap color ramp. For best results, use http://colorbrewer2.org or http://tristen.ca/hcl-picker/#/hlc/5/1
|
70
|
+
config.view.heatmaps.color_ramp = ['#fef0d9','#fdcc8a','#fc8d59','#e34a33','#b30000']
|
71
|
+
```
|
72
|
+
|
73
|
+
![changed_ramp](https://cloud.githubusercontent.com/assets/1656824/16814655/ce3a0170-4904-11e6-8d0f-a9cfb1d44057.png)
|
74
|
+
|
75
|
+
[ColorBrewer](http://colorbrewer2.org/) is a great resource in choosing a color ramp. It also has options for colorblind safe ramps to use and can export the hex values in an array that you can paste into your configuration.
|
76
|
+
|
44
77
|
## Development
|
45
78
|
|
46
79
|
Run Solr and Blacklight (with BlacklightMaps) for interactive development:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
BlacklightHeatmaps.Basemaps = {
|
2
|
+
darkMatter: L.tileLayer(
|
3
|
+
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png', {
|
4
|
+
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>',
|
5
|
+
maxZoom: 18,
|
6
|
+
worldCopyJump: true,
|
7
|
+
detectRetina: true,
|
8
|
+
}
|
9
|
+
),
|
10
|
+
positron: L.tileLayer(
|
11
|
+
'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
|
12
|
+
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>',
|
13
|
+
maxZoom: 18,
|
14
|
+
worldCopyJump: true,
|
15
|
+
detectRetina: true,
|
16
|
+
}
|
17
|
+
),
|
18
|
+
'OpenStreetMap.HOT': L.tileLayer(
|
19
|
+
'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
|
20
|
+
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>',
|
21
|
+
maxZoom: 19,
|
22
|
+
}
|
23
|
+
),
|
24
|
+
};
|
@@ -3,7 +3,15 @@
|
|
3
3
|
|
4
4
|
var BlacklightHeatmaps = L.Class.extend({
|
5
5
|
statics: {
|
6
|
-
__version__: '0.0.
|
6
|
+
__version__: '0.0.3',
|
7
|
+
|
8
|
+
selectBasemap: function (basemap) {
|
9
|
+
if (basemap && basemap !== undefined) {
|
10
|
+
return BlacklightHeatmaps.Basemaps[basemap];
|
11
|
+
} else {
|
12
|
+
return BlacklightHeatmaps.Basemaps.positron;
|
13
|
+
}
|
14
|
+
},
|
7
15
|
},
|
8
16
|
});
|
9
17
|
global.BlacklightHeatmaps = BlacklightHeatmaps;
|
@@ -20,10 +20,14 @@ Blacklight.onLoad(function () {
|
|
20
20
|
var template = $el.data().sidebarTemplate;
|
21
21
|
var colorRamp = $el.data().colorRamp;
|
22
22
|
|
23
|
+
// Blank out page link content first and disable pagination
|
24
|
+
$('#sortAndPerPage .page_links').html('');
|
25
|
+
$('ul.pagination li').addClass('disabled');
|
26
|
+
|
23
27
|
var map = L.map($el[0].id).setView([0, 0], 1);
|
24
|
-
var basemap =
|
25
|
-
|
26
|
-
|
28
|
+
var basemap = BlacklightHeatmaps.selectBasemap(
|
29
|
+
$el.data().basemapProvider
|
30
|
+
).addTo(map);
|
27
31
|
|
28
32
|
var solrLayer = L.solrHeatmap(requestUrl, {
|
29
33
|
field: geometryField,
|
@@ -17,9 +17,9 @@ Blacklight.onLoad(function () {
|
|
17
17
|
var features = $el.data().features;
|
18
18
|
|
19
19
|
var map = L.map($el[0].id).setView([0, 0], 1);
|
20
|
-
var basemap =
|
21
|
-
|
22
|
-
|
20
|
+
var basemap = BlacklightHeatmaps.selectBasemap(
|
21
|
+
$el.data().basemapProvider
|
22
|
+
).addTo(map);
|
23
23
|
|
24
24
|
var features = L.geoJson(features).addTo(map);
|
25
25
|
|
@@ -48,7 +48,7 @@ module Blacklight
|
|
48
48
|
def index_map_data_attributes
|
49
49
|
{
|
50
50
|
index_map: true,
|
51
|
-
|
51
|
+
basemap_provider: blacklight_config.basemap_provider,
|
52
52
|
search_url: request.url,
|
53
53
|
geometry_field: blacklight_config.geometry_field,
|
54
54
|
sidebar_template: sidebar_template,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% features = document.to_geojson(blacklight_config) %>
|
2
2
|
|
3
3
|
<% unless features.nil? %>
|
4
|
-
<%= content_tag(:div, nil, class: 'blacklight-heatmaps-show-map', id: "map-#{document.id}", data: {show_map: true, features: features,
|
4
|
+
<%= content_tag(:div, nil, class: 'blacklight-heatmaps-show-map', id: "map-#{document.id}", data: {show_map: true, features: features, basemap_provider: blacklight_config.basemap_provider}) %>
|
5
5
|
<% end %>
|
@@ -17,7 +17,8 @@ module BlacklightHeatmaps
|
|
17
17
|
inject_into_file 'app/controllers/catalog_controller.rb', after: 'configure_blacklight do |config|' do
|
18
18
|
"\n # BlacklightHeatmaps configuration values" \
|
19
19
|
"\n config.geometry_field = :geo_srpt" \
|
20
|
-
"\n
|
20
|
+
"\n # Basemaps configured include: 'positron', 'darkMatter', 'OpenStreetMap.HOT'" \
|
21
|
+
"\n config.basemap_provider = 'positron'" \
|
21
22
|
"\n config.show.partials.insert(1, :show_leaflet_map)" \
|
22
23
|
"\n config.view.heatmaps.partials = []" \
|
23
24
|
"\n #Heatmap color ramp. For best results, use http://colorbrewer2.org or http://tristen.ca/hcl-picker/#/hlc/5/1" \
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Configurable basemap', js: true do
|
4
|
+
scenario 'defaults to positron' do
|
5
|
+
visit search_catalog_path(q: ' ', view: 'heatmaps', search_field: 'all_fields')
|
6
|
+
expect(page).to have_css "img[src*='light_all']"
|
7
|
+
end
|
8
|
+
feature 'without configured basemap' do
|
9
|
+
before do
|
10
|
+
CatalogController.blacklight_config.basemap_provider = nil
|
11
|
+
end
|
12
|
+
scenario 'defaults to positron' do
|
13
|
+
visit search_catalog_path(q: ' ', view: 'heatmaps', search_field: 'all_fields')
|
14
|
+
expect(page).to have_css "img[src*='light_all']"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
feature 'with alterate configured basemap' do
|
18
|
+
before do
|
19
|
+
CatalogController.blacklight_config.basemap_provider = 'darkMatter'
|
20
|
+
end
|
21
|
+
after do
|
22
|
+
CatalogController.blacklight_config.basemap_provider = 'positron'
|
23
|
+
end
|
24
|
+
scenario 'defaults to positron' do
|
25
|
+
visit search_catalog_path(q: ' ', view: 'heatmaps', search_field: 'all_fields')
|
26
|
+
expect(page).to have_css "img[src*='dark_all']"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -2,12 +2,20 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
feature 'Index page map', js: true do
|
4
4
|
it 'renders a leaflet map' do
|
5
|
-
visit search_catalog_path(q: '
|
5
|
+
visit search_catalog_path(q: ' ', view: 'heatmaps', search_field: 'all_fields')
|
6
6
|
expect(page).to have_css '.leaflet-map-pane'
|
7
|
+
|
7
8
|
# Zoomed to world
|
8
|
-
expect(page).to have_css 'img[src
|
9
|
+
expect(page).to have_css 'img[src*="/light_all/1/0/0.png"]'
|
10
|
+
|
11
|
+
# Disabled pagination
|
12
|
+
expect(page).to have_css 'ul.pagination li.disabled', count: 6
|
13
|
+
|
14
|
+
# Document counts
|
15
|
+
expect(page).to have_css '.page_links', text: '17 items found'
|
16
|
+
|
9
17
|
expect(page).to have_css '#index-map-sidebar', visible: false
|
10
|
-
page.
|
18
|
+
page.first('svg g path').click
|
11
19
|
expect(page).to have_css '#index-map-sidebar', visible: true
|
12
20
|
expect(page)
|
13
21
|
.to have_css 'h3.media-heading a', text: '"Strong Medicine speaks"'
|
@@ -5,7 +5,7 @@ feature 'Show map map', js: true do
|
|
5
5
|
visit solr_document_path '43037890'
|
6
6
|
expect(page).to have_css '.leaflet-map-pane'
|
7
7
|
# Zoomed to Kazakhstan
|
8
|
-
expect(page).to have_css 'img[src
|
8
|
+
expect(page).to have_css 'img[src*="light_all/4/11/5.png"]'
|
9
9
|
expect(page).to have_css 'svg g path'
|
10
10
|
end
|
11
11
|
it 'renders a point type' do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Blacklight::MapsHelper do
|
4
4
|
let(:blacklight_config) do
|
5
5
|
Blacklight::Configuration.new(
|
6
|
-
|
6
|
+
basemap_provider: 'positron',
|
7
7
|
geometry_field: 'geo_srpt',
|
8
8
|
index: Blacklight::OpenStructWithHashAccess.new(
|
9
9
|
title_field: 'title_display'
|
@@ -24,7 +24,7 @@ describe Blacklight::MapsHelper do
|
|
24
24
|
expect(helper.index_map_div)
|
25
25
|
.to have_css '[data-geometry-field="geo_srpt"]'
|
26
26
|
expect(helper.index_map_div)
|
27
|
-
.to have_css '[data-basemap="
|
27
|
+
.to have_css '[data-basemap-provider="positron"]'
|
28
28
|
expect(helper.index_map_div).to have_css '[data-sidebar-template]'
|
29
29
|
expect(helper.index_map_div).to have_css '[data-color-ramp]'
|
30
30
|
end
|
@@ -17,7 +17,7 @@ describe 'catalog/_show_leaflet_map_default.html.erb' do
|
|
17
17
|
locals: { document: document, blacklight_config: blacklight_config }
|
18
18
|
expect(rendered).to have_css '.blacklight-heatmaps-show-map'
|
19
19
|
expect(rendered).to have_css '#map-abc123'
|
20
|
-
expect(rendered).to have_css '[data-basemap]'
|
20
|
+
expect(rendered).to have_css '[data-basemap-provider]'
|
21
21
|
expect(rendered).to have_css '[data-show-map]'
|
22
22
|
expect(rendered).to have_css '[data-features]'
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_heatmaps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- LICENSE.txt
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
|
+
- app/assets/javascripts/blacklight_heatmaps/basemaps.js
|
169
170
|
- app/assets/javascripts/blacklight_heatmaps/blacklight_heatmaps.js
|
170
171
|
- app/assets/javascripts/blacklight_heatmaps/default.js
|
171
172
|
- app/assets/javascripts/blacklight_heatmaps/viewers/index.js
|
@@ -191,6 +192,7 @@ files:
|
|
191
192
|
- lib/generators/blacklight_heatmaps/templates/blacklight_heatmaps.js
|
192
193
|
- lib/generators/blacklight_heatmaps/templates/blacklight_heatmaps.scss
|
193
194
|
- lib/tasks/blacklight_heatmaps_tasks.rake
|
195
|
+
- spec/features/configurable_basemap_spec.rb
|
194
196
|
- spec/features/index_page_map_spec.rb
|
195
197
|
- spec/features/show_page_map_spec.rb
|
196
198
|
- spec/helpers/blacklight/maps_helper_spec.rb
|
@@ -230,6 +232,7 @@ signing_key:
|
|
230
232
|
specification_version: 4
|
231
233
|
summary: Search and view Blacklight resources on a map.
|
232
234
|
test_files:
|
235
|
+
- spec/features/configurable_basemap_spec.rb
|
233
236
|
- spec/features/index_page_map_spec.rb
|
234
237
|
- spec/features/show_page_map_spec.rb
|
235
238
|
- spec/helpers/blacklight/maps_helper_spec.rb
|