asset static method
- String url, {
- required MarkerProperties markerProperties,
- MapController? mapController,
- Widget builder(
- BuildContext context,
- MarkerProperties markerProperties,
- Map<
String, dynamic> ? map
- Key? key,
- PowerMarkerClusterOptions? powerClusterOptions,
Creates a widget that displays a marker on a map using an asset image.
The url parameter specifies the asset image URL to be used as the marker icon.
The markerProperties parameter is required and contains properties for the marker,
such as position and rotation.
The mapController parameter allows you to specify a custom MapController to control
the map view. If not provided, the default MapController will be used.
The builder parameter is an optional callback function that allows you to customize
the marker widget's appearance. It takes a BuildContext, MarkerProperties, and a
map of extra data as arguments and should return a widget. If not provided, a default
marker widget will be used.
The key parameter is an optional key that can be used to uniquely identify this widget.
Example usage:
asset(
'assets/marker.png',
markerProperties: MarkerProperties(
position: LatLng(37.7749, -122.4194),
rotation: 45.0,
),
mapController: myMapController,
builder: (context, markerProperties, extraData) {
return Icon(Icons.location_on, color: Colors.red);
},
)
In this example, the asset widget will display a marker on the map using the
'assets/marker.png' image, with custom properties, a custom builder function,
and a specified map controller.
Returns a FutureBuilder widget that will build the marker widget once the asset is loaded.
Implementation
static Widget asset(
String url, {
required MarkerProperties markerProperties,
MapController? mapController,
Widget Function(
BuildContext context,
MarkerProperties markerProperties,
Map<String, dynamic>? map,
)?
builder,
Key? key,
PowerMarkerClusterOptions? powerClusterOptions,
}) {
return EnhancedFutureBuilder<Widget>(
future: _assetMarkers(
url,
powerClusterOptions: powerClusterOptions,
markerProperties: markerProperties,
mapController: mapController,
builder: builder,
key: key,
),
rememberFutureResult: true,
whenDone: (Widget snapshotData) => snapshotData,
whenNotDone: const Center(child: CupertinoActivityIndicator()),
);
}