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

插件详情v1.1.1

flutter_google_maps_webservices

适用于 Flutter 的 Google 地图 Web 服务(地理编码、地点、路线、距离矩阵、照片、时区、静态地图)

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.7万
喜欢数
27
Pub 分数
150

安装插件

flutter pub add flutter_google_maps_webservices

插件介绍

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

一个 Flutter 包,提供对 Google Maps Web Services 的访问,使开发者能够将地理编码、地点搜索、路线规划、距离矩阵、照片检索、时区信息和静态地图等功能集成到其应用程序中。该包支持多种平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。该包通过简洁的 Dart 接口简化了 API 交互,使开发者无需手动管理 HTTP 请求即可轻松获取地图相关数据。非常适合需要位置智能和基于地图功能的应用程序。

适合场景

  • 将地址转换为坐标
  • 搜索附近地点
  • 计算路线和出行方向
  • 获取位置之间的距离和时长
  • 显示静态地图图像
  • 根据位置获取时区详细信息

主要特点

  • 支持所有主要的 Google 地图 Web 服务
  • 跨平台兼容性
  • 简单直观的 Dart API
  • 内置错误处理
  • 异步请求管理
  • 轻量且易于集成

适合对象

  • 位置感知应用
  • 旅行和导航应用
  • 房地产和房产经纪人
  • 配送和物流服务
  • 旅游和发现平台
  • 任何需要地图数据集成的应用程序

使用建议

  • 需要一个 Google Cloud Platform API 密钥
  • 根据使用层级应用速率限制
  • 高使用量可能会产生额外费用
  • 所有操作都需要互联网连接
  • API 密钥必须在生产环境中得到保护

原始 README

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

flutter_google_maps_webservices

Build Status codecov Star on Github Buy Me A Coffee

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:flutter_google_maps_webservices/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:flutter_google_maps_webservices/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:flutter_google_maps_webservices/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.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目