Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter google maps app

Flutter Google Maps APP

a new flutter project.

getting started

flutter project

  • add this to your package’s pubspec.yaml file:

    dependencies: map_view: "^0.0.12"

getting started

generate your api key

  1. go to: https://console.developers.google.com/
  2. enable google maps android api
  3. enable google maps sdk for ios
  4. under credentials, choose create credential.
    • note: for development, you can create an unrestricted api key that can be used on both ios & android.
      for production it is highly recommended that you restrict.

the way you register your api key on ios vs android is different. make sure to read the next sections carefully.

ios

the maps plugin will request your users location when needed. ios requires that you explain this usage in the info.plist file

  1. set the nslocationwheninuseusagedescription in ios/runner/info.plist. example:
    <key>nslocationwheninuseusagedescription</key>
    <string>using location to display on a map</string>
  1. prior to using the map plugin, you must call mapview.setapikey(string apikey). example:
   import 'package:map_view/map_view.dart';
   
   void main() {
     mapview.setapikey("<your_api_key>");
     runapp(new myapp());
   }

note: if your ios and android api key are different, be sure to use your ios api key here.

  1. add code to show the mapview.
    //create an instance variable for the mapview
    var _mapview = new mapview();
    
    
    //add a method to call to show the map.
    void showmap() {
        _mapview.show(new mapoptions(showuserlocation: true));
    }
      
    
    
  2. run your application on an ios device or simulator.
    confirm that when you display the map you see map detail.
    if you only see a beige screen it’s possible that your api key is incorrect. when your api
    key is incorrect you’ll see messages like this in the console:
clientparametersrequest failed, 7 attempts remaining (0 vs 12). error domain=com.google.httpstatus code=400 "(null)" userinfo={data=<>}

common api key problems for ios

  1. your bundle id does not match what is registered in the google api console.
    when you create an restricted api key in the google api console it asks you to specify your ios bundle id.
    make sure that your ios bundle identifier matches the one you registered in the console.
  2. using the wrong key. if you made a separate key for ios and android,
    make sure you are using the ios key in the mapview.setapikey() call.

android

you will be making multiple edits to your androidmanifest.xml file. in your flutter project, you can
find this file location under android/app/src/main

  1. in your androidmanifest.xml, add the following uses-permission above the tag.
        <uses-permission android:name="android.permission.access_fine_location"/>
        <uses-permission android:name="android.permission.access_coarse_location"/>
    
  2. in your androidmanifest.xml, add the following lines inside of the application tag. be sure to replace your_api_key with the one you generated.
        <meta-data android:name="com.google.android.maps.v2.api_key" android:value="your_api_key"/>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
    
  3. add the mapactivity to your androidmanifest.xml
        <activity android:name="com.apptreesoftware.mapview.mapactivity" android:theme="@style/theme.appcompat.light.darkactionbar"/>
    
  4. in your android/build.gradle file. under buildscript dependencies add:
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
    
  5. run your application on an android device or simulator.
    confirm that when you display the map you see map detail.
    if you only see a beige screen it’s possible that your api key is incorrect.

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top