The GoogleMapController (see section “Handling events”) can be used to move the camera so that you can show a specific location to the user. Make sure to reference the asset image in your pubspec.yaml file. The following code sets a custom marker image by using the asset image “icon.png” in Munich/Europe. You can adjust the style with fillColor, strokeColor, and strokeWidth and handle the onTap event if required. The following example will display a circle around the center of Berlin/Europe. You can also use the GoogleMapController to trigger the InfoWindow. The onTap event will only be handled if consumeTapEvents is set to true. If an InfoWindow is defined, it will be displayed. The following example will display a rotated blue marker pin in Berlin/Europe.īy default, a tap on the marker centers the map over it. □ showMarkerInfoWindow – shows the info window of a given marker (see section “Adding markers”) Adding markers □ animateCamera – moves to a given position (see section “Moving the camera”) □ moveCamera – jumps to a given position (see section “Moving the camera”) □ takeSnapshot – returns a byte array of the current map image □ getLatLng – returns the latitude/longitude combination of a screen position The onMapCreated event returns a GoogleMapController which gives you complete control over the map. The widget offers various events that you can handle Customize it completely your way! Handling events There are a lot of properties to configure the map like rotateGesturesEnabled, zoomGesturesEnabled, trafficEnabled, or liteModeEnabled (only for Android). For a more complex version, please refer to the GitHub repository with code samples. It will display a map with the center over Berlin in Europe. To add a map, you can use the following code. Make sure to check the setup guidelines and adjust your code accordingly. Newer versions of the package might require different settings. Let’s move on to integrate a Google Maps widget. Return super.application(application, didFinishLaunchingWithOptions: launchOptions) GeneratedPluginRegistrant.register(with:self) GMSServices.provideAPIKey("YOUR_API_KEY") □ In your Flutter project directory go to ios/Runner/AppDelegate.swift and adjust the code as seen below import UIKitĭidFinishLaunchingWithOptions launchOptions: ? ✅ ( iOS) Your API key must be added to the application delegate Otherwise, check this article at the step iOS Deployment Target. □ This should already be the case because Flutter itself requires that version. ✅ ( iOS) Your minimum iOS version must be 9.0 or higher □ In your Flutter project directory go to android/app/src/main/AndroidManifest.xml and find the ✅ ( Android) Your API key must be added to the application manifest Replace the value (or Flutter variable) with 20. □ In your Flutter project directory go to android/app/adle and search for minSdkVersion inside the defaultConfig section. ✅ ( Android) Your minimum Android SDK version must be set to 20 or higher Configuring the appĭepending on the platform you want to support, additional configuration steps are required. This widget is the root of your application.In a production app, you should read about access limitations for your API key. Import 'package:google_maps_flutter/google_maps_flutter.dart'
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |