GemMap constructor
const
GemMap({
- Key? key,
- void onMapCreated()?,
- AndroidViewMode androidViewMode = AndroidViewMode.auto,
- Coordinates? coordinates,
- RectangleGeographicArea? area,
- int? zoomLevel,
- String? appAuthorization,
- String? initialMapStyleAsset,
- bool allowInternetConnection = true,
- AutoUpdateSettings? autoUpdateSettings,
Create a GemMap widget which renders an interactive map view.
The GemMap is the primary widget for embedding a Magic Lane map into a
Flutter application. It initializes the underlying native map, handles
platform-specific view composition, and provides a GemMapController
through the onMapCreated callback to interact with the map programmatically.
Use the appAuthorization parameter to pass your project token.
The initialMapStyleAsset allows applying a custom map style from the app's
assets when the map is first created.
Example
const GemMap(
appAuthorization: projectApiToken,
onMapCreated: (GemMapController controller) {
// Use controller to center, add overlays, etc.
},
);
Parameters
onMapCreated: (void Function(GemMapController)?) Optional callback invoked with a GemMapController once the native map has been initialized and is ready for use.androidViewMode: (AndroidViewMode) Mode for embedding native Android views. Defaults to AndroidViewMode.auto which chooses the best mode depending on Android version.coordinates: (Coordinates?) Optional initial center coordinates for the map.area: (RectangleGeographicArea?) Optional geographic area to center and fit the map to on creation.zoomLevel: (int?) Optional initial zoom level for the map center. Useful whencoordinatesis provided.appAuthorization: (String?) Optional project token used to initialize the SDK. If the SDK is already initialized this parameter is ignored.initialMapStyleAsset: (String?) Optional path to a.styleasset declared inpubspec.yaml. Example: 'assets/map_styles/my_map_style.style'.allowInternetConnection: (bool) When false, prevents SDK from using network resources during native initialization. Default:true.autoUpdateSettings: (AutoUpdateSettings?) Optional AutoUpdateSettings used when loading native binaries; ignored if SDK is already initialized.
See also:
- GemMapController - Control the map after creation.
- FollowPositionPreferences - Preferences for following the camera during follow position mode.
Implementation
const GemMap({
super.key,
final void Function(GemMapController)? onMapCreated,
final AndroidViewMode androidViewMode = AndroidViewMode.auto,
final Coordinates? coordinates,
final RectangleGeographicArea? area,
final int? zoomLevel,
final String? appAuthorization,
final String? initialMapStyleAsset,
final bool allowInternetConnection = true,
final AutoUpdateSettings? autoUpdateSettings,
}) : _initialMapStyleAsset = initialMapStyleAsset,
_appAuthorization = appAuthorization,
_zoomLevel = zoomLevel,
_area = area,
_coordinates = coordinates,
_androidViewMode = androidViewMode,
_onMapCreated = onMapCreated,
_autoUpdateSettings = autoUpdateSettings,
_allowInternetConnection = allowInternetConnection;