search method
Searches for places matching the query.
Implementation
Future<List<PowerMapSearchResult>> search(
String query, {
LatLng? location,
String lang = 'auto',
}) async {
final cacheKey =
'${query}_${location?.latitude ?? 0}_${location?.longitude ?? 0}_$lang';
if (_searchCache.containsKey(cacheKey)) {
return _searchCache[cacheKey]!;
}
final results = await provider.search(
query,
proximity: location,
lang: lang,
);
// Manage cache size (e.g., max 50 items)
if (_searchCache.length >= 50) {
_searchCache.remove(_searchCache.keys.first);
}
_searchCache[cacheKey] = results;
return results;
}