initialize method
Initializes the map by requesting permissions, getting user location, and preloading custom marker assets.
Returns the status of the location permission request.
Implementation
Future<LocationPermissionStatus> initialize() async {
final status = await _requestPermission();
if (status != LocationPermissionStatus.granted) return status;
final position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
_currentLocation = LatLng(position.latitude, position.longitude);
_mapController?.animateCamera(
CameraUpdate.newLatLngZoom(_currentLocation!, 16),
);
// PRELOAD MARKERS BEFORE THEY ARE USED
_customMarker ??= await BitmapDescriptor.fromAssetImage(
const ImageConfiguration(size: Size(30, 30)),
customMarkerPath,
);
_customMidMarker ??= await BitmapDescriptor.fromAssetImage(
const ImageConfiguration(size: Size(25, 25)),
customMidMarkerPath,
);
notifyListeners();
return LocationPermissionStatus.granted;
}