搜尋套件、儲存庫與 APP 分類

套件詳情v4.1.7

google_map_location_picker

🌍 基於 google_maps_flutter 的 Flutter 地圖位置選擇器

近 30 天下載
158
喜歡數
238
Pub 分數
35

安裝套件

flutter pub add google_map_location_picker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,讓使用者能透過直覺介面在 Google 地圖上選擇位置。基於 google_maps_flutter 建構,提供一種無縫的方式來選擇座標並取得地址詳細資訊。非常適合需要位置輸入的應用程式,例如送貨服務、旅遊應用或活動規劃工具。此選擇器支援互動式地圖導航、標記放置與自動地理編碼。它簡化了將基於地圖的位置選擇整合至 Flutter 應用程式的過程,而無需進行大量自訂開發。

適用情境

  • 選擇收貨地址
  • 活動預訂地點
  • 定位用戶簽到
  • 整合地圖為基礎的表單
  • 設定共乘應用中的取車點

主要特色

  • 互動式 Google 地圖整合
  • 標記位置和拖曳支援
  • 從地圖點擊自動地理編碼
  • 可自定義的 UI 組件
  • 回傳緯度、經度與格式化地址

適合對象

  • 需要精確位置輸入的應用
  • 使用 Google 地圖的 Flutter 開發人員
  • 位置感知表單欄位
  • 旅行和物流平台
  • 面向使用者的地址選擇介面

使用建議

  • 需要 Google Maps API 金鑰
  • 僅限 Android 和 iOS(無網頁支援)
  • 依賴於 google_maps_flutter 插件
  • 可能需要額外的權限以存取位置
  • 性能取決於地圖渲染品質

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

google_map_location_picker Pub

Location picker using the official google_maps_flutter.

I made This plugin because google deprecated Place Picker.

Demo

Using

Pubspec changes:

      dependencies: 
      
        google_maps_flutter: ^0.5.30
        google_map_location_picker: ^3.3.4
        flutter_localizations:
          sdk: flutter

For message localization inside the library please add in MaterialApp

import 'package:google_map_location_picker/generated/l10n.dart' as location_picker;
import 'package:flutter_localizations/flutter_localizations.dart';

MaterialApp(
  localizationsDelegates: const [
    location_picker.S.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: const <Locale>[
    Locale('en', ''),
    Locale('ar', ''),
  ],
  home: ...
)
import 'package:google_map_location_picker/google_map_location_picker.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

LocationResult result = await showLocationPicker(context, apiKey);

Getting Started

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:

#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: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("YOUR KEY HERE")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

you need also to define NSLocationWhenInUseUsageDescription

  <key>NSLocationWhenInUseUsageDescription</key>
  <string>This app needs your location to test the location feature of the Google Maps location picker plugin.</string>
Note

The following permissions are not required to use Google Maps Android API v2, but are recommended.

android.permission.ACCESS_COARSE_LOCATION Allows the API to use WiFi or mobile cell data (or both) to determine the device's location. The API returns the location with an accuracy approximately equivalent to a city block.

android.permission.ACCESS_FINE_LOCATION Allows the API to determine as precise a location as possible from the available location providers, including the Global Positioning System (GPS) as well as WiFi and mobile cell data.


You must also explicitly declare that your app uses the android.hardware.location.network or android.hardware.location.gps hardware features if your app targets Android 5.0 (API level 21) or higher and uses the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in order to receive location updates from the network or a GPS, respectively.

<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false"  />

The following permissions are defined in the package manifest, and are automatically merged into your app's manifest at build time. You don't need to add them explicitly to your manifest:

android.permission.INTERNET Used by the API to download map tiles from Google Maps servers.

android.permission.ACCESS_NETWORK_STATE Allows the API to check the connection status in order to determine whether data can be downloaded.

Restricting Autocomplete Search to Region

The LocationResults returned can be restricted to certain countries by passing an array of country codes into the countries parameter of showLocationPicker(). Countries must be two character, ISO 3166-1 Alpha-2 compatible. You can find code information at Wikipedia: List of ISO 3166 country codes or the ISO Online Browsing Platform.

The example below restricts Autocomplete Search to the United Arab Emirates and Nigeria

showLocationPicker(
context, "YOUR API KEY HERE",
initialCenter: LatLng(31.1975844, 29.9598339),
myLocationButtonEnabled: true,
layersButtonEnabled: true,
countries: ['AE', 'NG'],
);

Credits

The google map from Flutter's google_maps_flutter package

current location and permission from BaseflowIT's flutter-geolocator package.

The search bar from Degreat's locationpicker package.

所屬分類

依賴

依賴清單 8 項

原始碼儲存庫

使用此套件的專案