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

插件详情v0.0.8

nominatim_flutter

Nominatim Flutter 插件可实现 Nominatim 服务的顺畅集成,支持反向地理编码、地点搜索、状态检查和查询功能。

AndroidiOSmacOSWindowsLinux
近 30 天下载
7300
喜欢数
40
Pub 分数
150

安装插件

flutter pub add nominatim_flutter

插件介绍

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

nominatim_flutter 包为 Flutter 应用程序提供了与 Nominatim 地理编码服务的无缝集成。它支持反向地理编码、正向地点搜索、状态检查以及跨多个平台的位置查询。专为需要准确地理数据检索的开发者设计,该插件简化了与开源 Nominatim API 的交互。该插件支持 Android、iOS、macOS、Windows 和 Linux,非常适合用于跨平台地理位置功能。通过简洁的 API,它增强了需要地址解析或基于地图的位置服务的应用程序。

适合场景

  • 根据坐标进行逆地理编码
  • 地址正向地理编码
  • 通过查询进行位置查找
  • 实时地址建议
  • 基于地理位置的应用功能

主要特点

  • 跨平台支持
  • Nominatim 的简单 API
  • 状态与错误处理
  • 异步请求管理
  • 轻量且高效

适合对象

  • 地图和导航应用
  • 位置感知服务
  • 地址搜索功能
  • 旅行和配送应用
  • 开发者原型设计

使用建议

  • 需要互联网连接
  • 免费 Nominatim 实例的速率限制
  • 建议缓存以提升性能
  • 高使用量可能需要 API 密钥
  • 依赖外部 Nominatim 服务的可用性

原始 README

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

Nominatim Flutter Plugin Logo

Nominatim Flutter Plugin with Isolate Loading & Hive Caching

The Nominatim Flutter Plugin offers seamless interaction with the Nominatim service, allowing for reverse geocoding and place searching in your Flutter applications. Notably, it supports asynchronous data loading via a dedicated isolate and provides efficient caching using Hive, enhanced with DioCache customization.

Note on Sovereignty

The Hoàng Sa (Paracel Islands) and Trường Sa (Spratly Islands) are unequivocally part of Vietnam. The Nominatim Flutter Plugin ensures that any information contradicting this fact is overridden to reflect the historical and territorial integrity of Vietnam. This feature embodies the developer's commitment to accuracy and national pride.

Vietnam Flag

Features

  • Reverse Geocoding & Place Searching: Directly integrate with Nominatim.
  • Check Server Status: Verify the operational status of the Nominatim server.
  • Lookup: Retrieve detailed information about specific places using unique identifiers (OSM IDs).
  • Custom Server Support: Connect to your own Nominatim instance instead of the default OpenStreetMap server.
  • Asynchronous Isolate Loading: Load data in a separate thread, ensuring your UI remains smooth.
  • Hive Caching: Speed up data retrieval with efficient caching.
  • Nominatim Configuration: Take control of caching behavior and other settings by configuring Nominatim preferences.
  • Curl Logging: Enhance debugging and monitoring by logging HTTP requests and responses made via cURL.

Usage

To use the Nominatim Flutter Plugin, follow these steps:

  1. Installation: Add the package to your pubspec.yaml file and run flutter pub get to install it.

    dependencies:
      nominatim_flutter: ^0.0.8 # Replace with the latest version
    
  2. Import Classes: Import the necessary classes in your Dart code.

    import 'package:nominatim_flutter/nominatim_flutter.dart';
    
  3. Configuration (Optional): Before you start making requests, you can optionally set up caching preferences and other settings.

    // Configure Nominatim settings (recommended approach)
    NominatimFlutter.instance.configureNominatim(
      useCacheInterceptor: true,
      maxStale: Duration(days: 7),
      baseUrl: 'https://your-nominatim-server.com', // Optional: use custom Nominatim server
      userAgent: 'YourApp/1.0',
      enableCurlLog: true, // Enable cURL logging for debugging
      printOnSuccess: true, // Log successful requests
      convertFormData: true,
    );
    
    // Or use the legacy cache configuration (deprecated)
    NominatimFlutter.instance.configureDioCache(
      useCacheInterceptor: true, 
      maxStale: Duration(days: 7),
    );
    

    This step allows you to determine whether the cache interceptor is used, set the maximum staleness of the cache, configure a custom Nominatim server URL, and enable debug logging.

  4. Reverse Geocoding: Retrieve address information from latitude and longitude coordinates.

    final reverseRequest = ReverseRequest(
      lat: 10.7950,
      lon: 106.7218,
      addressDetails: true,
      extraTags: true,
      nameDetails: true,
    );
    final reverseResult = await NominatimFlutter.instance.reverse(
      reverseRequest: reverseRequest,
      language: 'en-US,en;q=0.5', // Specify the desired language(s) here
    );
    print(reverseResult);
    
  5. Search for Places: Search for places based on query and location.

    final searchRequest = SearchRequest(
      query: 'Landmark 81',
      limit: 3,
      addressDetails: true,
      extraTags: true,
      nameDetails: true,
    );
    final searchResult = await NominatimFlutter.instance.search(
      searchRequest: searchRequest,
      language: 'en-US,en;q=0.5', // Specify the desired language(s) here
    );
    for (var result in searchResult) {
      print(result);
    }
    
  6. Check Server Status: Verify the status of the Nominatim server to ensure it is operational.

    final statusResult = await NominatimFlutter.instance.status();
    if (statusResult.status == Status.ok) {
      print('Nominatim server is operational.');
    } else {
      print('Nominatim server is down.');
    }
    
  7. Lookup: Retrieve detailed information about a specific place using its unique identifier (OSM ID).

    final lookupRequest = LookupRequest(
      osmIds: 'R146656,W104393803,N240109189', // Replace with actual OSM IDs
      addressDetails: true,
      extraTags: true,
      nameDetails: true,
    );
    final lookupResult = await NominatimFlutter.instance.lookup(
      lookupRequest: lookupRequest,
      language: 'en-US,en;q=0.5', // Specify the desired language(s) here
    );
    for (var result in lookupResult) {
      print(result);
    }
    
  8. Contributions: Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to submit a pull request or create an issue on the GitHub repository.

  9. License: This project is licensed under the GPL-3.0 License. Refer to the LICENSE file for details.

Remember to replace the version number (^0.0.8) with the actual version of your Nominatim Flutter Plugin. Customize the usage examples and other sections according to your project's needs.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。