パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.8.7

google_maps_pick_place

Google マップから場所を選択するのを助ける pub.dev パッケージ

30日間ダウンロード
20
いいね数
24
Pub ポイント
75

パッケージをインストール

flutter pub add google_maps_pick_place

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Google マップから場所を選択するのを簡単にするFlutterパッケージです。ユーザーがマップとインタラクションすることで場所を選択できる直感的なインターフェースを提供し、正確な地理情報入力が必要なアプリに最適です。Google マップSDKとシームレスに統合され、カスタムマーカーおよび場所の詳細情報を取得できます。膨大なボイラープレートコードを書かずに、地図ベースの場所選択を実装したい開発者向けに設計されています。

用途

  • 地図ベースの住所選択
  • フォーム内の場所ピッカー
  • 旅行または配達アプリのチェックイン
  • ジオタグ機能
  • ユーザー プロファイルの場所設定

主な機能

  • Google Maps SDK との簡単な統合
  • カスタマイズ可能なマーカーとUI
  • 詳細な位置データを返します
  • 検索とピンの配置をサポート
  • 軽量で場所選定に集中

適している対象

  • 場所を認識するアプリを開発している開発者
  • ユーザーが選択した座標を必要とするアプリ
  • Google Mapsを広く利用するプロジェクト
  • 迅速な場所入力が必要なプロトタイプ

注意事項

  • Google Maps API キーが必要です
  • Google マッププラットフォームに限定
  • オフラインマップのサポートなし
  • インターネット接続に依存します
  • UIの一貫性を確保するために追加のスタイル設定が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Google Maps Pick Place

A pub.dev package to handle picking place from google map and use the picked data in the app.

  • 🌟 Easy to use 🌟
  • 🚀 Saves a lot of time 🚀
  • ✨ It's like magic ✨

Follow Me

linkedIn GitHub followers GitHub Repo stars GitHub forks Pub Version

Features

  • Pick a place from google map
  • Search for a specific
  • Use the GPS and the current location
  • New and customizable design
  • Handle disconnected case
  • handle refuse GPS access case

Preview

Getting Started

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

  • Enable Google Map SDK for each platform.

    • Go to Google Developers Console.
    • Choose the project that you want to enable Google Maps on.
    • Select the navigation menu and then select "Google Maps".
    • Select "APIs" under the Google Maps menu.
    • To enable Google Maps for Android, select "Maps SDK for Android" in the "Additional APIs" section, then select "ENABLE".
    • To enable Google Maps for iOS, select "Maps SDK for iOS" in the "Additional APIs" section, then select "ENABLE".
    • Make sure the APIs you enabled are under the "Enabled APIs" section.

For more details, see Getting started with Google Maps Platform.

Android
  1. Set the minSdkVersion in android/app/build.gradle:
android {
    defaultConfig {
        minSdkVersion 20
    }
}

This means that app will only be available for users that run Android SDK 20 or higher.

  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 31:
android {
 compileSdkVersion 31

 ...
}
  1. 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"/>
  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found Android migration guide).
Hybrid Composition

To use Hybrid Composition to render the GoogleMap widget on Android, set AndroidGoogleMapsFlutter.useAndroidViewSurface to true.

if (defaultTargetPlatform == TargetPlatform.android) {
  AndroidGoogleMapsFlutter.useAndroidViewSurface = true;
}
iOS

To set up, specify your API key in the application delegate ios/Runner/AppDelegate.m:

#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

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("YOUR KEY HERE")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

On iOS you'll need to add the following entries to your Info.plist file (located under ios/Runner) in order to access the device's location.

Simply open your Info.plist file and add the following:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>

In addition, you need to add the Background Modes capability to your XCode project (Project > Signing and Capabilties > "+ Capability" button) and select Location Updates.g>This app needs access to location when open and in the background.

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.

<key>io.flutter.embedded_views_preview</key>
<true/>

Usage

Basic usage

You can use GoogleMapsPickPlace by pushing to a new page using Navigator, OR put as a child of any widget. When the user picks a place on the map, it will return result to 'getResult' with FullAddress type.

import 'package:flutter/material.dart';
import 'package:google_maps_pick_place/google_maps_pick_place.dart';

// ...
Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => GoogleMapsPickPlace(
          apiKey: "YOU GOOGLE MAPS API KEY",
          getResult: (FullAddress result) {
            print('${result.address}');
            /// Don't use Navigator.of(context).pop() it's build in the method
          },
        ),
      ),
    );
Note

Searching for a place feature needs a paid google map api key. With free key map and picking a place feature will work correctly without any error. But searching for a place feature will not work.

Google Maps Pick Place Properties
Parameter Type Description
apiKey String Google Map Api Token
mapLanguage Language map's language used in search and other widgets
getResult Function(FullAddress)? Method of Getting the address and position
initialPosition LatLng Initial position of the map in case there's no location and GPS is off
enableMyLocationButton bool Enable or disable the My Location button
enableSearchButton bool Enable or disable the Search button
loader Widget Widget to show while the map is loading
doneButton Widget? Widget to show when the map is done loading and apply getResult method
errorButton Widget? Widget to show when there's a corruption or there's no internet connection
zoomFactor double Zoom factor of the map (default is 5.0)
markerColor MarkerColor Marker color of the map (default is red)
FullAddress Properties
Parameter Type Description
address String? Formatted address
position Position? Position of the address

License

MIT

カテゴリー

依存関係

依存関係一覧 5 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。