Skip to content
Snippets Groups Projects
Commit 6a9b112d authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: search bar result selection

parent 3775c77b
No related branches found
No related tags found
1 merge request!10Clhp map
......@@ -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
......
......@@ -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();
......
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment