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

套件詳情v2.0.7

flutter_geofire

一個 Flutter 外掛,用於取得附近地點的即時更新。GeoFire 是一個開源程式庫,可讓您根據地理位置儲存和查詢一組鍵。

AndroidiOS
近 30 天下載
434
喜歡數
106
Pub 分數
130

安裝套件

flutter pub add flutter_geofire

套件介紹

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

Flutter GeoFire 是一個 Flutter 插件,可使用 GeoFire(一個開源庫)實現即時基於位置的查詢。它允許開發者根據地理坐標儲存和檢索資料,非常適合需要附近地點偵測的應用程式。透過與 Firebase 集成,支援使用者移動時的即時更新,確保精確且動態的位置追蹤。此外,該插件簡化了行動應用中的地理空間運算,特別是涉及地圖或鄰近警示的應用。

適用情境

  • 即時位置追蹤
  • 查找附近的興趣點
  • 即時共乘服務
  • 基於位置的通知
  • 地理圍欄實作

主要特色

  • 即時地理位置更新
  • 與 Firebase 集成
  • 支援 Android 與 iOS
  • 高效的空间查詢
  • 附近位置篩選

適合對象

  • 需要基於接近度功能的應用程式
  • 計程車或送貨平台
  • 社交網絡與位置共享
  • 事件發現應用
  • 位置感知的物聯網應用

使用建議

  • 需要 Firebase 設定
  • 限於地理空間查詢
  • 依賴網路連接
  • 可能影響電池壽命
  • 需要正確的權限處理

原始 README

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

flutter_geofire

A Flutter plugin to use the GeoFire Api

For Flutter plugins for other products, see mrdishant@github

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

iOS Installation

In your project's pod file add the below line

pod 'GeoFire', :git => 'https://github.com/mrdishant/geofire-objc'

Example:

            target 'Runner' do
            use_frameworks!
            use_modular_headers!
            pod 'GeoFire', :git => 'https://github.com/mrdishant/geofire-objc'
            
            flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
            end

Usage

GeoFire — Realtime location queries with Firebase.

GeoFire is an open-source library that allows you to store and query a set of keys based on their geographic location.

At its heart, GeoFire simply stores locations with string keys. Its main benefit however, is the possibility of querying keys within a given geographic area - all in realtime.

GeoFire uses the Firebase database for data storage, allowing query results to be updated in realtime as they change. GeoFire selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.

Quickstart

Initalize GeoFire with path to keys in Realtime Database

String pathToReference = "Sites";
Intializing geoFire
Geofire.initialize(pathToReference);

Also don't forget to add indexOn in your Realtime Database rules

Example: Just change the 'Sites' with your pathToReference

    {
      "rules": {
        ".read":true,
        ".write": true,
          "Sites": {
          ".indexOn": ["g"]
        }
      }
    }   
Setting location data

Here setLocation method is used and first is the unique id of the place and other two parameters are latitude and longitude of that place.

bool response = await Geofire.setLocation(
        new DateTime.now().millisecondsSinceEpoch.toString(),
        30.730743,
        76.774948)
Retrieving a location

Retrieving a location for a single key in GeoFire happens like below:

Map<String, dynamic> response =
        await Geofire.getLocation("AsH28LWk8MXfwRLfVxgx");

print(response);
Geo Queries

GeoFire allows you to query all keys within a geographic area using GeoQuery objects. As the locations for keys change, the query is updated in realtime and fires events letting you know if any relevant keys have moved. GeoQuery parameters can be updated later to change the size and center of the queried area.

Geofire.queryAtLocation(30.730743, 76.774948, 5).listen((map) {
        print(map);
        if (map != null) {
          var callBack = map['callBack'];

          //latitude will be retrieved from map['latitude']
          //longitude will be retrieved from map['longitude']

          switch (callBack) {
            case Geofire.onKeyEntered:
              keysRetrieved.add(map["key"]);
              break;

            case Geofire.onKeyExited:
              keysRetrieved.remove(map["key"]);
              break;

            case Geofire.onKeyMoved:
            // Update your key's location
              break;

            case Geofire.onGeoQueryReady:
            // All Intial Data is loaded
            print(map['result'])

              break;
          }
        }

        setState(() {});
Stop Listening to Geo Query

To remove listeners to all queries:

bool response = await Geofire.stopListener();

print(response);

Removing a location

To remove a location and delete it from the database simply pass the location's key to removeLocation:

bool response = await Geofire.removeLocation("AsH28LWk8MXfwRLfVxgx");

print(response);                

Contributing

if you want to contribute to GeoFire, clone the repository and just start making pull requests.

git clone 'https://github.com/mrdishant/flutter_geofire'
This plugin is in development and suggestions are most welcome. Happy Coding and Be Exceptional !!

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。