Add map borders and change default timeframe on the Map page

This commit is contained in:
Eugene Burmakin 2024-10-16 15:25:22 +02:00
parent caf34ff6fd
commit 1a0d68ab58
4 changed files with 24 additions and 11 deletions

View file

@ -1 +1 @@
0.15.4
0.15.5

View file

@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.15.5 - 2024-10-16
### Changed
- The Map page now by default uses timeframe based on last point tracked instead of the today's points. If there are no points, the map will use the today's timeframe.
- The map on the Map page can no longer be infinitely scrolled horizontally. #299
# 0.15.4 - 2024-10-15
### Changed

View file

@ -4,10 +4,7 @@ class MapController < ApplicationController
before_action :authenticate_user!
def index
@points = points
.without_raw_data
.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
.order(timestamp: :asc)
@points = points.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
@countries_and_cities = CountriesAndCities.new(@points).call
@coordinates =
@ -22,15 +19,17 @@ class MapController < ApplicationController
private
def start_at
return Time.zone.today.beginning_of_day.to_i if params[:start_at].nil?
return Time.zone.parse(params[:start_at]).to_i if params[:start_at].present?
return Time.zone.at(points.last.timestamp).beginning_of_day.to_i if points.any?
Time.zone.parse(params[:start_at]).to_i
Time.zone.today.beginning_of_day.to_i
end
def end_at
return Time.zone.today.end_of_day.to_i if params[:end_at].nil?
return Time.zone.parse(params[:end_at]).to_i if params[:end_at].present?
return Time.zone.at(points.last.timestamp).end_of_day.to_i if points.any?
Time.zone.parse(params[:end_at]).to_i
Time.zone.today.end_of_day.to_i
end
def distance
@ -50,10 +49,10 @@ class MapController < ApplicationController
end
def points_from_import
current_user.imports.find(params[:import_id]).points
current_user.imports.find(params[:import_id]).points.without_raw_data.order(timestamp: :asc)
end
def points_from_user
current_user.tracked_points
current_user.tracked_points.without_raw_data.order(timestamp: :asc)
end
end

View file

@ -48,6 +48,13 @@ export default class extends Controller {
this.map = L.map(this.containerTarget).setView([this.center[0], this.center[1]], 14);
// Set the maximum bounds to prevent infinite scroll
var southWest = L.latLng(-90, -180);
var northEast = L.latLng(90, 180);
var bounds = L.latLngBounds(southWest, northEast);
this.map.setMaxBounds(bounds);
this.markersArray = this.createMarkersArray(this.markers);
this.markersLayer = L.layerGroup(this.markersArray);
this.heatmapMarkers = this.markers.map((element) => [element[0], element[1], 0.2]);