2024-02-05 03:07:08 +00:00
|
|
|
import 'dart:async';
|
2024-01-15 15:26:13 +00:00
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:maplibre_gl/maplibre_gl.dart';
|
|
|
|
|
|
2025-03-10 09:41:43 -05:00
|
|
|
extension MapMarkers on MapLibreMapController {
|
2024-01-15 15:26:13 +00:00
|
|
|
Future<Symbol?> addMarkerAtLatLng(LatLng centre) async {
|
|
|
|
|
// no marker is displayed if asset-path is incorrect
|
|
|
|
|
try {
|
|
|
|
|
final ByteData bytes = await rootBundle.load("assets/location-pin.png");
|
|
|
|
|
await addImage("mapMarker", bytes.buffer.asUint8List());
|
2025-07-29 00:34:03 +05:30
|
|
|
return addSymbol(SymbolOptions(geometry: centre, iconImage: "mapMarker", iconSize: 0.15, iconAnchor: "bottom"));
|
2024-01-15 15:26:13 +00:00
|
|
|
} finally {
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|