搜索插件、代码仓与 APP 分类

bound_location_picker 封面
插件详情v0.0.1

bound_location_picker

一个由官方 google_maps_flutter 插件创建的 Flutter 包,可帮助您在边界内选择位置。

AndroidiOSWeb
近 30 天下载
47
喜欢数
3
Pub 分数
140

安装插件

flutter pub add bound_location_picker

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,通过集成 Google 地图功能,使用户能够在定义的边界内选择位置。该包基于官方的 google_maps_flutter 插件构建,通过将选择限制在特定地理区域,提供了对位置选择的增强控制。适用于需要在预定义区域内进行精确位置输入的应用程序,例如配送服务或活动签到。该包支持 Android、iOS 和 Web 平台,确保跨平台一致性。

适合场景

  • 配送区域选择
  • 事件位置注册
  • 地理围栏区域导航
  • 基于地图的表单输入
  • 边界内的位置验证

主要特点

  • 边界限制的位置选择
  • 与 google_maps_flutter 的集成
  • 跨平台支持(Android、iOS、Web)
  • 可自定义的地图边界
  • 实时位置反馈

适合对象

  • 需要地理围栏的应用程序
  • 位置感知表单
  • 配送和物流应用
  • 事件管理工具
  • 以地图为中心的用户界面

使用建议

  • 需要 Google Maps API 密钥
  • 限制为有界区域选择
  • 依赖于 google_maps_flutter
  • Web 支持可能存在渲染差异
  • 用户必须启用位置权限

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Bound Location Picker for Flutter

Pub Version

A Flutter package created by the official google_maps_flutter plugin, which can help you to picked locations within a boundary.

Highlighted feature
  • Pick location within the Polygon boundary
  • Pick location within the Circular Radius boundary

Made by @Hasan

Android iOS Web
Support SDK 20+ iOS 11+ Same as Flutter's
Regular Picker Circle Boundary Polygon Boundary

💻 Usage

First, add bound_location_picker as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter

  bound_location_picker: ^update_version

Don't forget to flutter pub get.

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. 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

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)
  }
}
Web

You'll need to modify the web/index.html file of your Flutter Web application to include the Google Maps JS SDK.

Check the google_maps_flutter_web README for the latest information on how to prepare your App to use Google Maps on the web.

Sample Usage
class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: BoundLocationPicker(
          initialCameraPosition: const LatLng(24.540725, 89.631088),
          onPickedLocation: (LatLng? location) {
            ///TODO do something using location 
          },
          onLocationUpdateListener: (LatLng? location) {
            ///TODO do something with current location
          },
          locationPickerImage: const AssetImage("assets/pin_point.png"),
          circleBoundary: CircleBoundary(radius: 800),
          enablePickedButton: true,
        ),
      ),
    );
  }
}
👨🏻‍💻Contribute to the project

All contributions are welcome.

GitHub

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目

暂无相关数据。