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

插件详情v1.0.3

geocode

用于发起地理编码请求的包。它提供了两种方法,可将坐标转换为位置,或将地址转换为坐标。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.3万
喜欢数
124
Pub 分数
160

安装插件

flutter pub add geocode

插件介绍

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

geocode 包可实现地理坐标与物理地址之间的无缝转换。它提供两种核心方法:一种是将坐标反向编码为人类可读的位置,另一种是将地址正向编码为纬度和经度。该包专为跨平台使用而设计,支持 Android、iOS、Web、macOS、Windows 和 Linux。该包轻量且易于与需要位置服务的 Flutter 应用集成。由 imanol.dev 开发,它无需外部依赖即可简化地理定位任务。

适合场景

  • 用于用户位置显示的逆地理编码
  • 从GPS坐标查找地址
  • 基于位置的搜索功能
  • 从地址放置地图标记
  • 旅行或配送应用中的地理定位
  • 将地图与地址输入集成

主要特点

  • 用于正向和反向地理编码的简单 API
  • 跨平台兼容性
  • 轻量且无依赖
  • 支持所有主要平台
  • 与 Flutter 的轻松集成
  • 简洁、可读的响应结构

适合对象

  • 开发集成地图的应用程序的开发者
  • 需要地址转坐标转换的应用
  • 跨平台的定位感知应用程序
  • 原型化地理位置功能
  • 需要最少地理编码开销的项目

使用建议

  • 依赖外部地理编码服务(例如,Google 地图、OpenStreetMap)
  • 根据后端情况,可能会应用速率限制
  • 请求需要互联网连接
  • 精度取决于底层地理编码提供方
  • 无内置缓存机制
  • 根据提供方,可能需要 API 密钥配置

原始 README

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

Geocode library

workflow name likes popularity pub points

Introduction

Package to make Geocode requests. It exposes two methods to translate coordinates into locations and addresses into coordinates.

It's a basic implementation of the most useful methods in the Dart language of the following API geocode.xyz.

It's free for one request per second quota. Register in the above site to get an API Key and increase the number of requests to 10 per second. These are paid plans that allow more requests per second. For more information, review the site.

Installation

dependecies:
  geocode: 1.0.3

Example

See example/main.dart

import 'package:geocode/geocode.dart';

void main() async {
  GeoCode geoCode = GeoCode();

  try {
    Coordinates coordinates = await geoCode.forwardGeocoding(
        address: "532 S Olive St, Los Angeles, CA 90013");

    print("Latitude: ${coordinates.latitude}");
    print("Longitude: ${coordinates.longitude}");
  } catch (e) {
    print(e);
  }
}

Methods

Constructor

Library GeoCode class constructor, includes an optional parameter to set the apiKey.

GeoCode({this.apiKey});
Reverse Geocode

Method to translate a pair of latitude and longitude coordinates into a real address.

Future<Address> reverseGeocoding({double latitude, double longitude})
Forward Geocode

Method to translate an address into a pair of latitude and longitudecoordinates.

Future<Coordinates> forwardGeocoding({String address})

Responses

Reverse Geocode
Attribute Type Description
elevation double The elevation in meters.
timezone String The timezone.
geoNumber int geocode is an alphanumeric string representing both latitude and longitude as one value. Nearby points will have similar geocodes.
streetNumber int The properly formated street address number to be returned.
streetAddress String The properly formated street address to be returned.
city String The properly formated city name to be returned.
countyCode String The properly formated country code to be returned.
countryName String The properly formated country name to be returned.
region String The properly formated region to be returned.
postal String The properly formated postal code to be returned.
distance double The distance of the result location from the input location.
Forward Geocode
Attribute Type Description
latitude double Latitude coordinate value.
longitude double Longitude coordinate value.

Exceptions

  • AccountOutOfCreditsException: auth has ran out of credits.
  • AuthTokenNotFoundException: authentication token: auth not found.
  • PostalCodeFormatException: postal Code is not in the proper Format.
  • RequestThrottledException: request Throttled.
  • InvalidQueryException: supply a valid query.
  • EmptyResultException: your request did not produce any results. Check your spelling and try again.
  • UnknownErrorException: unkown error.

Dependencies

http: '>=0.13.0 <2.0.0'

License

BSD 3-Clause License

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目