### Flutter Map Location Picker Example App Source: https://pub.dev/documentation/map_location_picker/latest/index A complete Flutter example app demonstrating the usage of the map_location_picker package. It includes setting up the main app structure, handling theme modes, displaying a map preview with a marker, showing formatted addresses, and opening the location picker with custom configurations. ```dart import 'package:example/key.dart'; import 'package:flutter/material.dart'; import 'package:map_location_picker/map_location_picker.dart'; void main() => runApp(const MyApp()); final _themeMode = ValueNotifier(ThemeMode.light); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: _themeMode, builder: (context, themeMode, child) { return MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), themeMode: themeMode, home: const LocationPickerScreen(), ); }, ); } } class LocationPickerScreen extends StatefulWidget { const LocationPickerScreen({super.key}); @override State createState() => _LocationPickerScreenState(); } class _LocationPickerScreenState extends State { LatLng? _pickedLocation; String _formattedAddress = "No location selected"; BitmapDescriptor? _customMarkerIcon; @override void initState() { super.initState(); _createMarkerIcon(); } void _createMarkerIcon() async { _customMarkerIcon = await BitmapDescriptor.asset( const ImageConfiguration(size: Size(48, 48)), 'assets/marker.webp', ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Location Picker')), body: SingleChildScrollView( child: Column( children: [ // Map preview Container( height: 200, child: _pickedLocation == null ? Center(child: Text("Select a location")) : Image.network( googleStaticMapWithMarker( _pickedLocation!.latitude, _pickedLocation!.longitude, 16, apiKey: YOUR_API_KEY, ), fit: BoxFit.cover, ), ), // Address display ListTile( leading: Icon(Icons.location_on), title: Text(_formattedAddress), ), // Picker options _buildOptionCard( icon: Icons.map, title: "Standard Picker", onTap: () => _openPicker(standardConfig), ), // More options... ], ), ), ); } void _openPicker(MapPickerConfig config) async { await Navigator.push( context, MaterialPageRoute( builder: (context) => MapLocationPicker( config: config.copyWith( initialPosition: _pickedLocation, onNext: (result) { if (result != null) { setState(() { _pickedLocation = LatLng( result.geometry.location.lat, result.geometry.location.lng, ); _formattedAddress = result.formattedAddress ?? ""; }); } }, ), searchConfig: PlacesAutocompleteConfig( apiKey: YOUR_API_KEY, ), ), ), ); } } ``` -------------------------------- ### PlacesAutocomplete Constructor Definition Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/PlacesAutocomplete/PlacesAutocomplete Defines the parameters for the PlacesAutocomplete constructor, including key, search configuration, initial value, and callbacks for getting details and selection. ```dart const PlacesAutocomplete({ 1. Key? key, 2. required SearchConfig config, 3. Prediction? initialValue, 4. void onGetDetails( 1. PlacesDetailsResponse? )?, 5. void onSelected( 1. Prediction )?, }) ``` -------------------------------- ### Dart hashCode Implementation Example Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/HeatmapGradient/hashCode This example demonstrates how to implement the hashCode property in Dart, overriding the default behavior to reflect the object's state. It uses Object.hash to combine the hash codes of relevant properties. ```dart @override int get hashCode => Object.hash(colors, colorMapSize); ``` -------------------------------- ### iOS API Key Setup for Google Maps Source: https://pub.dev/documentation/map_location_picker/latest/index Shows how to provide the Google Maps API key in the AppDelegate.swift file for iOS applications. This is crucial for initializing and using Google Maps services on iOS devices. ```swift GMSServices.provideAPIKey("YOUR_IOS_API_KEY") ``` -------------------------------- ### Open App Settings Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Geolocator-class Opens the application's settings page within the device's system settings. This is useful for guiding users to grant necessary location permissions. ```Dart Geolocator.openAppSettings() ``` -------------------------------- ### Android API Key Setup for Google Maps Source: https://pub.dev/documentation/map_location_picker/latest/index Provides the necessary XML snippet to be added to the AndroidManifest.xml file for enabling Google Maps services. It requires an API key obtained from the Google Cloud Console and ensures the Maps SDK for Android is properly configured. ```xml ``` -------------------------------- ### Web API Key Setup for Google Maps JavaScript API Source: https://pub.dev/documentation/map_location_picker/latest/index Illustrates how to include the Google Maps JavaScript API script in an HTML file, embedding the API key. This enables Google Maps functionality on web applications. ```html ``` -------------------------------- ### BytesMapBitmap Constructor with imagePixelRatio Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/BytesMapBitmap/BytesMapBitmap Constructs a BytesMapBitmap from PNG byte data, utilizing the imagePixelRatio for scaling based on device pixel density. Ensures the byte data is not empty and handles scaling options appropriately. ```dart Uint8List byteData = await _loadImageData('path/to/image.png'); double imagePixelRatio = 2.0; // Pixel density of the image. BytesMapBitmap bytesMapBitmap = BytesMapBitmap( byteData, imagePixelRatio: imagePixelRatio, ); ``` -------------------------------- ### Animate Map Camera (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapController/animateCamera Starts an animated change of the map camera position using a CameraUpdate. The duration of the animation can be specified; otherwise, a platform default is used. The returned Future indicates when the animation has started on the platform. ```dart Future animateCamera(CameraUpdate cameraUpdate, {Duration? duration}) { return GoogleMapsFlutterPlatform.instance.animateCameraWithConfiguration( cameraUpdate, CameraUpdateAnimationConfiguration(duration: duration), mapId: mapId, ); } ``` -------------------------------- ### Dart hashCode Implementation Example Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/AndroidPosition/hashCode This example demonstrates how to implement the hashCode getter in Dart. It combines the hash codes of relevant object properties using the bitwise XOR operator. Ensure that if operator == is overridden, hashCode is also overridden to maintain consistency for hash-based collections. ```dart @override int get hashCode => satelliteCount.hashCode ^ satellitesUsedInFix.hashCode ^ super.hashCode; ``` -------------------------------- ### Marker Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Marker/Marker Provides details on the constructor for the Marker class, outlining all available parameters for customization. ```APIDOC ## Constructor Marker ### Description Creates a set of marker configuration options with various customizable properties. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (Parameters are passed directly to the constructor) ### Parameters - **markerId** (MarkerId) - Required - A unique identifier for the marker. - **alpha** (double) - Optional - Controls the opacity of the marker. Defaults to 1.0. - **anchor** (Offset) - Optional - Specifies the anchor point of the marker on the map. Defaults to (0.5, 1.0). - **consumeTapEvents** (bool) - Optional - Determines if tap events on the marker should be consumed. Defaults to false. - **draggable** (bool) - Optional - Enables or disables dragging of the marker. Defaults to false. - **flat** (bool) - Optional - If true, the marker is drawn flat against the screen. Defaults to false. - **icon** (BitmapDescriptor) - Optional - The icon to display for the marker. Defaults to `BitmapDescriptor.defaultMarker`. - **infoWindow** (InfoWindow) - Optional - Configuration for the info window displayed when the marker is tapped. Defaults to `InfoWindow.noText`. - **position** (LatLng) - Optional - The geographical position of the marker. Defaults to `LatLng(0.0, 0.0)`. - **rotation** (double) - Optional - The rotation of the marker in degrees. Defaults to 0.0. - **visible** (bool) - Optional - Controls the visibility of the marker. Defaults to true. - **zIndex** (double) - Optional - Controls the drawing order of the marker (deprecated). Defaults to 0.0. - **zIndexInt** (int) - Optional - Controls the drawing order of the marker. Defaults to 0. - **clusterManagerId** (ClusterManagerId?) - Optional - The ID of the cluster manager this marker belongs to. - **onTap** (VoidCallback?) - Optional - Callback function triggered when the marker is tapped. - **onDrag** (ValueChanged?) - Optional - Callback function triggered when the marker is being dragged. - **onDragStart** (ValueChanged?) - Optional - Callback function triggered when the marker drag starts. - **onDragEnd** (ValueChanged?) - Optional - Callback function triggered when the marker drag ends. ### Request Example ```dart const Marker( markerId: MarkerId("my_marker"), position: LatLng(37.7749, -122.4194), infoWindow: InfoWindow(title: 'My Location'), ) ``` ### Response #### Success Response (200) N/A (This is a constructor, not an API endpoint) #### Response Example N/A ``` -------------------------------- ### BytesMapBitmap Constructor for sharp rendering Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/BytesMapBitmap/BytesMapBitmap Initializes a BytesMapBitmap using device pixel ratio for the sharpest possible rendering. This ensures the asset is displayed at a pixel-to-pixel ratio on the screen. ```dart Uint8List byteData = imageBuffer.asUint8List() BytesMapBitmap bytesMapBitmap = BytesMapBitmap( byteData, imagePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context), ); ``` -------------------------------- ### Get Place Details by Place ID (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsPlaces/getDetailsByPlaceId The getDetailsByPlaceId method retrieves detailed information for a given place ID. It supports optional parameters like session token, requested fields, language, and region. This method makes an HTTP GET request to a constructed URL and decodes the response. ```dart Future getDetailsByPlaceId( String placeId, { String? sessionToken, List fields = const [], String? language, String? region, }) async { final url = buildDetailsUrl( placeId: placeId, sessionToken: sessionToken, fields: fields, language: language, region: region, ); return _decodeDetailsResponse(await doGet(url, headers: apiHeaders)); } ``` -------------------------------- ### GoogleMap Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMap-class Creates a GoogleMap widget with various parameters to configure map behavior, appearance, and event handling. It requires an initial camera position and accepts optional settings for map styles, gestures, overlays, and callbacks. ```dart GoogleMap.new({ Key? key, required CameraPosition initialCameraPosition, String? style, MapCreatedCallback? onMapCreated, Set> gestureRecognizers = const >{}, WebGestureHandling? webGestureHandling, WebCameraControlPosition? webCameraControlPosition, bool webCameraControlEnabled = true, bool compassEnabled = true, bool mapToolbarEnabled = true, CameraTargetBounds cameraTargetBounds = CameraTargetBounds.unbounded, MapType mapType = MapType.normal, MinMaxZoomPreference minMaxZoomPreference = MinMaxZoomPreference.unbounded, bool rotateGesturesEnabled = true, bool scrollGesturesEnabled = true, bool zoomControlsEnabled = true, bool zoomGesturesEnabled = true, bool liteModeEnabled = false, bool tiltGesturesEnabled = true, bool fortyFiveDegreeImageryEnabled = false, bool myLocationEnabled = false, bool myLocationButtonEnabled = true, TextDirection? layoutDirection, EdgeInsets padding = EdgeInsets.zero, bool indoorViewEnabled = false, bool trafficEnabled = false, bool buildingsEnabled = true, Set markers = const {}, Set polygons = const {}, Set polylines = const {}, Set circles = const {}, Set clusterManagers = const {}, Set heatmaps = const {}, VoidCallback? onCameraMoveStarted, Set tileOverlays = const {}, Set groundOverlays = const {}, CameraPositionCallback? onCameraMove, VoidCallback? onCameraIdle, ArgumentCallback? onTap, ArgumentCallback? onLongPress, String? cloudMapId }) ``` -------------------------------- ### Get Location Details by Reference (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsPlaces/getDetailsByReference Retrieves detailed information about a location using its reference ID. This method is deprecated and recommends using `getDetailsByPlaceId`. It takes a reference string and optional parameters like session token, fields to include, and language. The implementation builds a URL and makes a GET request. ```dart @Deprecated("Use [getDetailsByPlaceId] instead") Future getDetailsByReference( String reference, { String? sessionToken, List fields = const [], String? language, }) @Deprecated("Use [getDetailsByPlaceId] instead") Future getDetailsByReference( String reference, { String? sessionToken, List fields = const [], String? language, }) async { final url = buildDetailsUrl( reference: reference, sessionToken: sessionToken, fields: fields, language: language, ); return _decodeDetailsResponse(await doGet(url, headers: apiHeaders)); } ``` -------------------------------- ### Implement searchByAddress Method (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsGeocoding/searchByAddress This method performs a geocoding request based on an address and optional parameters like bounds, language, region, and components. It builds the URL, makes a GET request, and decodes the response. Dependencies include the `GeocodingResponse` model and helper functions like `buildUrl`, `doGet`, and `apiHeaders`. ```dart Future searchByAddress( String address, { Bounds? bounds, String? language, String? region, List components = const [], }) async { final url = buildUrl( address: address, bounds: bounds, language: language, region: region, components: components, ); return _decode(await doGet(url, headers: apiHeaders)); } ``` -------------------------------- ### Create HeatmapGradientColor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/HeatmapGradientColor-class Creates a new HeatmapGradientColor object with a specified color and start point. This is the primary constructor for the class. ```dart HeatmapGradientColor.new(Color color, double startPoint) ``` -------------------------------- ### PlaceDetails Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/PlaceDetails/PlaceDetails This snippet details the PlaceDetails constructor, outlining all the parameters used to create a PlaceDetails object. It specifies which parameters are required and their data types. ```APIDOC ## PlaceDetails Constructor ### Description Constructs a PlaceDetails object with various attributes related to a place. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **adrAddress** (String?) - Optional - The address of the place. - **name** (String) - Required - The name of the place. - **placeId** (String) - Required - The unique identifier for the place. - **utcOffset** (num?) - Optional - The UTC offset of the place. - **id** (String?) - Optional - The ID of the place. - **internationalPhoneNumber** (String?) - Optional - The international phone number of the place. - **addressComponents** (List) - Optional - A list of address components. - **photos** (List) - Optional - A list of photos associated with the place. - **types** (List) - Optional - A list of types the place belongs to. - **reviews** (List) - Optional - A list of reviews for the place. - **formattedAddress** (String?) - Optional - The formatted address of the place. - **formattedPhoneNumber** (String?) - Optional - The formatted phone number of the place. - **reference** (String?) - Optional - A reference string for the place. - **icon** (String?) - Optional - The icon URL for the place. - **rating** (num?) - Optional - The rating of the place. - **openingHours** (OpeningHoursDetail?) - Optional - The opening hours details. - **priceLevel** (PriceLevel?) - Optional - The price level of the place. - **scope** (String?) - Optional - The scope of the place. - **url** (String?) - Optional - The URL of the place. - **vicinity** (String?) - Optional - The vicinity of the place. - **website** (String?) - Optional - The website of the place. - **geometry** (Geometry?) - Optional - The geometry information of the place. - **businessStatus** (String?) - Optional - The business status of the place. - **curbsidePickup** (bool?) - Optional - Indicates if curbside pickup is available. - **delivery** (bool?) - Optional - Indicates if delivery is available. - **dineIn** (bool?) - Optional - Indicates if dine-in is available. - **editorialSummary** (PlaceEditorialSummary?) - Optional - The editorial summary of the place. - **iconBackgroundColor** (String?) - Optional - The background color of the place's icon. - **iconMaskBaseUri** - Optional - The base URI for the icon mask. - **plusCode** (PlusCode?) - Optional - The Plus Code for the place. - **reservable** (bool?) - Optional - Indicates if the place is reservable. - **servesBeer** (bool?) - Optional - Indicates if the place serves beer. - **servesBreakfast** (bool?) - Optional - Indicates if the place serves breakfast. - **servesBrunch** (bool?) - Optional - Indicates if the place serves brunch. - **servesDinner** (bool?) - Optional - Indicates if the place serves dinner. - **servesLunch** (bool?) - Optional - Indicates if the place serves lunch. - **servesVegetarianFood** (bool?) - Optional - Indicates if the place serves vegetarian food. - **servesWine** (bool?) - Optional - Indicates if the place serves wine. - **takeout** (bool?) - Optional - Indicates if takeout is available. - **userRatingsTotal** (int?) - Optional - The total number of user ratings. - **wheelChairAccessibleEntrance** (bool?) - Optional - Indicates if there is wheelchair accessible entrance. ### Request Example ```json { "adrAddress": "123 Main St", "name": "Example Place", "placeId": "ChIJN1t_tDeuEmsRUsoyG83frpc", "rating": 4.5 } ``` ### Response #### Success Response (200) This constructor does not return a response in the traditional API sense; it creates an object in memory. #### Response Example N/A ``` -------------------------------- ### Create AssetMapBitmap for sharp rendering Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/AssetMapBitmap/AssetMapBitmap Shows how to create an AssetMapBitmap for the sharpest possible rendering by setting the `imagePixelRatio` to the device's pixel ratio. This ensures pixel-to-pixel rendering but may affect logical marker sizes across different device densities. ```dart AssetMapBitmap assetMapBitmap = AssetMapBitmap( 'assets/images/map_icon.png', imagePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context), ); ``` -------------------------------- ### Get GeolocatorPlatform Instance Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform/instance Retrieves the default instance of GeolocatorPlatform. This is typically used to access Geolocator functionalities. The default implementation is MethodChannelGeolocator. ```dart static GeolocatorPlatform get instance => _instance; ``` -------------------------------- ### Dart hashCode Implementation Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/MatchedSubstring/hashCode Example of implementing the hashCode getter in Dart. It combines the hash codes of the 'offset' and 'length' properties using the bitwise XOR operator. ```dart @override int get hashCode => offset.hashCode ^ length.hashCode; ``` -------------------------------- ### BytesMapBitmap Dart Implementation Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/BytesMapBitmap/BytesMapBitmap The core Dart implementation of the BytesMapBitmap constructor, including assertions to validate byte data and scaling options. It initializes the bitmap with provided parameters. ```dart BytesMapBitmap( this.byteData, { super.bitmapScaling = MapBitmapScaling.auto, super.width, super.height, double? imagePixelRatio, } ) : assert( byteData.isNotEmpty, 'Cannot create BitmapDescriptor with empty byteData.', ), assert( bitmapScaling != MapBitmapScaling.none || imagePixelRatio == null, 'If bitmapScaling is set to MapBitmapScaling.none, imagePixelRatio parameter cannot be used.', ), assert( bitmapScaling != MapBitmapScaling.none || width == null, 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.', ), assert( bitmapScaling != MapBitmapScaling.none || height == null, 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.', ), super._(imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio); ``` -------------------------------- ### Clone HeatmapGradientColor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/HeatmapGradientColor-class Returns a new HeatmapGradientColor instance with the same color and start point as the current object. Ensures immutability by creating a distinct copy. ```dart clone() ``` -------------------------------- ### Main Scaffold Structure Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/MapLocationPicker/build This snippet outlines the main Scaffold widget for the application. It configures properties like extending behind the app bar and body, setting the background color, and using a Stack to layer different UI elements including the Google Map, search view, and floating controls. ```dart return Scaffold( extendBodyBehindAppBar: true, extendBody: true, backgroundColor: CupertinoColors.systemBackground, body: Stack( children: [ /// Google Map View GoogleMap(...), /// Search view buildSearchView(), /// Floating controls buildFloatingControls(), ], ), ); ``` -------------------------------- ### GeoCodingConfig Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeoCodingConfig-class Initializes the GeoCodingConfig with necessary parameters for geocoding services. ```APIDOC ## POST /websites/pub_dev_map_location_picker/GeoCodingConfig ### Description Initializes the GeoCodingConfig with the API key, optional HTTP client, API headers, base URL, language, location types, and result types. ### Method POST ### Endpoint /websites/pub_dev_map_location_picker/GeoCodingConfig ### Parameters #### Request Body - **apiKey** (String) - Required - The API key for the geocoding service. - **httpClient** (Client?) - Optional - The HTTP client to use for the geocoding service. - **apiHeaders** (Map?) - Optional - The API headers to use for the geocoding service. - **baseUrl** (String?) - Optional - The base URL for the geocoding service. - **language** (String?) - Optional - The language for the geocoding service. - **locationType** (List) - Optional - The types of locations to return. - **resultType** (List) - Optional - The types of results to return. ### Request Example { "apiKey": "YOUR_API_KEY", "httpClient": null, "apiHeaders": { "X-Custom-Header": "Value" }, "baseUrl": "https://api.geocoding.com/v1/", "language": "en", "locationType": ["street_address", "geocode"], "resultType": ["geocode", "locality"] } ### Response #### Success Response (200) - **message** (String) - Indicates successful initialization. ``` -------------------------------- ### CapType Enum Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Cap-class Defines the types of caps that can be rendered at the start or end vertices of a Polyline. These types control the visual appearance of the line endings. ```dart enum CapType { /// The cap is squared off exactly at the start or end vertex. butt, /// The cap is a semicircle with radius equal to half the stroke width. round, /// The cap is squared off after extending half the stroke width beyond the vertex. square, /// The cap is rendered using a custom bitmap image. custom, } ``` -------------------------------- ### Get Location Accuracy Status Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform-class Returns a Future containing the current accuracy status of the device's location services. The status is represented by the LocationAccuracyStatus type. ```dart getLocationAccuracy() → Future ``` -------------------------------- ### Review Constructor Implementation (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Review/Review Provides the implementation of the Review constructor in Dart. This code initializes the Review object with the provided named parameters. ```dart Review({ required this.authorName, required this.authorUrl, required this.language, required this.profilePhotoUrl, required this.rating, required this.relativeTimeDescription, required this.text, required this.time, }); ``` -------------------------------- ### Get Current Device Position Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform-class Returns a Future containing the device's current geographical position. Optional LocationSettings can be provided to customize the position retrieval. ```dart getCurrentPosition({LocationSettings? locationSettings}) → Future ``` -------------------------------- ### AssetMapBitmap Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/AssetMapBitmap/AssetMapBitmap This section details the constructor for the AssetMapBitmap class, which allows you to create a bitmap from an asset image with various customization options. ```APIDOC ## AssetMapBitmap Constructor ### Description Creates an `AssetMapBitmap` from an asset image. For mipmapped assets, use `AssetMapBitmap.create` instead. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **assetName** (String) - Required - The name of the asset image. * **bitmapScaling** (MapBitmapScaling) - Optional - Controls the scaling behavior. Defaults to `MapBitmapScaling.auto`. * `MapBitmapScaling.auto`: Automatically upscales/downscales to match device pixel ratio or specified dimensions. * `MapBitmapScaling.none`: Disables automatic scaling. * **imagePixelRatio** (double?) - Optional - The pixel ratio of the asset image. Defaults to 1.0. Set to the device's pixel ratio for sharp rendering. * **width** (double?) - Optional - Specifies the desired width of the rendered image in logical pixels. * **height** (double?) - Optional - Specifies the desired height of the rendered image in logical pixels. **Note:** If `width` or `height` is provided, `imagePixelRatio` is ignored. ### Request Example ```dart AssetMapBitmap mapBitmap = AssetMapBitmap( 'assets/images/map_icon.png', bitmapScaling: MapBitmapScaling.auto, width: 40, ); AssetMapBitmap assetMapBitmap = AssetMapBitmap( 'assets/images/map_icon.png', imagePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context), ); ``` ### Response #### Success Response (200) N/A (Constructor returns an instance of AssetMapBitmap) #### Response Example ```dart // Example of a created AssetMapBitmap object AssetMapBitmap mapBitmapInstance; ``` ``` -------------------------------- ### GoogleMapsGeocoding Constructor (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsGeocoding/GoogleMapsGeocoding Initializes the GoogleMapsGeocoding client with an API key and optional configuration. It sets up the base URL and headers for API requests. ```dart GoogleMapsGeocoding({ String? apiKey, String? baseUrl, Client? httpClient, Map? apiHeaders, }) : super( apiKey: apiKey, baseUrl: baseUrl, apiPath: _geocodeUrl, httpClient: httpClient, apiHeaders: apiHeaders, ); ``` -------------------------------- ### Get Details By Reference (Deprecated) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsPlaces/getDetailsByReference Retrieves detailed information about a location using its reference ID. This method is deprecated and `getDetailsByPlaceId` should be used instead. ```APIDOC ## GET /websites/pub_dev_map_location_picker/getDetailsByReference ### Description Retrieves detailed information about a location using its reference ID. This method is deprecated and `getDetailsByPlaceId` should be used instead. ### Method GET ### Endpoint /websites/pub_dev_map_location_picker/getDetailsByReference ### Parameters #### Query Parameters - **reference** (String) - Required - The reference ID of the location. - **sessionToken** (String) - Optional - A session token for the request. - **fields** (List) - Optional - A list of fields to include in the response. - **language** (String) - Optional - The language for the response. ### Request Example ``` { "reference": "some_reference_id", "sessionToken": "optional_session_token", "fields": ["name", "formatted_address"], "language": "en" } ``` ### Response #### Success Response (200) - **PlacesDetailsResponse** (Object) - Contains the detailed information about the location. #### Response Example ``` { "name": "Example Location", "formatted_address": "123 Main St, Anytown, USA" } ``` ``` -------------------------------- ### Search Geocoding by Address Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsGeocoding-class Provides an example of using the `searchByAddress` method to find geocoding information for a given address. It returns a Future of `GeocodingResponse`. ```dart Future searchAddress() async { try { final response = await geocoder.searchByAddress("Eiffel Tower, Paris"); // Process the response print(response.results.first.formattedAddress); } catch (e) { print("Error searching by address: $e"); } } ``` -------------------------------- ### Create AssetMapBitmap with specified width Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/AssetMapBitmap/AssetMapBitmap Demonstrates creating an AssetMapBitmap from an asset image, specifying a fixed width and enabling automatic scaling. The `imagePixelRatio` is ignored when width or height is provided. ```dart AssetMapBitmap mapBitmap = AssetMapBitmap( 'assets/images/map_icon.png', bitmapScaling: MapBitmapScaling.auto, width: 40, // Desired width in logical pixels. ); ``` -------------------------------- ### Copy HeatmapGradientColor with Changes Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/HeatmapGradientColor-class Creates a new HeatmapGradientColor instance, optionally updating the color and start point from the current instance. Useful for immutable object updates. ```dart copyWith({Color? colorParam, double? startPointParam}) ``` -------------------------------- ### GoogleMapsPlaces Constructor Implementation (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsPlaces/GoogleMapsPlaces This code snippet shows the Dart implementation of the GoogleMapsPlaces constructor. It initializes the superclass with provided API key, base URL, API path, HTTP client, and API headers. ```dart GoogleMapsPlaces({ String? apiKey, String? baseUrl, Client? httpClient, Map? apiHeaders, }) : super( apiKey: apiKey, baseUrl: baseUrl, apiPath: _placesUrl, httpClient: httpClient, apiHeaders: apiHeaders, ); ``` -------------------------------- ### Get Service Status Change Stream Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform-class Returns a Stream that emits ServiceStatus updates whenever the device's location services are manually disabled or enabled by the user. ```dart getServiceStatusStream() → Stream ``` -------------------------------- ### TileProvider Class Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/TileProvider-class Documentation for the TileProvider class, an interface for providing tile images for a TileOverlay. ```APIDOC ## TileProvider Class ### Description An interface for a class that provides the tile images for a TileOverlay. ### Constructors #### TileProvider.new() ### Properties #### hashCode → int The hash code for this object. #### runtimeType → Type A representation of the runtime type of the object. ### Methods #### getTile(int x, int y, int? zoom) → Future Returns the tile to be used for this tile coordinate. #### noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. #### toString() → String A string representation of this object. ### Operators #### operator ==(Object other) → bool The equality operator. ### Constants #### noTile → const Tile Stub tile that is used to indicate that no tile exists for a specific tile coordinate. ``` -------------------------------- ### BytesMapBitmap Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/BytesMapBitmap-class Constructs a BytesMapBitmap from PNG encoded byte data. Allows customization of scaling, width, height, and image pixel ratio. ```APIDOC ## BytesMapBitmap.new ### Description Constructs a BytesMapBitmap that is created from an array of bytes that must be encoded as `PNG` in Uint8List. ### Method `BytesMapBitmap.new` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **byteData** (Uint8List) - Required - The byte data of the image in PNG format. - **bitmapScaling** (MapBitmapScaling) - Optional - Controls the scaling behavior. Defaults to `MapBitmapScaling.auto`. - **width** (double?) - Optional - The target width of the bitmap in logical pixels. - **height** (double?) - Optional - The target height of the bitmap in logical pixels. - **imagePixelRatio** (double?) - Optional - The pixel ratio of the bitmap. Ignored if `width` or `height` is provided. ### Request Example ```dart // Example 1: Basic usage with imagePixelRatio Uint8List byteData = imageBuffer.asUint8List(); double imagePixelRatio = 2.0; BytesMapBitmap bytesMapBitmap1 = BytesMapBitmap( byteData, imagePixelRatio: imagePixelRatio, ); // Example 2: Specifying width Uint8List byteData2 = imageBuffer.asUint8List(); BytesMapBitmap bytesMapBitmap2 = BytesMapBitmap( byteData2, width: 64, ); // Example 3: Using device's pixel ratio for sharpness BytesMapBitmap bytesMapBitmap3 = BytesMapBitmap( byteData, imagePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context), ); ``` ### Response #### Success Response (N/A for constructor) This is a constructor and does not return a response in the typical API sense. #### Response Example N/A ``` -------------------------------- ### PlacesSearchResponse toJson Method (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/PlacesSearchResponse-class Converts the PlacesSearchResponse object into a Map representation. This is useful for serializing the object, for example, before sending it in an API request or saving it to a file. ```dart toJson() => Map ``` -------------------------------- ### Build Photo URL Method (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GoogleMapsPlaces/buildPhotoUrl Constructs a photo URL using provided photo reference and optional maximum width or height. Throws an ArgumentError if neither maxWidth nor maxHeight is specified. Requires an 'apiKey' to be accessible in the scope. ```dart String buildPhotoUrl({ required String photoReference, int? maxWidth, int? maxHeight, }) { if (maxWidth == null && maxHeight == null) { throw ArgumentError("You must supply 'maxWidth' or 'maxHeight'"); } final params = { 'photoreference': photoReference, }; if (maxWidth != null) { params['maxwidth'] = maxWidth.toString(); } if (maxHeight != null) { params['maxheight'] = maxHeight.toString(); } if (apiKey != null) { params['key'] = apiKey!; } return url .replace( path: '${url.path}$_photoUrl', queryParameters: params, ) .toString(); } ``` -------------------------------- ### Foreground Notification Configuration Declaration Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/AndroidSettings/foregroundNotificationConfig Declares the foregroundNotificationConfig property, which is an optional ForegroundNotificationConfig object. This property is used to start a service as a foreground service with a persistent notification. ```dart final ForegroundNotificationConfig? foregroundNotificationConfig; ``` -------------------------------- ### Create BytesMapBitmap with Device Pixel Ratio Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/BytesMapBitmap-class Illustrates creating a BytesMapBitmap and setting the `imagePixelRatio` to the device's pixel ratio for the sharpest possible rendering. ```dart Uint8List byteData = imageBuffer.asUint8List(); BytesMapBitmap bytesMapBitmap = BytesMapBitmap( byteData, imagePixelRatio: MediaQuery.maybeDevicePixelRatioOf(context), ); ``` -------------------------------- ### TileOverlay Constructor Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/TileOverlay-class Explains how to create a new TileOverlay object with customizable properties. ```APIDOC ## TileOverlay.new() Creates an immutable representation of a TileOverlay to draw on GoogleMap. ### Method **Constructor** ### Parameters #### Request Body - **tileOverlayId** (TileOverlayId) - Required - A unique identifier for the TileOverlay. - **fadeIn** (bool) - Optional - Whether the tiles should fade in. Defaults to true. - **tileProvider** (TileProvider?) - Optional - The tile provider to use for this tile overlay. - **transparency** (double) - Optional - The transparency of the tile overlay. Defaults to 0.0 (opaque). - **zIndex** (int) - Optional - The order in which the tile overlay will be drawn. Higher values are drawn above lower values. Defaults to 0. - **visible** (bool) - Optional - The visibility for the tile overlay. Defaults to true. - **tileSize** (int) - Optional - Specifies the number of logical pixels that the returned tile images will prefer to display as. iOS only. Defaults to 256. ``` -------------------------------- ### Get Position Change Stream Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform-class Returns a Stream that emits Position updates whenever the device's location changes within the bounds of the specified desiredAccuracy. LocationSettings can be provided. ```dart getPositionStream({LocationSettings? locationSettings}) → Stream ``` -------------------------------- ### Cluster Class Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Cluster-class Details about the Cluster class, its constructor, properties, and methods. ```APIDOC ## Cluster Class A cluster containing multiple markers. ### Description Represents a cluster of markers, typically used in map interfaces to group nearby markers. ### Constructors #### Cluster.new ```dart Cluster.new(ClusterManagerId clusterManagerId, List markerIds, {required LatLng position, required LatLngBounds bounds}) ``` Creates a cluster with its location LatLng, bounds LatLngBounds, and list of MarkerIds in the cluster. ### Properties - **bounds** (LatLngBounds) - The bounds containing all cluster markers. - **clusterManagerId** (ClusterManagerId) - ID of the ClusterManager of the cluster. - **count** (int) - Returns the number of markers in the cluster. - **hashCode** (int) - The hash code for this object. - **markerIds** (List) - List of MarkerIds in the cluster. - **position** (LatLng) - Cluster marker location. - **runtimeType** (Type) - A representation of the runtime type of the object. ### Methods - **noSuchMethod**(Invocation invocation) → dynamic - Invoked when a nonexistent method or property is accessed. - **toString**() → String - A string representation of this object. ### Operators - **operator ==**(Object other) → bool - The equality operator. ``` -------------------------------- ### Get Last Known Device Position Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GeolocatorPlatform-class Returns a Future containing the last known geographical position of the device. The 'forceLocationManager' parameter can be used to force the use of the location manager. ```dart getLastKnownPosition({bool forceLocationManager = false}) → Future ``` -------------------------------- ### Create GroundOverlay from Position Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/GroundOverlay/GroundOverlay Demonstrates how to create a GroundOverlay using the `fromPosition` factory constructor. It requires an image, a geographic position, and optionally accepts dimensions and zoom level for rendering. ```dart GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('overlay_id'), image: await AssetMapBitmap.create( createLocalImageConfiguration(context), 'assets/images/ground_overlay.png', bitmapScaling: MapBitmapScaling.none, ), position: LatLng(37.42, -122.08), width: 100, height: 100, zoomLevel: 14, ); ``` -------------------------------- ### Get Location Changes Stream Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Geolocator-class Provides a Stream that fires whenever the device's location changes within the bounds specified by LocationSettings.accuracy. This is ideal for real-time location tracking. ```Dart Geolocator.getPositionStream(locationSettings: LocationSettings()) ``` -------------------------------- ### PlacesDetailsResponse Constructor Implementation (Dart) Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/PlacesDetailsResponse/PlacesDetailsResponse Provides the Dart implementation for the PlacesDetailsResponse constructor. This code initializes the class properties using the provided parameters and calls the superclass constructor. ```dart PlacesDetailsResponse({ required String status, String? errorMessage, required this.result, required this.htmlAttributions, }) : super( status: status, errorMessage: errorMessage, ); ``` -------------------------------- ### PlacesAutocomplete Constructor Implementation Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/PlacesAutocomplete/PlacesAutocomplete Provides the implementation details of the PlacesAutocomplete constructor, assigning the provided parameters to the widget's properties. ```dart const PlacesAutocomplete({ super.key, required this.config, this.initialValue, this.onGetDetails, this.onSelected, }); ``` -------------------------------- ### Dart hashCode Implementation Example Source: https://pub.dev/documentation/map_location_picker/latest/map_location_picker/Polyline/hashCode This snippet demonstrates how to override the hashCode property in Dart. It uses the hashCode of another object (polylineId) to ensure consistency when the equality operator (==) is also overridden. ```dart @override int get hashCode => polylineId.hashCode; ```