Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
6a9b112d
Commit
6a9b112d
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: search bar result selection
parent
3775c77b
No related branches found
No related tags found
1 merge request
!10
Clhp map
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/consts.dart
+1
-0
1 addition, 0 deletions
app/lib/consts.dart
app/lib/pages/default_page.dart
+24
-10
24 additions, 10 deletions
app/lib/pages/default_page.dart
server/map_handler/process_lake.py
+2
-2
2 additions, 2 deletions
server/map_handler/process_lake.py
with
27 additions
and
12 deletions
app/lib/consts.dart
+
1
−
0
View file @
6a9b112d
...
...
@@ -9,6 +9,7 @@ const String mapEndpoint = "update_map";
const
int
fetchInterval
=
60
;
// Fetch marker data every n minutes
// Map variables
String
selectedLake
=
'Mjøsa'
;
// Initialise to Mjøsa, NB should be initialised to last selected lake
LatLng
mapCenter
=
LatLng
(
60.8000
,
10.8471
);
DateTime
?
lastUpdate
;
// Last time data was fetched from server
...
...
This diff is collapsed.
Click to expand it.
app/lib/pages/default_page.dart
+
24
−
10
View file @
6a9b112d
...
...
@@ -101,7 +101,7 @@ class _DefaultPageState extends State<DefaultPage> {
},
),
title:
Text
(
'Mjøsa'
,
selectedLake
,
// Display name of current map
style:
regTextStyleBig
,
),
actions:
[
...
...
@@ -112,11 +112,13 @@ class _DefaultPageState extends State<DefaultPage> {
),
onPressed:
()
{
showSearch
(
context:
context
,
delegate:
_CustomSearchDelegate
());
/*setState(() {
showBar = !showBar;
});*/
context:
context
,
delegate:
_CustomSearchDelegate
((
String
result
)
{
setState
(()
{
selectedLake
=
result
;
});
}),
);
},
),
],
...
...
@@ -146,7 +148,13 @@ class _DefaultPageState extends State<DefaultPage> {
}
}
typedef
SearchResultCallback
=
void
Function
(
String
result
);
class
_CustomSearchDelegate
extends
SearchDelegate
{
final
SearchResultCallback
onResultSelected
;
_CustomSearchDelegate
(
this
.
onResultSelected
);
List
<
String
>
searchItems
=
[
// NB temp values
"Mjøsa"
,
"Bogstadsvannet"
,
...
...
@@ -183,7 +191,7 @@ class _CustomSearchDelegate extends SearchDelegate {
@override
Widget
buildResults
(
BuildContext
context
)
{
List
<
String
>
searchResults
=
[];
final
options
=
FuzzyOptions
(
threshold:
0.
3
,
findAllMatches:
true
);
final
options
=
FuzzyOptions
(
threshold:
0.
4
,
findAllMatches:
true
);
final
matcher
=
Fuzzy
(
searchItems
,
options:
options
);
final
results
=
matcher
.
search
(
query
);
searchResults
=
results
.
map
((
result
)
=
>
result
.
item
as
String
)
.
toList
();
...
...
@@ -192,8 +200,14 @@ class _CustomSearchDelegate extends SearchDelegate {
itemCount:
searchResults
.
length
,
itemBuilder:
(
context
,
index
)
{
var
result
=
searchResults
[
index
];
return
ListTile
(
title:
Text
(
result
),
return
GestureDetector
(
onTap:
()
{
onResultSelected
(
result
);
close
(
context
,
result
);
},
child:
ListTile
(
title:
Text
(
result
),
),
);
},
);
...
...
@@ -202,7 +216,7 @@ class _CustomSearchDelegate extends SearchDelegate {
@override
Widget
buildSuggestions
(
BuildContext
context
)
{
List
<
String
>
searchResults
=
[];
final
options
=
FuzzyOptions
(
threshold:
0.
3
,
findAllMatches:
true
);
final
options
=
FuzzyOptions
(
threshold:
0.
4
,
findAllMatches:
true
);
final
matcher
=
Fuzzy
(
searchItems
,
options:
options
);
final
results
=
matcher
.
search
(
query
);
searchResults
=
results
.
map
((
result
)
=
>
result
.
item
as
String
)
.
toList
();
...
...
This diff is collapsed.
Click to expand it.
server/map_handler/process_lake.py
+
2
−
2
View file @
6a9b112d
import
geopandas
as
gpd
from
shapely.geometry
import
Polygon
,
LineString
,
MultiLineString
from
shapely.geometry
import
Polygon
,
MultiPolygon
import
json
from
server.map.add_lake
import
write_json_to_file
from
server.map
_handler
.add_lake
import
write_json_to_file
# Writes contents of a map_handler json file to the response
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment