Skip to content

Commit

Permalink
Prepare for timeline rendering in maps show views (refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ut committed May 1, 2024
1 parent bcf5472 commit 7c801a1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Metrics/CyclomaticComplexity:
Exclude:
- app/helpers/application_helper.rb
- app/controllers/layers_controller.rb
- app/controllers/maps_controller.rb


Metrics/MethodLength:
Enabled: false
Expand Down
11 changes: 9 additions & 2 deletions app/assets/javascripts/helpers/timeslider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@


jQuery(function ($) {



function filterMarkers(selectedYear) {

// markers.forEach(function(marker) {
console.log("filterMarkers **************");
console.log(marker_layers);
}
// for a single slider, used in places index
$(document).on('changed.zf.slider', '[data-slider]', function(event) {
var $slider = $(event.currentTarget);
var $numberInput = $slider.children('input');
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/layers.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function ShowPlacesForLayer(map,text_layers,image_layers,marker_meta_layers,curv

if ( marker_display_mode == 'single' ) {
marker_layers = L.featureGroup();
window.markers_layer = L.featureGroup();
} else {
marker_layers = L.markerClusterGroup(markerclusterSettings);
}
Expand Down Expand Up @@ -187,7 +188,9 @@ function ShowPlacesForLayer(map,text_layers,image_layers,marker_meta_layers,curv
});

}

console.log('******************************');
console.log(window.markers_layer)

var layer_style = '';
$.each(data.layers, function(key,data) {
layer_style += "#map .marker-cluster-layer-" + data.id;
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/markers/draw_markers.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ function drawMarkers(map,layer_id,layer_type,level,show_annotations_on_map,text_
marker_layers.addLayer(marker);
text_layers.addLayer(textmarker);
// text_layers.addLayer(marker);
} else {
window.markers_layer.addLayer(marker);
}

var content = (place.layer_type == 'standard') ? PopupFullContent(place) : PopupImageOnlyContent(place);
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/maps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ def index
# GET /maps/1.json
def show
@maps = Map.sorted.by_user(current_user)

if @map
@map_layers = @map.layers

@places = @map_layers.flat_map(&:places)
# timeline calculation, for now on a yearly basis
@minyear = @places.reject { |place| place.startdate.nil? }.min_by { |place| place.startdate.year }&.startdate&.year || Date.today.year
@maxyear = @places.reject { |place| place.enddate.nil? }.max_by { |place| place.enddate.year }&.enddate&.year || Date.today.year
@timespan = @maxyear - @minyear

respond_to do |format|
format.html { render :show }
format.json { render :show, filename: "orte-map-#{@map.title.parameterize}-#{I18n.l Date.today}.json" }
Expand Down
17 changes: 17 additions & 0 deletions app/views/maps/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
- content_for(:title) { @map.title }

#info{:style => "background-color: #fff; padding:10px; margin-bottom: 10px;"}
Timeline setup
%br
#{@places.count} places in #{@map_layers.count} layers
%br
Timerange:
#{@minyear}
\—
#{@maxyear}
(#{@timespan} Years)
%br
- if @map.marker_display_mode == 'single'
Marker display mode is set to single ✓
%br
TODO: generate timeline
%br
TODO: set filter active
#selection{:data => { 'url' => "/maps/#{@map.id}.json", 'map_id' => "#{@map.id}", 'map-center-lat' => "#{@map.mapcenter_lat}", 'map-center-lon' => "#{@map.mapcenter_lon}", 'map-zoom' => "#{@map.zoom}", 'map-extent-northeast' => "#{@map.northeast_corner}", 'map-extent-southwest' => "#{@map.southwest_corner}", 'map-basemap-url' => "#{@map.basemap_url}", 'map-basemap-attribution' => "#{@map.basemap_attribution}", 'map-background-color' => "#{@map.background_color}", 'map-popup-display-mode' => "#{@map.popup_display_mode}", 'map-marker_display_mode' => "#{@map.marker_display_mode}", 'map-enable_historical_maps' => "#{@map.enable_historical_maps}" }}
- if params[:setbound]
#form-wrapper.small-wrapper
Expand Down

0 comments on commit 7c801a1

Please sign in to comment.