make packages for dart and npm
This commit is contained in:
@@ -1,49 +1,10 @@
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
library intaleq_maps;
|
||||
|
||||
class IntaleqMapController {
|
||||
final MapLibreMapController mapController;
|
||||
final String apiKey;
|
||||
export 'package:maplibre_gl/maplibre_gl.dart' show LatLng, LatLngBounds, CameraUpdate, CameraPosition, Symbol, Line, Circle, Fill;
|
||||
|
||||
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';
|
||||
}
|
||||
export 'src/intaleq_map_controller.dart';
|
||||
export 'src/intaleq_map_widget.dart';
|
||||
export 'src/styles.dart';
|
||||
export 'src/models/geometry.dart';
|
||||
export 'src/utils/polyline_utils.dart';
|
||||
export 'src/constants/colors.dart';
|
||||
|
||||
Reference in New Issue
Block a user