mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Add map borders and change default timeframe on the Map page
This commit is contained in:
parent
caf34ff6fd
commit
1a0d68ab58
4 changed files with 24 additions and 11 deletions
|
|
@ -1 +1 @@
|
||||||
0.15.4
|
0.15.5
|
||||||
|
|
|
||||||
|
|
@ -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/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
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
|
# 0.15.4 - 2024-10-15
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,7 @@ class MapController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@points = points
|
@points = points.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||||
.without_raw_data
|
|
||||||
.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
|
||||||
.order(timestamp: :asc)
|
|
||||||
|
|
||||||
@countries_and_cities = CountriesAndCities.new(@points).call
|
@countries_and_cities = CountriesAndCities.new(@points).call
|
||||||
@coordinates =
|
@coordinates =
|
||||||
|
|
@ -22,15 +19,17 @@ class MapController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def start_at
|
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
|
end
|
||||||
|
|
||||||
def end_at
|
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
|
end
|
||||||
|
|
||||||
def distance
|
def distance
|
||||||
|
|
@ -50,10 +49,10 @@ class MapController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def points_from_import
|
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
|
end
|
||||||
|
|
||||||
def points_from_user
|
def points_from_user
|
||||||
current_user.tracked_points
|
current_user.tracked_points.without_raw_data.order(timestamp: :asc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@ export default class extends Controller {
|
||||||
|
|
||||||
this.map = L.map(this.containerTarget).setView([this.center[0], this.center[1]], 14);
|
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.markersArray = this.createMarkersArray(this.markers);
|
||||||
this.markersLayer = L.layerGroup(this.markersArray);
|
this.markersLayer = L.layerGroup(this.markersArray);
|
||||||
this.heatmapMarkers = this.markers.map((element) => [element[0], element[1], 0.2]);
|
this.heatmapMarkers = this.markers.map((element) => [element[0], element[1], 0.2]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue