50 lines
1.4 KiB
Dart
50 lines
1.4 KiB
Dart
import 'package:maplibre_gl/maplibre_gl.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'dart:convert';
|
|
|
|
class IntaleqMapController {
|
|
final MapLibreMapController mapController;
|
|
final String apiKey;
|
|
|
|
IntaleqMapController({
|
|
required this.mapController,
|
|
required this.apiKey,
|
|
});
|
|
|
|
/// Search for places using Intaleq Geocoding API
|
|
Future<List<dynamic>> search(String query) async {
|
|
final response = await http.get(
|
|
Uri.parse(
|
|
'https://map-saas.intaleq.com/v1/geocoding/search?q=$query&key=$apiKey'),
|
|
);
|
|
if (response.statusCode == 200) {
|
|
return json.decode(response.body);
|
|
}
|
|
throw Exception('Failed to search');
|
|
}
|
|
|
|
/// Get route using Intaleq Routing API
|
|
Future<Map<String, dynamic>> getRoute(
|
|
LatLng start,
|
|
LatLng end, {
|
|
String profile = 'car',
|
|
}) async {
|
|
final response = await http.get(
|
|
Uri.parse(
|
|
'https://map-saas.intaleq.com/v1/routing/route?start=${start.longitude},${start.latitude}&end=${end.longitude},${end.latitude}&profile=$profile&key=$apiKey',
|
|
),
|
|
);
|
|
if (response.statusCode == 200) {
|
|
return json.decode(response.body);
|
|
}
|
|
throw Exception('Failed to fetch route');
|
|
}
|
|
}
|
|
|
|
class IntaleqStyles {
|
|
static String obsidian(String apiKey) =>
|
|
'https://maps.intaleq.com/styles/obsidian/style.json?key=$apiKey';
|
|
static String light(String apiKey) =>
|
|
'https://maps.intaleq.com/styles/light/style.json?key=$apiKey';
|
|
}
|