mirai icon indicating copy to clipboard operation
mirai copied to clipboard

Feat: base implementation of google_map feature on framework

Open mtellect opened this issue 1 year ago • 4 comments

Description

This PR is intended to kickstart the process of adding a base implementation for google_maps support on framework

Create a .env file at the root of your project and add:

GOOGLE_MAP_KEY_ANDROID=YOUR_ANDROID_KEY
GOOGLE_MAP_KEY_IOS=YOUR_IOS_KEY

On Android Manifest add:

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/GOOGLE_MAP_KEY_ANDROID"
            tools:replace="android:value" />

On iOS AppDelegate.swift add:

import UIKit
import Flutter

import flutter_config
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        
        //[Google map key]
        let googleMapKey = FlutterConfigPlugin.env(for: "GOOGLE_MAP_KEY_IOS")
        GMSServices.provideAPIKey(googleMapKey!)

        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

Json example:

{
  "type": "scaffold",
  "appBar": {
    "type": "appBar",
    "title": {
      "type": "text",
      "data": "Google Map Example"
    }
  },
  "body": {
    "type": "googleMap",
    "initialCameraPosition": {
      "target": {
        "latitude": 37.42796133580664,
        "longitude": -122.085749655962
      },
      "zoom": 14.4746,
      "tilt": 10
    },
    "compassEnabled": true,
    "mapToolbarEnabled": true,
    "indoorViewEnabled": true,
    "trafficEnabled": true,
    "buildingsEnabled": true,
    "myLocationButtonEnabled": true,
    "padding": {
      "left": 50,
      "right": 10,
      "bottom": 20
    }
  }
}

Type of Change

  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Code refactor
  • [ ] Build configuration change
  • [ ] Documentation
  • [ ] Chore

mtellect avatar Mar 13 '24 18:03 mtellect

Hey @mtellect, Thank you so much for this amazing contribution 🎉. By far this is probably the biggest single contribution. 🥇

I have one request. I don't want to make the main framework bloated. Cab we create a separate package for mirai_google_map in packages folder

divyanshub024 avatar Mar 19 '24 11:03 divyanshub024

Hi @divyanshub024 , i'd refactor into packages.

mtellect avatar Mar 19 '24 11:03 mtellect

Hey @mtellect, let me know if you have any questions or need any help. :)

divyanshub024 avatar Mar 22 '24 12:03 divyanshub024

Hi @divyanshub024 i'd make updates soon as i get some bandwidth. cheers!

mtellect avatar Apr 03 '24 11:04 mtellect