Blacklight::Maps
Provides a map view for Blacklight search results.
Installation
Add this line to your application's Gemfile:
gem 'blacklight-maps'
And then execute:
$ bundle
Or install it yourself as:
$ gem install blacklight-maps
Run Blacklight-Maps generator:
$ rails g blacklight_maps:install
Usage
Blacklight-Maps adds a map view capability for a results set that contains geospatial coordinates (latitude/longitude).
For now, Blacklight-Maps requires that your Solr index include one of the following two types of fields:
A
location_rpt
field that contains a bounding box for the document. For more onlocation_rpt
see Solr help. This field can be multivalued.place_bbox: 44.0318907 25.0594286 63.3333366 39.7816755 # minX minY maxX maxY
A field containing placenames with latitude and longitude coordinates delimited by
-|-
. The delimiter can be configured inapp/controllers/catalog_controller.rb
. This field can be multivalued.placename_coords: - China-|-35.86166-|-104.195397 - Tibet-|-29.646923-|-91.117212 - India-|-20.593684-|-78.96288
Note: We are looking at implementing support for additional fields.
Configuration
Required
Blacklight-Maps expects you to provide:
- the type of location field you are using,
placename_coord
orbbox
(bbox
is default) - a field to map the placename coordinates or bbox field
Optional
- the maxZoom property of the map
- a tileLayer url to change the basemap
- an attribution string to describe the basemap layer
- a custom delimiter field (used to delimit placename_coord values)
All of these options can easily be configured in CatalogController.rb
in the config
block.
...
configure_blacklight do |config|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
config.default_solr_params = {
:qt => 'search',
:rows => 10,
:fl => '*'
}
## Default values
config.view.maps.type = "bbox" # also accepts 'placename_coord' to use the placename coordinate type
config.view.maps.bbox_field = "place_bbox"
config.view.maps.placename_coord_field = "placename_coords"
config.view.maps.tileurl = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
config.view.maps.attribution = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
config.view.maps.placename_coord_delimiter = '-|-'
...
Contributing
- Fork it ( http://github.com/
/blacklight-maps/fork ) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request