blacklight-maps 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +120 -42
- data/app/assets/javascripts/blacklight-maps.js +1 -2
- data/app/assets/javascripts/blacklight-maps/blacklight-maps-browse.js +122 -96
- data/app/assets/stylesheets/blacklight_maps/blacklight-maps.css.scss +5 -1
- data/app/assets/stylesheets/blacklight_maps/default.css.scss +74 -12
- data/app/helpers/blacklight/blacklight_maps_helper_behavior.rb +125 -0
- data/app/helpers/blacklight_maps_helper.rb +1 -24
- data/app/views/catalog/_document_maps.html.erb +1 -3
- data/app/views/catalog/_index_map.html.erb +7 -0
- data/app/views/catalog/_map_placename_search.html.erb +8 -0
- data/app/views/catalog/_map_spatial_search.html.erb +6 -0
- data/app/views/catalog/_show_maplet_default.html.erb +11 -0
- data/app/views/catalog/map.html.erb +8 -0
- data/blacklight-maps.gemspec +1 -2
- data/config/locales/blacklight-maps.en.yml +17 -1
- data/config/routes.rb +2 -2
- data/docs/blacklight-maps_index-view.png +0 -0
- data/docs/blacklight-maps_map-view.png +0 -0
- data/docs/blacklight-maps_search-control.png +0 -0
- data/docs/blacklight-maps_show-view.png +0 -0
- data/lib/blacklight/maps.rb +16 -0
- data/lib/blacklight/maps/controller_override.rb +33 -0
- data/lib/blacklight/maps/engine.rb +14 -6
- data/lib/blacklight/maps/export.rb +102 -61
- data/lib/blacklight/maps/render_constraints_override.rb +62 -0
- data/lib/blacklight/maps/version.rb +1 -1
- data/lib/generators/blacklight_maps/templates/blacklight_maps.css.scss +1 -1
- data/solr_conf/conf/schema.xml +4 -1
- data/spec/controllers/catalog_controller_spec.rb +22 -0
- data/spec/features/maps_spec.rb +194 -61
- data/spec/fixtures/sample_solr_documents.yml +73 -72
- data/spec/helpers/blacklight_maps_helper_spec.rb +134 -12
- data/spec/lib/blacklight/maps/controller_override_spec.rb +34 -0
- data/spec/lib/blacklight/maps/export_spec.rb +178 -35
- data/spec/lib/blacklight/maps/render_constraints_override_spec.rb +95 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +0 -2
- metadata +22 -21
- data/app/views/catalog/_index_maps.html.erb +0 -9
- data/docs/map-sidebar.png +0 -0
- data/docs/map-view.png +0 -0
@@ -9,12 +9,17 @@ module BlacklightMaps
|
|
9
9
|
include BlacklightMaps
|
10
10
|
|
11
11
|
# controller is a Blacklight CatalogController object passed by a helper
|
12
|
-
#
|
13
|
-
|
12
|
+
# action is the controller action
|
13
|
+
# response_docs is passed by a helper, and is either:
|
14
|
+
# - index view, map view: an array of facet values
|
15
|
+
# - show view: the document object
|
16
|
+
def initialize(controller, action, response_docs)
|
14
17
|
@controller = controller
|
18
|
+
@action = action
|
15
19
|
@response_docs = response_docs
|
16
20
|
end
|
17
21
|
|
22
|
+
# build the GeoJSON FeatureCollection
|
18
23
|
def to_geojson
|
19
24
|
geojson_docs = { type: 'FeatureCollection',
|
20
25
|
features: build_geojson_features }
|
@@ -27,85 +32,121 @@ module BlacklightMaps
|
|
27
32
|
@controller.blacklight_config.view.maps
|
28
33
|
end
|
29
34
|
|
30
|
-
def
|
31
|
-
blacklight_maps_config.
|
35
|
+
def geojson_field
|
36
|
+
blacklight_maps_config.geojson_field
|
32
37
|
end
|
33
38
|
|
34
|
-
def
|
35
|
-
blacklight_maps_config.
|
39
|
+
def coordinates_field
|
40
|
+
blacklight_maps_config.coordinates_field
|
36
41
|
end
|
37
42
|
|
38
|
-
def
|
39
|
-
blacklight_maps_config.
|
43
|
+
def search_mode
|
44
|
+
blacklight_maps_config.search_mode
|
40
45
|
end
|
41
46
|
|
42
|
-
def
|
43
|
-
blacklight_maps_config.
|
47
|
+
def facet_mode
|
48
|
+
blacklight_maps_config.facet_mode
|
44
49
|
end
|
45
50
|
|
46
|
-
def
|
47
|
-
|
48
|
-
when 'placename_coord'
|
49
|
-
build_placename_coord_features
|
50
|
-
when 'bbox'
|
51
|
-
build_bbox_features
|
52
|
-
else
|
53
|
-
Rails.logger.error("Your Solr field type was not configured with a recognized type, '#{type}' is not yet supported")
|
54
|
-
end
|
51
|
+
def placename_property
|
52
|
+
blacklight_maps_config.placename_property
|
55
53
|
end
|
56
54
|
|
57
|
-
#
|
58
|
-
|
55
|
+
# build GeoJSON features array
|
56
|
+
# determine how to build GeoJSON feature based on config and controller#action
|
57
|
+
def build_geojson_features
|
59
58
|
features = []
|
60
|
-
@
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
case @action
|
60
|
+
when "index", "map"
|
61
|
+
@response_docs.each do |geofacet|
|
62
|
+
if facet_mode == "coordinates"
|
63
|
+
features.push(build_feature_from_coords(geofacet.value, geofacet.hits))
|
64
|
+
else
|
65
|
+
features.push(build_feature_from_geojson(geofacet.value, geofacet.hits))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
when "show"
|
69
|
+
doc = @response_docs
|
70
|
+
return unless doc[geojson_field] || doc[coordinates_field]
|
71
|
+
if doc[geojson_field]
|
72
|
+
doc[geojson_field].uniq.each do |loc|
|
73
|
+
features.push(build_feature_from_geojson(loc))
|
74
|
+
end
|
75
|
+
elsif doc[coordinates_field]
|
76
|
+
doc[coordinates_field].uniq.each do |coords|
|
77
|
+
features.push(build_feature_from_coords(coords))
|
78
|
+
end
|
79
|
+
end
|
69
80
|
end
|
70
81
|
features
|
71
82
|
end
|
72
83
|
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
html: render_leaflet_sidebar_partial(doc)))
|
83
|
-
end
|
84
|
+
# build blacklight-maps GeoJSON feature from GeoJSON-formatted data
|
85
|
+
# turn bboxes into points for index view so we don't get weird mix of boxes and markers
|
86
|
+
def build_feature_from_geojson(loc, hits = nil)
|
87
|
+
geojson_hash = JSON.parse(loc).deep_symbolize_keys
|
88
|
+
|
89
|
+
if @action != "show" && geojson_hash[:bbox]
|
90
|
+
geojson_hash[:geometry][:coordinates] = Geometry::BoundingBox.new(geojson_hash[:bbox]).find_center
|
91
|
+
geojson_hash[:geometry][:type] = "Point"
|
92
|
+
geojson_hash.delete(:bbox)
|
84
93
|
end
|
85
|
-
|
94
|
+
geojson_hash[:properties] ||= {}
|
95
|
+
geojson_hash[:properties][:hits] = hits.to_i if hits
|
96
|
+
geojson_hash[:properties][:popup] = render_leaflet_popup_content(geojson_hash, hits)
|
97
|
+
geojson_hash
|
86
98
|
end
|
87
99
|
|
88
|
-
#
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
# build blacklight-maps GeoJSON feature from coordinate data
|
101
|
+
# turn bboxes into points for index view so we don't get weird mix of boxes and markers
|
102
|
+
def build_feature_from_coords(coords, hits = nil)
|
103
|
+
geojson_hash = {type: "Feature", geometry: {}, properties: {}}
|
104
|
+
if coords.scan(/[\s]/).length == 3 # bbox
|
105
|
+
if @action != "show"
|
106
|
+
geojson_hash[:geometry][:type] = "Point"
|
107
|
+
geojson_hash[:geometry][:coordinates] = Geometry::BoundingBox.from_lon_lat_string(coords).find_center
|
108
|
+
else
|
109
|
+
coords_array = coords.split(' ').map { |v| v.to_f }
|
110
|
+
geojson_hash[:bbox] = coords_array
|
111
|
+
geojson_hash[:geometry][:type] = "Polygon"
|
112
|
+
geojson_hash[:geometry][:coordinates] = [[[coords_array[0],coords_array[1]],
|
113
|
+
[coords_array[2],coords_array[1]],
|
114
|
+
[coords_array[2],coords_array[3]],
|
115
|
+
[coords_array[0],coords_array[3]],
|
116
|
+
[coords_array[0],coords_array[1]]]]
|
117
|
+
end
|
118
|
+
elsif coords.match(/^[-]?[\d]*[\.]?[\d]*[ ,][-]?[\d]*[\.]?[\d]*$/) # point
|
119
|
+
geojson_hash[:geometry][:type] = "Point"
|
120
|
+
if coords.match(/,/)
|
121
|
+
coords_array = coords.split(',').reverse
|
122
|
+
else
|
123
|
+
coords_array = coords.split(' ')
|
124
|
+
end
|
125
|
+
geojson_hash[:geometry][:coordinates] = coords_array.map { |v| v.to_f }
|
126
|
+
else
|
127
|
+
Rails.logger.error("This coordinate format is not yet supported: '#{coords}'")
|
128
|
+
end
|
129
|
+
geojson_hash[:properties] = { popup: render_leaflet_popup_content(geojson_hash, hits) } if geojson_hash[:geometry][:coordinates]
|
130
|
+
geojson_hash[:properties][:hits] = hits.to_i if hits
|
131
|
+
geojson_hash
|
92
132
|
end
|
93
133
|
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
feature
|
134
|
+
# Render to string the partial for each individual doc.
|
135
|
+
# For placename searching, render catalog/map_placename_search partial,
|
136
|
+
# full geojson hash is passed to the partial for easier local customization
|
137
|
+
# For coordinate searches (or features with only coordinate data),
|
138
|
+
# render catalog/map_coordinate_search partial
|
139
|
+
def render_leaflet_popup_content(geojson_hash, hits=nil)
|
140
|
+
if search_mode == 'placename' && geojson_hash[:properties][placename_property.to_sym]
|
141
|
+
@controller.render_to_string partial: 'catalog/map_placename_search',
|
142
|
+
locals: { geojson_hash: geojson_hash, hits: hits }
|
143
|
+
else
|
144
|
+
@controller.render_to_string partial: 'catalog/map_spatial_search',
|
145
|
+
locals: { coordinates: geojson_hash[:bbox].presence || geojson_hash[:geometry][:coordinates],
|
146
|
+
hits: hits }
|
147
|
+
end
|
109
148
|
end
|
149
|
+
|
110
150
|
end
|
151
|
+
|
111
152
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Meant to be applied on top of Blacklight view helpers, to over-ride
|
2
|
+
# certain methods from RenderConstraintsHelper (newish in BL),
|
3
|
+
# to affect constraints rendering
|
4
|
+
module BlacklightMaps
|
5
|
+
|
6
|
+
module RenderConstraintsOverride
|
7
|
+
|
8
|
+
# BlacklightMaps override: update to look for spatial query params
|
9
|
+
def has_search_parameters?
|
10
|
+
has_spatial_parameters? || super
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_spatial_parameters?
|
14
|
+
!params[:coordinates].blank?
|
15
|
+
end
|
16
|
+
|
17
|
+
# BlacklightMaps override: check for coordinate parameters
|
18
|
+
def query_has_constraints?(localized_params = params)
|
19
|
+
has_search_parameters? || super
|
20
|
+
end
|
21
|
+
|
22
|
+
# BlacklightMaps override: include render_spatial_query() in rendered constraints
|
23
|
+
def render_constraints(localized_params = params)
|
24
|
+
render_spatial_query(localized_params) + super
|
25
|
+
end
|
26
|
+
|
27
|
+
# BlacklightMaps override: include render_search_to_s_coord() in rendered constraints
|
28
|
+
# Simpler textual version of constraints, used on Search History page.
|
29
|
+
def render_search_to_s(params)
|
30
|
+
render_search_to_s_coord(params) + super
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Render the search query constraint
|
35
|
+
def render_search_to_s_coord(params)
|
36
|
+
return "".html_safe if params[:coordinates].blank?
|
37
|
+
render_search_to_s_element(spatial_constraint_label(params), render_filter_value(params[:coordinates]) )
|
38
|
+
end
|
39
|
+
|
40
|
+
# Render the spatial query constraints
|
41
|
+
def render_spatial_query(localized_params = params)
|
42
|
+
# So simple don't need a view template, we can just do it here.
|
43
|
+
scope = localized_params.delete(:route_set) || self
|
44
|
+
return ''.html_safe if localized_params[:coordinates].blank?
|
45
|
+
|
46
|
+
render_constraint_element(spatial_constraint_label(localized_params),
|
47
|
+
localized_params[:coordinates],
|
48
|
+
:classes => ['coordinates'],
|
49
|
+
:remove => scope.url_for(localized_params.merge(:coordinates=>nil,
|
50
|
+
:spatial_search_type=>nil,
|
51
|
+
:action=>'index')))
|
52
|
+
end
|
53
|
+
|
54
|
+
def spatial_constraint_label(params)
|
55
|
+
(params[:spatial_search_type] && params[:spatial_search_type] == 'bbox') ?
|
56
|
+
t('blacklight.search.filters.coordinates.bbox') :
|
57
|
+
t('blacklight.search.filters.coordinates.point')
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/solr_conf/conf/schema.xml
CHANGED
@@ -534,7 +534,10 @@
|
|
534
534
|
<field name="format" type="string" indexed="true" stored="true"/>
|
535
535
|
|
536
536
|
<!-- addition -->
|
537
|
-
<field name="
|
537
|
+
<field name="geojson" type="string" indexed="true" stored="true" multiValued="true"/>
|
538
|
+
<field name="coordinates" type="location_rpt" stored="true" indexed="true" multiValued="true"/>
|
539
|
+
<!-- copy coordinates to string field for faceting -->
|
540
|
+
<copyField source="coordinates" dest="coordinates_facet" />
|
538
541
|
|
539
542
|
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
|
540
543
|
will be used if the name matches any of the patterns.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CatalogController do
|
4
|
+
|
5
|
+
render_views
|
6
|
+
|
7
|
+
describe "GET 'map'" do
|
8
|
+
|
9
|
+
before { get :map }
|
10
|
+
|
11
|
+
it "should respond to the #map action" do
|
12
|
+
response.should be_success
|
13
|
+
assigns(:document_list).should_not be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should render the '/map' page" do
|
17
|
+
response.body.should have_selector("body.blacklight-catalog-map")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/spec/features/maps_spec.rb
CHANGED
@@ -2,111 +2,244 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Map View", js: true do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
before :each do
|
6
|
+
CatalogController.blacklight_config = Blacklight::Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "catalog#index and catalog#map views" do
|
10
|
+
|
11
|
+
describe "catalog#index map view" do
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
CatalogController.configure_blacklight do |config|
|
15
|
+
# use geojson facet for blacklight-maps catalog#index map view specs
|
16
|
+
config.add_facet_field 'geojson', :limit => -2, :label => 'GeoJSON', :show => false
|
17
|
+
config.add_facet_fields_to_solr_request!
|
18
|
+
end
|
19
|
+
visit catalog_index_path :q => 'korea', :view => 'maps'
|
14
20
|
end
|
15
|
-
end
|
16
21
|
|
17
|
-
|
22
|
+
it "should display map elements" do
|
23
|
+
expect(page).to have_selector("#documents.map")
|
24
|
+
expect(page).to have_selector("#blacklight-index-map")
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
expect(page).to have_selector("#blacklight-map-sidebar")
|
23
|
-
end
|
27
|
+
it "should display tile layer attribution" do
|
28
|
+
expect(find("div.leaflet-control-container")).to have_content('OpenStreetMap contributors, CC-BY-SA')
|
29
|
+
end
|
24
30
|
|
25
|
-
|
31
|
+
describe "#sortAndPerPage" do
|
32
|
+
|
33
|
+
it "should show the mapped item count" do
|
34
|
+
expect(page).to have_selector(".mapped-count .badge", text: "4")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should show the mapped item caveat" do
|
38
|
+
expect(page).to have_selector(".mapped-caveat")
|
39
|
+
end
|
40
|
+
|
41
|
+
# TODO: placeholder spec: #sortAndPerPage > .view-type > .view-type-group
|
42
|
+
# should show active map icon. however, this spec doesn't work because
|
43
|
+
# Blacklight::ConfigurationHelperBehavior#has_alternative_views? returns false,
|
44
|
+
# so catalog/_view_type_group partial renders no content, can't figure out why
|
45
|
+
it "should show the map view icon" #do
|
46
|
+
#expect(page).to have_selector(".view-type-maps.active")
|
47
|
+
#end
|
26
48
|
|
27
|
-
it "maxzoom should be 8" do
|
28
|
-
expect(page).to have_selector("#blacklight-map[data-maxzoom='8']")
|
29
49
|
end
|
30
50
|
|
31
|
-
|
32
|
-
|
51
|
+
describe "data attributes" do
|
52
|
+
|
53
|
+
it "maxzoom should be from config" do
|
54
|
+
expect(page).to have_selector("#blacklight-index-map[data-maxzoom='#{CatalogController.blacklight_config.view.maps.maxzoom}']")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "tileurl should be from config" do
|
58
|
+
expect(page).to have_selector("#blacklight-index-map[data-tileurl='#{CatalogController.blacklight_config.view.maps.tileurl}']")
|
59
|
+
end
|
60
|
+
|
33
61
|
end
|
34
62
|
|
35
|
-
|
36
|
-
|
63
|
+
describe "marker clusters" do
|
64
|
+
|
65
|
+
before {
|
66
|
+
0.upto(2) { find("a.leaflet-control-zoom-out").click } # zoom out to create cluster
|
67
|
+
}
|
68
|
+
|
69
|
+
it "should have marker cluster div" do
|
70
|
+
expect(page).to have_selector("div.marker-cluster")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should only have one marker cluster" do
|
74
|
+
expect(page).to have_selector("div.marker-cluster", count: 1)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should show the result count" do
|
78
|
+
expect(find("div.marker-cluster")).to have_content(4)
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "click marker cluster" do
|
82
|
+
|
83
|
+
before { find("div.marker-cluster").click }
|
84
|
+
|
85
|
+
it "should split into two marker clusters" do
|
86
|
+
expect(page).to have_selector("div.marker-cluster", count: 2)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
37
91
|
end
|
38
92
|
|
39
|
-
|
93
|
+
describe "marker popups" do
|
40
94
|
|
41
|
-
|
95
|
+
before { find(".marker-cluster:first-child").click }
|
96
|
+
|
97
|
+
it "should show a popup with correct content" do
|
98
|
+
expect(page).to have_selector("div.leaflet-popup-content-wrapper")
|
99
|
+
expect(page).to have_content("Seoul (Korea)")
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "click search link" do
|
103
|
+
|
104
|
+
before { find("div.leaflet-popup-content a").click }
|
105
|
+
|
106
|
+
it "should run a new search" do
|
107
|
+
expect(page).to have_selector(".constraint-value .filterValue", text: "Seoul (Korea)")
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
42
111
|
|
43
|
-
it "should have marker cluster div" do
|
44
|
-
expect(page).to have_selector("div.marker-cluster")
|
45
112
|
end
|
46
113
|
|
47
|
-
|
48
|
-
|
114
|
+
describe "map search control" do
|
115
|
+
|
116
|
+
it "should have a search control" do
|
117
|
+
expect(page).to have_selector(".leaflet-control .search-control")
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "search control hover" do
|
121
|
+
|
122
|
+
before { find(".search-control").hover }
|
123
|
+
|
124
|
+
it "should add a border to the map" do
|
125
|
+
expect(page).to have_selector(".leaflet-overlay-pane path")
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "search control click" do
|
131
|
+
|
132
|
+
before { find(".search-control").click }
|
133
|
+
|
134
|
+
it "should run a new search" do
|
135
|
+
expect(page).to have_selector(".constraint.coordinates")
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
49
140
|
end
|
50
141
|
|
51
|
-
|
52
|
-
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "catalog#map view" do
|
145
|
+
|
146
|
+
before :each do
|
147
|
+
CatalogController.configure_blacklight do |config|
|
148
|
+
# use coordinates_facet facet for blacklight-maps catalog#map view specs
|
149
|
+
config.view.maps.facet_mode = 'coordinates'
|
150
|
+
config.view.maps.coordinates_facet_field = 'coordinates_facet'
|
151
|
+
config.add_facet_field 'coordinates_facet', :limit => -2, :label => 'Coordinates', :show => false
|
152
|
+
config.add_facet_fields_to_solr_request!
|
153
|
+
end
|
154
|
+
visit map_path
|
155
|
+
#print page.html # debugging
|
53
156
|
end
|
54
157
|
|
55
|
-
it "should display
|
56
|
-
expect(
|
158
|
+
it "should display map elements" do
|
159
|
+
expect(page).to have_selector("#documents.map")
|
160
|
+
expect(page).to have_selector("#blacklight-index-map")
|
57
161
|
end
|
58
162
|
|
59
|
-
|
60
|
-
|
163
|
+
it "should display some markers" do
|
164
|
+
expect(page).to have_selector("div.marker-cluster")
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "marker popups" do
|
61
168
|
|
62
|
-
|
63
|
-
|
169
|
+
before :each do
|
170
|
+
0.upto(1) { find("a.leaflet-control-zoom-in").click } # zoom in
|
171
|
+
find(".marker-cluster:first-child").click
|
64
172
|
end
|
65
173
|
|
66
|
-
|
67
|
-
|
174
|
+
it "should show a popup with correct content" do
|
175
|
+
expect(page).to have_selector("div.leaflet-popup-content-wrapper")
|
176
|
+
expect(page).to have_content("[35.86166, 104.195397]")
|
177
|
+
end
|
68
178
|
|
69
|
-
|
70
|
-
expect(page).to have_content("es yon")
|
71
|
-
end
|
179
|
+
describe "click search link" do
|
72
180
|
|
73
|
-
|
74
|
-
before { click_link("es yon") }
|
181
|
+
before { find("div.leaflet-popup-content a").click }
|
75
182
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
183
|
+
it "should run a new search" do
|
184
|
+
expect(page).to have_selector(".constraint-value .filterValue", text: "35.86166,104.195397")
|
79
185
|
end
|
186
|
+
|
80
187
|
end
|
188
|
+
|
81
189
|
end
|
190
|
+
|
82
191
|
end
|
192
|
+
|
83
193
|
end
|
84
194
|
|
85
|
-
describe "
|
86
|
-
|
87
|
-
|
195
|
+
describe "catalog#show maplet view" do
|
196
|
+
|
197
|
+
before :each do
|
88
198
|
CatalogController.configure_blacklight do |config|
|
89
|
-
|
90
|
-
config.
|
199
|
+
# add maplet to show partials
|
200
|
+
config.show.partials << :show_maplet
|
91
201
|
end
|
202
|
+
visit catalog_path('2008308175')
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should show the maplet" do
|
206
|
+
expect(page).to have_selector("#blacklight-show-map")
|
92
207
|
end
|
93
208
|
|
94
|
-
|
209
|
+
it "should show the mapped item count" do
|
210
|
+
expect(page).to have_selector(".mapped-count .badge", text: "2")
|
211
|
+
end
|
95
212
|
|
96
|
-
it "should
|
97
|
-
expect(
|
213
|
+
it "should show a bounding box and a point marker" do
|
214
|
+
expect(page).to have_selector(".leaflet-overlay-pane path.leaflet-clickable")
|
215
|
+
expect(page).to have_selector(".leaflet-marker-icon")
|
98
216
|
end
|
99
217
|
|
100
|
-
|
101
|
-
|
218
|
+
describe "click marker icon" do
|
219
|
+
|
220
|
+
before { find(".leaflet-marker-icon").click }
|
221
|
+
|
222
|
+
it "should show a popup with correct content" do
|
223
|
+
expect(page).to have_selector("div.leaflet-popup-content-wrapper")
|
224
|
+
expect(page).to have_content("India")
|
225
|
+
end
|
226
|
+
|
102
227
|
end
|
103
228
|
|
104
|
-
describe "click
|
105
|
-
before { find("div.marker-cluster").click }
|
229
|
+
describe "click bbox path" do
|
106
230
|
|
107
|
-
|
108
|
-
|
231
|
+
before do
|
232
|
+
0.upto(4) { find("a.leaflet-control-zoom-in").click } #so bbox not covered by point
|
233
|
+
find(".leaflet-overlay-pane svg").click
|
109
234
|
end
|
235
|
+
|
236
|
+
it "should show a popup with correct content" do
|
237
|
+
expect(page).to have_selector("div.leaflet-popup-content-wrapper")
|
238
|
+
expect(page).to have_content("[68.162386, 6.7535159, 97.395555, 35.5044752]")
|
239
|
+
end
|
240
|
+
|
110
241
|
end
|
242
|
+
|
111
243
|
end
|
244
|
+
|
112
245
|
end
|