搜尋分類、套件與程式碼儲存庫

套件詳情v1.5.2

google_geocoding_api

此套件實作了 Google 地理編碼 API,支援預設與反向地理搜尋

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.3萬
喜歡數
41
Pub 分數
160

安裝套件

flutter pub add google_geocoding_api

套件介紹

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

google_geocoding_api 套件提供了一種簡單的方式,將 Google 地理編碼 API 整合到 Flutter 應用程式中,支援正向與反向地理定位搜尋。它允許使用者將位址轉換為地理座標,反之亦然,支援多個平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。該套件透過簡潔易用的方法簡化 API 互動,非常適合應用程式中的位置相關功能。使用此套件需要有效的 Google Cloud Platform API 金鑰。

適用情境

  • 地址轉座標轉換
  • 位置詳情的逆地理編碼
  • 基於地圖的應用位置搜尋
  • 位置感知天氣應用
  • 配送和物流追蹤

主要特色

  • 支援正向與反向地理編碼
  • 跨平台相容性
  • 簡單的 API 結合
  • 內建錯誤處理
  • 需要 Google Cloud API 金鑰

適合對象

  • 需要位置服務的行動和網頁應用
  • 需要地址解析的應用程式
  • 使用 Google 地圖後端的開發人員
  • 基於位置的分析工具
  • 即時導航應用

使用建議

  • 需要 Google Cloud Platform API 金鑰
  • 根據查詢量可能會產生使用費用
  • 速率限制已套用
  • 需要網路連接
  • API 金鑰在生產環境中必須受到保護

原始 README

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

Pub License: MIT

Buy Me A Coffee


Introduction

This package implement Google Geocoding API with only dart dependency(without flutter).
Before working with the package, be sure to read Before you begin and create an API key in Google Developer Console.

USAGE

Geocoding (latitude/longitude lookup)

This is example code how to use Geocoding Search. Before use it please read Geocoding (latitude/longitude lookup)

import 'package:google_geocoding_api/google_geocoding_api.dart';

Future<void> main() async {
  const String googelApiKey = 'YOUR_API_KEY';
  final bool isDebugMode = true;  
  final api = GoogleGeocodingApi(googelApiKey, isLogged: isDebugMode);  
  final searchResults = await api.search(
    'Boston',
    language: 'en',
  );
}

Reverse geocoding (address lookup)

This is example code how to use Geocoding Reverse Search. Before use it please read Reverse geocoding (address lookup)

import 'package:google_geocoding_api/google_geocoding_api.dart';

Future<void> main() async {
  const String googelApiKey = 'YOUR_API_KEY';
  final bool isDebugMode = true;  
  final api = GoogleGeocodingApi(googelApiKey, isLogged: isDebugMode);  
  final reversedSearchResults = await api.reverse(
    '42.360083,-71.05888',
    language: 'en',
  );
}

Place geocoding

This is example code how to use Place Geocoding. Before use it please read Place Geocoding

import 'package:google_geocoding_api/google_geocoding_api.dart';

Future<void> main() async {
  const String googelApiKey = 'YOUR_API_KEY';
  final bool isDebugMode = true;  
  final api = GoogleGeocodingApi(googelApiKey, isLogged: isDebugMode);  
  final placeSearchResults = await api.placeGeocoding(
    'ChIJd8BlQ2BZwokRAFUEcm_qrcA',
    language: 'en',
  );
}

Pretty Address

Now you can use .mapToPretty() to get an instance of GeocodingPrettyAddress instance containing address, city, country, latitude, longitude, postalCode, state, countryCode, streetNumber, streetName, placeId.

Attention: The feature is experimental and may not work exactly as you need. Any suggestions for improvement may be written in the Issue Tracker.

  final placeSearchResults = await api.placeGeocoding(
    'ChIJd8BlQ2BZwokRAFUEcm_qrcA',
    language: 'en',
  );
  
  final prettyAddress = placeSearchResults.results.firstOrNull?.mapToPretty();

  if (prettyAddress == null) {
    return null;
  }

  print(prettyAddress.postalCode);
  print(prettyAddress.streetNumber);
  print(prettyAddress.streetName);
  print(prettyAddress.city);
  print(prettyAddress.state);
  print(prettyAddress.placeId);
  print(prettyAddress.country);
  print(prettyAddress.address);
  print(prettyAddress.countryCode);
  print(prettyAddress.latitude);
  print(prettyAddress.longitude);

Contact and bugs

Use Issue Tracker for any questions or bug reports.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。