Flutter Google Map Example

Overview

Flutter Google Map Example

Say Thanks!

A Flutter application demonstrate google map.

Preview

Listener and Marker Compass MapTypes
Screenshot Screenshot Screenshot

Plugin

google_maps_flutter from flutter team.

Usage

To use this plugin, add

 google_maps_flutter: latest_version

as a dependency in your pubspec.yaml file.

Getting Started

Get an API key at https://cloud.google.com/maps-platform/.

Android

Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="YOUR KEY HERE"/>

iOS

Specify your API key in the application delegate ios/Runner/AppDelegate.m:

Objective-C

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GMSServices provideAPIKey:@"YOUR KEY HERE"];
  [GeneratedPluginRegistrant registerWithRegistry:self];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

Swift

import UIKit
import Flutter
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    GMSServices.provideAPIKey("YOUR_API_KEY")
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

Both

You can now add a GoogleMap widget to your widget tree.

The map view can be controlled with the GoogleMapController that is passed to the GoogleMap's onMapCreated callback.

Contribute

  1. Fork the the project
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make required changes and commit (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Questions? 🤔

Hit me on

Donate

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of

  • PayPal
  • Google Pay (bhavikmakwana43@okhdfcbank)

License

Copyright (c) 2018 Bhavik Makwana

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You might also like...

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Sep 14, 2022

A flutter package for select a city from svg map.

A flutter package for select a city from svg map.

City Picker From Map A flutter package for select a city from svg map. Supported countries (+150) are here. Screenshots Getting Started In the pubspec

Nov 17, 2022

Map Picker for Flutter

Map Picker for Flutter

Map Pin Picker A Vendor-free map Library for Easy and Quick Usage. Follow the steps to integrate Google Maps (https://pub.dev/packages/google_maps_flu

Jul 15, 2022

Flutter plugin to display a simple flat world map with animated points in real time

Flutter plugin to display a simple flat world map with animated points in real time

Flutter Simple Map Flutter plugin to display a simple flat world map with animated points in real time. Can be used as a presentation of online users,

Dec 8, 2022

A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Installation Add flutter_map to your pubspec: dependencies: flutter_map: any # or the

Dec 28, 2022

🌍 Map location picker component for flutter Based on google_maps_flutter

🌍 Map location picker component for flutter Based on google_maps_flutter

google_map_location_picker Location picker using the official google_maps_flutter. I made This plugin because google deprecated Place Picker. Using Pu

Dec 5, 2022

A map widget with live position updates for Flutter

A map widget with live position updates for Flutter

Livemap A map widget with live position updates. Based on Flutter map and Geolocator. Provides a controller api to handle map state changes. Example i

Sep 28, 2022

A Flutter package for place search using MapBox Api and for Static map image

A Flutter package for place search using MapBox Api and for Static map image

About This package provides easy api calls to MapBox Search API. Also, it contains an static map image generator 😆 . Maki Icons can be used now in ma

Dec 2, 2022

A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Usage Add flutter_map to your pubspec: dependencies: flutter_map: any # or the latest

Dec 13, 2022
Comments
  • Error intergraded on android, has api key already

    Error intergraded on android, has api key already

    Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... Resolving dependencies... Gradle task 'assembleDebug'... Built build/app/outputs/apk/debug/app-debug.apk. Installing build/app/outputs/apk/app.apk... Syncing files to device Android SDK built for x86... D/ ( 2368): HostConnection::get() New Host Connection established 0xa601db00, tid 2381 D/ ( 2368): HostConnection::get() New Host Connection established 0xa601d740, tid 2382 I/zzbz ( 2368): Making Creator dynamically I/DynamiteModule( 2368): Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221 I/DynamiteModule( 2368): Selected remote version of com.google.android.gms.maps_dynamite, version >= 221 W/System ( 2368): ClassLoader referenced unknown path: W/System ( 2368): ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000013/n/x86 I/Google Maps Android API( 2368): Google Play services client version: 12451000 I/Google Maps Android API( 2368): Google Play services package version: 14574022 E/MethodChannel#flutter/platform_views( 2368): Failed to handle method call E/MethodChannel#flutter/platform_views( 2368): java.lang.RuntimeException: API key not found. Check that is in the element of AndroidManifest.xml E/MethodChannel#flutter/platform_views( 2368): at com.google.maps.api.android.lib6.drd.q.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):20) E/MethodChannel#flutter/platform_views( 2368): at com.google.maps.api.android.lib6.auth.e.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):10) E/MethodChannel#flutter/platform_views( 2368): at com.google.maps.api.android.lib6.impl.f.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):3) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.internal.b.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):19) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.internal.CreatorImpl.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):56) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.internal.CreatorImpl.newMapViewDelegate(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):31) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.internal.i.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):62) E/MethodChannel#flutter/platform_views( 2368): at fu.onTransact(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-219897028):4) E/MethodChannel#flutter/platform_views( 2368): at android.os.Binder.transact(Binder.java:499) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.internal.maps.zza.transactAndReadException(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.internal.zzf.zza(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.MapView$zzb.createDelegate(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.dynamic.DeferredLifecycleHelper.zza(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at com.google.android.gms.maps.MapView.onCreate(Unknown Source) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugins.googlemaps.GoogleMapController.init(GoogleMapController.java:110) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugins.googlemaps.GoogleMapBuilder.build(GoogleMapBuilder.java:23) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugins.googlemaps.GoogleMapFactory.create(GoogleMapFactory.java:26) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:130) E/MethodChannel#flutter/platform_views( 2368): at android.app.Dialog.dispatchOnCreate(Dialog.java:389) E/MethodChannel#flutter/platform_views( 2368): at android.app.Dialog.show(Dialog.java:293) E/MethodChannel#flutter/platform_views( 2368): at android.app.Presentation.show(Presentation.java:235) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.platform.VirtualDisplayController.(VirtualDisplayController.java:75) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:47) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.platform.PlatformViewsController.createPlatformView(PlatformViewsController.java:179) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.platform.PlatformViewsController.onMethodCall(PlatformViewsController.java:118) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E/MethodChannel#flutter/platform_views( 2368): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#flutter/platform_views( 2368): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter/platform_views( 2368): at android.os.MessageQueue.next(MessageQueue.java:323) E/MethodChannel#flutter/platform_views( 2368): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#flutter/platform_views( 2368): at android.app.ActivityThread.main(ActivityThread.java:6077) E/MethodChannel#flutter/platform_views( 2368): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter/platform_views( 2368): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) E/MethodChannel#flutter/platform_views( 2368): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) I/art ( 2368): Background partial concurrent mark sweep GC freed 17209(926KB) AllocSpace objects, 1(20KB) LOS objects, 40% free, 5MB/9MB, paused 8.821ms total 40.994ms D/ ( 2368): HostConnection::get() New Host Connection established 0xa601dc80, tid 2397 D/EGL_emulation( 2368): eglMakeCurrent: 0xa1b7a240: ver 2 0 (tinfo 0xa6003660) E/flutter ( 2368): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception: E/flutter ( 2368): PlatformException(error, API key not found. Check that is in the element of AndroidManifest.xml, null) E/flutter ( 2368): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7) E/flutter ( 2368): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18) E/flutter ( 2368): E/flutter ( 2368): #2 AndroidViewController._create (package:flutter/src/services/platform_views.dart:579:54) E/flutter ( 2368): E/flutter ( 2368): #3 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:504:14) E/flutter ( 2368): E/flutter ( 2368): #4 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:177:29) E/flutter ( 2368): E/flutter ( 2368): #5 RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:158:5) E/flutter ( 2368): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9) E/flutter ( 2368): #7 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15) E/flutter ( 2368): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #9 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11) E/flutter ( 2368): #10 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7) E/flutter ( 2368): #11 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7) E/flutter ( 2368): #12 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14) E/flutter ( 2368): #13 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #14 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #15 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #16 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #17 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11) E/flutter ( 2368): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #21 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #23 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #29 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7) E/flutter ( 2368): #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13) E/flutter ( 2368): #34 RenderOffstage.performLayout (package:flutter/sr

    opened by Nimto007 3
  • Fix build error for iOS

    Fix build error for iOS

    Build failed with this error: “AppDelegate.swift:11:5: Use of unresolved identifier 'GMSServices'; did you mean 'NetService'?”, and I fixed the error.

    opened by mono0926 0
Owner
Bhavik Makwana
Google Developer Expert for Flutter and Dart | Speaker | Blogger | Google Certified Associate Android Developer
Bhavik Makwana
Flutter Google Map Example

Flutter Google Map Example A Flutter application demonstrate google map. Preview Listener and Marker Compass MapTypes Plugin google_maps_flutter from

Bhavik Makwana 67 Sep 14, 2021
A google map example for flutter

Flutter Google Map Example - Day 41 class Afgprogrammer extends Flutter100DaysOf

Behruz Hurramov 5 Nov 24, 2022
Stateful map controller for Flutter Map

Map controller Stateful map controller for Flutter Map. Manage markers, lines and polygons. View the web demo Usage import 'dart:async'; import 'packa

null 55 Sep 15, 2022
A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC.

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC. Through the combination of 5g + AI, colle

null 24 Jan 14, 2022
Custom map markers - Custom Map Markers Using Flutter

Custom Map Markers Not only "Everything is a widget" also "Everywhere is a widge

null 8 Oct 19, 2022
Flutter Tutorial - Google Map with Live Location Tracking

Flutter Tutorial - Google Map with Live Location Tracking Build Google Map app with Live Location Tracking in Flutter. ✌   App Preview Android Preview

Samuel Adekunle 10 Dec 22, 2022
How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter Let’s develop a customised Google Maps for the best user experience. Visit : https://medium.com/flut

Jaimil Patel 19 Dec 6, 2022
Customized google map with widget markers. Enables to show markers with widget code.

widget_marker_google_map Google map with widget markers. Set up Follow the steps on google_maps_flutter document. Usage Same as google_maps_flutter ex

Santa Takahashi 8 Dec 4, 2022
Google Places - Google places autocomplete widgets for flutter.

flutter_google_places Google places autocomplete widgets for flutter. Getting Started For help getting started with Flutter, view our online documenta

Flutter Community 267 Jan 5, 2023
A migration of Google Maps Application with Flutter & Google Maps APIs including: Maps SDK for Android & IOS, Places API & polylines

google_maps A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

TAD 1 Mar 4, 2022