projectblacklight / blacklight-maps Goto Github PK
View Code? Open in Web Editor NEWMap search results view for Blacklight
License: Other
Map search results view for Blacklight
License: Other
I think we could push some of this logic into the document, using the "Document Extensibility Framework" to add an #export_as_geojson.
I was hoping to implement a new map interface using blacklight-maps to replace this interface: http://d.lib.ncsu.edu/collections/map
I already have a lat and a lng field stored in Solr and would like to use those fields instead of reindexing everything with new fields. This appears to not be possible at this time.
To give our consumers additional flexibility, I'd adjust this method signature to something like:
def blacklight_map_tag id, tag_options = {}, &block
...
content_tag(:div, { id: id data: ...}.deep_merge(tag_options), &block)
end
This (sorta) mirrors the regular #content_tag
signature, and allows the caller to add additional attributes and the like to this div.
I tried to set the initialview property in my CatalogController:
config.view.maps.initialview = [[27.741885,-96.987305],[37.874853,-71.279297]]
But that didn't take. So I looked around and saw that the data attribute wasn't being set like the other config settings were:
From _index_mapview.html.erb
<%= blacklight_map_tag('blacklight-index-map', {data:{searchcontrol: true, catalogpath: search_catalog_path, placenamefield: blacklight_config.view.maps.placename_field, clustercount:'hits', searchresultsview: default_document_index_view_type }}) %>
So I added the initalview to the data hash
<%= blacklight_map_tag('blacklight-index-map', {data:{searchcontrol: true, catalogpath: search_catalog_path, placenamefield: blacklight_config.view.maps.placename_field, clustercount:'hits', searchresultsview: default_document_index_view_type, initialview: blacklight_config.view.maps.initialview }}) %>
...and changed the config value to a string rather than an array...
config.view.maps.initialview = '[[27.741885,-96.987305],[37.874853,-71.279297]]'
And the config setting now works as expected.
Perhaps I am missing something, but I thought it would be helpful to point this out!
I ran in to issues installing on a new Rails 5 app. It seems the leaflet-markercluster-rails
gem does not yet work with Rails 5. See this PR on that repo which should address the issue
Until that fix is in place, I've make things work by including the JS from leaflet-markercluster
in my assets after the blacklight-maps
include.
To fix a deprecation warning:
DEPRECATION WARNING: facet_by_field_name is deprecated
and will be removed from a future release (use aggregations instead).
(called from map_facet_values at /blacklight-maps/app/helpers/blacklight/blacklight_maps_helper_behavior.rb:65)
The blacklight dependency for this fix must be >= 5.12, since the aggregations
method was introduced with this release.
I would propose using the AirBnb Javascript style guide:
https://github.com/airbnb/javascript
Thoughts?
We're currently light on unit tests for the BlacklightMapsHelper
file.
I don't see where we're using the index counter. Maybe it's vestigial?
We can also use #map
to create the features array directly, e.g.:
{type: "FeatureCollection", features: @response.docs.map { |doc| ... }.compact }.to_json
When updating tests, this method appears to be doing just too much. Perhaps this should be a class itself?
Are there ways we can make the installation easier for users by providing automatic configuration using a rake task?
Remove hardcoded var mapWidth = $('#blacklight-map').width();
There is an issue with setMapBounds()
in blacklight-maps-browse.js
where the bounds are set to the default ([[90, 180], [-90, -180]]
) if the only item in the GeoJSON FeatureCollection is a bounding box, rather than setting the bounds to the dimensions of the bbox.
Incorrect bounds for bbox only:
This is because markers._featureGroup._layers
(https://github.com/projectblacklight/blacklight-maps/blob/master/app/assets/javascripts/blacklight-maps/blacklight-maps-browse.js#L185) returns an empty object when the only item is a bounding box (which is definitely a bit surprising), so hasAnyFeatures()
returns false.
Would suggest either:
hasAnyFeatures()
to return true if there is a bounding box object/layer to display, or . . .mapBounds()
(https://github.com/projectblacklight/blacklight-maps/blob/master/app/assets/javascripts/blacklight-maps/blacklight-maps-browse.js#L162) to return Leaflet's markers.getBounds()
function, which will set the correct bounds if there are markers/bboxes to display (even a single bbox), or if there are no markers, returns a center point or bounds that provides the classic mid-Atlantic-centered map view (see screenshot below).Default bounds returned by getBounds()
when there are no features:
B is probably the easier solution, but A could easily be done if we want to preserve the [[90, 180], [-90, -180]]
default bounds feature. Something like this seems to work:
/**
* Checks to see if there are any features in the markers MarkerClusterGroup
*/
function hasAnyFeatures() {
var has_features = false;
markers.eachLayer(function (layer) {
if (!$.isEmptyObject(layer)) {
has_features = true;
}
});
return has_features;
}
I'm updating sul-dlss/spotlight-maps_of_africa (which uses the placename_coords feature). I've added configuration like this:
config.view.maps.type = "placename_coords"
config.view.maps.placename_coord_field = 'placename_coords_ssim'
But when I go to the map view, I get this js error:
Uncaught Error: Invalid GeoJSON object. leaflet.js?body=1:6224
L.extend.geometryToLayer leaflet.js?body=1:6224
L.GeoJSON.L.FeatureGroup.extend.addData leaflet.js?body=1:6133
L.GeoJSON.L.FeatureGroup.extend.initialize leaflet.js?body=1:6110
L.Class.extend.NewClass leaflet.js?body=1:230
L.geoJson leaflet.js?body=1:6382
(anonymous function) blacklight-maps-browse.js?body=1:44
jQuery.extend.each
geometry.type // => "FeatureCollection"
Any ideas?
E.g.
$("[data-blacklight-map]").blacklight_leaflet_map();
$.fn.blacklight_leaflet_map = function(arg_opts) {
this.each(function() {
L.map(this.id)...
}
}
Due to some substantial changes with rendering constraints in Blacklight 7.8, it makes sense to have separate versions of blacklight-maps to support compatibility with pre/post 7.8 blacklight.
The v1.1.0 release supports >= 7.8.
We need make a release for >=7.0, < 7.8, which should be tagged as v1.0.0.
This should be fairly easy, almost all the v1.1.0 code should work, except for a few methods in RenderConstraintsOverride
that will need to be tweaked.
In catalog#index and catalog#map views, bboxes are displayed as points. It would be cool if when the user hovers over a point that's from a bbox, the bounds are shown. (Similar to how clusters show bounds on hover.)
Not sure to what extent this is possible with current Leaflet or Leaflet MarkerCluster methods/config settings.
Potentially use .send rather than making them public
This would be more in-line with what the Leaflet community does.
Support for LonLat solr field types should be created. See http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
This might be useful. As a Spotlight curator, I might not want the placenames "Africa" and "Africa--Maps" to appear mapped because I know the geocodes are not very good.
I think/hope the render_leaflet_sidebar_partial call can be replaced with something like:
render_to_string(doc) # not sure if render_to_string supports this short-hand.. but it'd be awfully nice if it did.
Obviously, if we delegate most of the geojson to the model, we'll have to have some way to pass or merge the html into the block..
Is there some sample data that I can import into my dev SOLR instance for development purposes?
For example:
"id": "sq609fm6426",
...
"placename_coords_ssim": [
"Africa--Maps-|--1.283113-|-36.818225",
"Egypt-|-26.820553-|-30.802498",
"Egypt-|-26.820553-|-30.802498"
],
is given 3 markers to the map, 2 of them are identical.
config as an array
Need to change the translation file config/locales/blacklight-maps.en.yml
to include the application name in the page title for catalog#map view, like so:
en:
blacklight:
maps:
title: 'Map - %{application_name}'
As an institution I already have coordinates and bbox indexed in location_rpt fields, I want to be able to display and filter this on a map.
To comply with deprecation warnings caused by Blacklight 5.10.* about building search params by calling methods directly on CatalogController
.
Beginning with this fix, we may need to start indicating in the documentation which versions of blacklight-maps work with which versions of Blacklight. The dependency should of course be set in blacklight-maps.gemspec
, but some info in the README might be useful for implementers.
When attempting to use blacklight-maps v0.4.0 with blacklight >= 5.16.0, you get an error uninitialized constant Blacklight::Configuration (NameError)
when starting your application.
Here's the full trace:
/home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps/engine.rb:9:in `<class:Engine>': uninitialized constant Blacklight::Configuration (NameError)
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps/engine.rb:7:in `<module:Maps>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps/engine.rb:6:in `<module:Blacklight>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps/engine.rb:5:in `<top (required)>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps.rb:7:in `require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps.rb:7:in `<module:Maps>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps.rb:4:in `<module:Blacklight>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/blacklight-maps-0.4.0/lib/blacklight/maps.rb:3:in `<top (required)>'
from /home/username/boston-library/commonwealth-vlr-engine/lib/commonwealth-vlr-engine/engine.rb:4:in `require'
from /home/username/boston-library/commonwealth-vlr-engine/lib/commonwealth-vlr-engine/engine.rb:4:in `<top (required)>'
from /home/username/boston-library/commonwealth-vlr-engine/lib/commonwealth-vlr-engine.rb:1:in `require'
from /home/username/boston-library/commonwealth-vlr-engine/lib/commonwealth-vlr-engine.rb:1:in `<top (required)>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
from /home/username/boston-library/Commonwealth-public-interface/config/application.rb:5:in `<top (required)>'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/username/.rvm/gems/ruby-2.2.1/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
Blacklight::Maps::Engine
attempts to set some default configuration settings, which is what causes the error.
(In 5.16.0, the Blacklight::Configuration
module was moved to app/models/blacklight/configuration.rb
.)
There may be other issues related to using Blacklight >= 5.16.0, but this one is a major blocker to further work on bringing this project up to date with Blacklight 6.
@mejackreed @cbeer any ideas on where to move the default configuration stuff?
When I am on a page with a map (catalog#map, catalog#index map view, etc.)
And I click on a coordinate point or use the search tool on the map
I should see the coordinate search constraints in the page title in the browser window
Blacklight::CatalogHelperBehavior#render_search_to_page_title
(from projectblacklight/blacklight@47eab51) adds functionality to display search constraints in the page title on catalog#index views. Coordinate search constraints are not displayed, since there is no provision in that method to display them.
We need to add methods to BlacklightMaps::RenderConstraintsOverride
to add functionality to include coordinate constraints in the page title.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.