搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案