搜尋套件、儲存庫與 APP 分類

套件詳情v8.3.0

google_maps

使用此套件,您將能夠從 Dart 程式碼中使用 Google Maps JavaScript API。

Web
近 30 天下載
118萬
喜歡數
125
Pub 分數
160

安裝套件

flutter pub add google_maps

套件介紹

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

google_maps 套件讓 Dart 應用程式能夠整合並與 Google Maps JavaScript API 互動,主要適用於 Web 平台。它在 Dart 程式碼與 Google Maps 功能之間建立橋樑,讓開發者能在 Flutter Web 應用中直接嵌入互動地圖、顯示標記、處理使用者互動,並自訂地圖檢視。此套件專為需要存取完整 Google Maps JavaScript API 的 Web 環境設計。它透過 Dart 接口支援動態地圖渲染與事件處理。

適用情境

  • 在網頁應用中嵌入互動式地圖
  • 顯示位置標記和資訊視窗
  • 處理使用者地圖互動,例如點擊和縮放
  • 自定地圖樣式和圖層
  • 將地理定位功能與地圖整合

主要特色

  • 僅限網頁的 Google 地圖整合
  • Google Maps JavaScript API 的 Dart 接口
  • 支援標記、多邊形和覆蓋層
  • 事件驅動的地圖互動模型
  • 透過 API 配置進行地圖自訂

適合對象

  • 需要高級地圖功能的Flutter Web應用程序
  • 使用 Dart 的 Google Maps JavaScript API 的開發人員
  • 需要在網頁上進行互動式地圖可視化的項目
  • 需要對地圖行為和樣式進行精確控制的應用程式

使用建議

  • 僅限網頁平台
  • 需要有效的 Google Maps API 金鑰
  • 依賴外部 JavaScript 庫加載
  • 可能需要額外的設定才能用於生產部署
  • 不相容移動平台

原始 README

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

Dart Google Maps

This project is a library to use Google Maps JavaScript API v3 from dart scripts.

Usage

To use this library in your code:

  • add a dependency in your pubspec.yaml :

    dependencies:
      google_maps:
    
  • add import in your dart code:

    import 'package:google_maps/google_maps.dart';
    
  • Include the Maps API JavaScript using a script tag before your dart script.

    <script src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
    

Please see the Google Maps JavaScript API v3 Getting Started guide for information about obtaining an API Key.

A very simple example :

import 'package:google_maps/google_maps.dart';
import 'package:web/web.dart';

void main() {
  final mapOptions = MapOptions()
    ..zoom = 8
    ..center = LatLng(-34.397, 150.644);
  GMap(document.getElementById('map-canvas') as HTMLElement, mapOptions);
}

Coverage

The library covers all Google Maps JavaScript API v3 and its Libraries.

To use one or more Google Maps Library:

  • add import in your dart code:

    import 'package:google_maps/google_maps_LIBRARY1.dart';
    import 'package:google_maps/google_maps_LIBRARY2.dart';
    
  • Include the Maps API JavaScript using a script tag.

    <script src="http://maps.googleapis.com/maps/api/js?libraries=LIBRARY1,LIBRARY2"></script>
    

NB: This package doesn't support neither alpha or beta elements/libraries.

Examples

Examples found at https://google-developers.appspot.com/maps/documentation/javascript/examples/ are available in a dart version at https://github.com/a14n/dart-google-maps in the example directory.

License

Apache 2.0

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案