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

插件详情v0.0.19

google_maps_webservice

Google 地图 Web 服务 [API](https://developers.google.com/maps/web-services)

近 30 天下载
9700
喜欢数
163
Pub 分数
30

安装插件

flutter pub add google_maps_webservice

插件介绍

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

google_maps_webservice 包提供了一个 Dart 客户端,用于与 Google Maps Web Services API 进行交互。它使 Flutter 应用能够通过 HTTP 请求访问地理编码、地点、路线、距离矩阵以及其他地图相关数据。该包专为需要程序化访问 Google 地图基础设施的开发者设计,简化了集成过程,无需直接管理 API 调用。该包轻量且专注于核心 Web 服务功能,非常适合在 Flutter 应用中进行类似后端的操作。

适合场景

  • 将地址转换为坐标
  • 获取附近地点和详细信息
  • 计算路线和旅行距离
  • 将地图数据集成到基于位置的功能中
  • 在无服务器函数中处理地图数据

主要特点

  • Google Maps API 的简单 HTTP 客户端
  • 支持多个 Google Maps Web 服务
  • 干净、类型安全的请求和响应模型
  • 与 Flutter 应用轻松集成
  • 文档齐全且持续维护

适合对象

  • 开发位置感知的 Flutter 应用程序的开发者
  • 需要从 Google Maps Web Services 获取地图数据的应用程序
  • 需要地理编码或路线计算的项目
  • Flutter 应用中的后端逻辑
  • 大量使用 Google 地图 API 的团队

使用建议

  • 需要有效的 Google Cloud API 密钥
  • 不包含地图UI渲染(请与 google_maps_flutter 一起使用)
  • 仅限网页服务端点,不支持实时地图
  • 根据 Google Cloud 计费应用速率限制
  • 不适用于离线地图功能

原始 README

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

Build Status codecov Star on Github Buy Me A Coffee

google_maps_webservice

General Information

This is the Dart Library for Google Maps Webservices. You can find the Google Maps Platform Documentation here, but if you're new to this, you may want to start here.

API Key

To use this library you need a Web API key. Follow these steps to acquire the key relevant to your particular Dart application.

These keys are not to be used individually as Android or iOS API keys, but they are instead meant to be used in your Dart application.

Availables API

Usage

Geocoding
import "package:google_maps_webservice/geocoding.dart";

final geocoding = GoogleMapsGeocoding(apiKey: "<API_KEY>");
final geocoding = GoogleMapsGeocoding(apiKey: "<API_KEY>", httpClient: BrowserClient());
final geocoding = GoogleMapsGeocoding(baseUrl: "http://myProxy.com");

GeocodingResponse response = await geocoding.searchByAddress("1600 Amphitheatre Parkway, Mountain View, CA");
Places
import "package:google_maps_webservice/places.dart";

final places = GoogleMapsPlaces(apiKey: "<API_KEY>");
final places = GoogleMapsPlaces(apiKey: "<API_KEY>", httpClient: BrowserClient());
final places = GoogleMapsPlaces(baseUrl: "http://myProxy.com");

PlacesSearchResponse response = await places.searchNearbyWithRadius(Location(lat: 31.0424, lng: 42.421), 500);
PlacesSearchResponse response = await places.searchNearbyWithRankby(Location(lat: 31.0424, lng: 42.421), "distance");
PlacesSearchResponse response = await places.searchByText("123 Main Street");

PlacesDetailsResponse response = await places.getDetailsByPlaceId("PLACE_ID");
PlacesDetailsResponse response = await places.getDetailsByReference("REF");
Timezone
import "package:google_maps_webservice/timezone.dart";

final timezone = GoogleMapsTimezone(apiKey: "<API_KEY>");
final timezone = GoogleMapsTimezone(apiKey: "<API_KEY>", httpClient: BrowserClient());
final timezone = GoogleMapsTimezone(baseUrl: "http://myProxy.com");

TimezoneResponse response = await timezone.getByLocation(Location(lat: 31.0424, lng: 42.421));
TimezoneResponse response = await timezone.getByLocation(Location(lat: 31.0424, lng: 42.421), timestamp: DateTime.utc(2019, 4, 24));
TimezoneResponse response = await timezone.getByLocation(Location(lat: 31.0424, lng: 42.421), timestamp: DateTime.utc(2019, 4, 24), language: 'es');
Static Map

  StaticMap mapStatic = StaticMap(
    apiKey,
    markers: List.from([
      Location(lat: 23.721160, lng: 90.394435),
      Location(lat: 23.732322, lng: 90.385142),]
    ),
    path: Path(
      enc: 'svh~F`j}uOusC`bD',
      color: 'black',
    ),
    scale: 'false'
  )

  String url = mapStatic.getUrl();

  Image.network(url)


Proxy

In case of using a proxy the baseUrl can be set. The apiKey is not required in case the proxy sets it. (Not storing the apiKey in the app is good practice)

Feature Requests and Issues

Please file feature requests and bugs at the issue tracker.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目