import 'dart:convert'; import 'package:wetter/models/location_model.dart'; import 'package:http/http.dart' as http; class OpenStreetMapAPI { static Future> getLocationsFromSearch( String search) async { final response = await http.get( Uri.parse( 'https://nominatim.openstreetmap.org/search.php?q=$search&format=jsonv2'), headers: {"Accept": "application/json"}); if (response.statusCode == 200) { List locations = []; List results = jsonDecode(response.body); for (Map result in results) { locations.add(LocationModel.fromJson(result)); } return locations; } else { throw Exception('Failed to load weather data'); } } }