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

google_map_custom_windows 封面
套件詳情v1.1.0

google_map_custom_windows

一個可自訂的 Google 地圖標記資訊視窗。您可以在 Google 地圖檢視中顯示多個資訊視窗。

AndroidiOS
近 30 天下載
1460
喜歡數
2
Pub 分數
160

安裝套件

flutter pub add google_map_custom_windows

套件介紹

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

一個可自訂的 Google 地圖標記資訊視窗套件,可實現在 Google 地圖檢視中顯示多個資訊視窗。它透過允許開發者為每個標記建立和管理自訂、互動式彈出視窗,擴展了標準標記功能。適用於需要在地圖標記中顯示豐富動態內容的應用程式,例如詳細位置資料、圖片或按鈕。此套件支援 Android 與 iOS 平台,並與 Flutter 的 Google Maps 插件無縫整合。

適用情境

  • 在地圖上顯示多個自定義資訊視窗
  • 在標記中顯示圖像和按鈕等豐富內容
  • 建立互動式地點詳細資訊面板
  • 透過自定義標記彈出視窗提升使用者體驗
  • 建構基於位置的應用程式並提供詳細的標記資訊

主要特色

  • 支援同時多個資訊視窗
  • 資訊視窗的高度可自訂UI
  • 相容 Android 和 iOS
  • 與 Google 地圖外掛輕鬆整合
  • 允許在資訊視窗內使用互動式元素

適合對象

  • 開發複雜地圖介面的開發者
  • 需要豐富標記內容的應用程式
  • 基於位置的服務,包含詳細資訊
  • 使用 Google 地圖的 Flutter 項目
  • 希望靈活自定標記的團隊

使用建議

  • 需要使用 Google 地圖 API 金鑰進行正確設定
  • 可能影響效能,因為有大量重疊的資訊視窗
  • 自定樣式需要熟悉 Flutter 小部件
  • 除了基本用法外,文件有限
  • 依賴外部GitHub倉儲的穩定性

原始 README

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

google map custom info window

A Flutter package that extends the capabilities of google_maps_flutter by allowing developers to display fully customizable info windows for markers, including the ability to show multiple info windows simultaneously on the map.

✨Features

  • Customizable Info Windows: Design your info window using any Flutter widget.
  • Multiple Info Windows: Display several info windows at once, ideal for showing details of nearby locations or clustered markers.
  • Highly Flexible: Control the content, styling, and behavior of each info window independently.
  • Easy Integration: Seamlessly integrates with your existing Maps_flutter implementation.

📸 Demo screen recording

🚀 Getting Started

  1. Add Dependencies First, ensure you have google_maps_flutter integrated into your project. Then, add google_map_custom_windows to your pubspec.yaml:

     dependencies:
       google_map_custom_windows: ^1.0.1
    

    Run flutter pub get to fetch the new dependencies.

  2. Import

     import 'package:google_map_custom_windows/google_map_custom_windows.dart';
    
  3. Usage To use the custom info windows, you'll primarily interact with the GoogleMapCustomWindowController and the CustomMapInfoWindow widget.

  • Initialize GoogleMapCustomWindowController, Create an instance of GoogleMapCustomWindowController in your StatefulWidget's initState.
    late GoogleMapCustomWindowController _googleMapCustomWindowController;
    
    @override
    void initState() {
     super.initState();
     _googleMapCustomWindowController = GoogleMapCustomWindowController();
    }
    
  • Need to create your custom info window widget for view. You can create multiple window as your requirement.
    class MyCustomInfoWidget extends StatelessWidget {
    final String title;
    const MyCustomInfoWidget({super.key, required this.title});
    
    @override
    Widget build(BuildContext context) {
     return Container(
       decoration: BoxDecoration(
         borderRadius: BorderRadius.circular(10),
         color: Colors.black,
       ),
       alignment: Alignment.center,
       child: Text(
         title,
         style: TextStyle(color: Colors.white, fontSize: 14),
       ),
     );
    }
    }
    
  • Declare list of info window and same size of list LatLng.
    List<Widget> infoWidgets = [
    MyCustomInfoWidget(title: 'From Marker'),
    MyCustomInfoWidget(title: 'To Marker'),
    ];
    
    List<LatLng> infoPositions = [
    LatLng(23.798054, 90.413459),
    LatLng(23.789451, 90.419584),
    ];
    
  • Use Stack widget for using custom info window.
    @Stack(
         children: [
           GoogleMap(
             mapType: MapType.normal,
             markers: markers,
             initialCameraPosition: CameraPosition(target: initPosition, zoom: 15),
             onMapCreated: (GoogleMapController controller) {
               _setFromToMarker();
               _googleMapCustomWindowController.googleMapController = controller;
               _googleMapCustomWindowController.addInfoWindow!(infoWidgets, infoPositions);
             },
             onTap: (position) {
               _googleMapCustomWindowController.hideInfoWindow!();
             },
             onCameraMove: (CameraPosition cameraPosition) {
               _googleMapCustomWindowController.onCameraMove!();
             },
           ),
    
           CustomMapInfoWindow(
             controller: _googleMapCustomWindowController,
             offset: const Offset(0, 50),
             height: 40,
             width: 100,
           ),
         ],
       )
    
  1. Don't forget to dispose _googleMapCustomWindowController
    @override
      void dispose() {
        _googleMapCustomWindowController.dispose();
        super.dispose();
      }
    

🤝 Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. If you'd like to contribute code, please fork the repository and submit a pull request.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。