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

flutter_animarker 封面
套件詳情v3.2.0

flutter_animarker

Google 地圖的標記地理動畫解決方案。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.9萬
喜歡數
166
Pub 分數
120

安裝套件

flutter pub add flutter_animarker

套件介紹

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

Flutter Animarker 是一個專門用於在 Flutter 應用程式中為 Google 地圖上的標記創建動畫的套件。它可實現流暢、動態的標記移動和過渡,非常適合即時位置追蹤或路徑動畫視覺化。該套件以效能和易於整合為核心設計,支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。透過直觀的 API 擴展 Google 地圖功能,可控制動畫速度、緩入緩出效果和標記行為。適用於導航應用、配送追蹤,或任何需要動畫地理定位標記的場景。

適用情境

  • 即時位置追蹤
  • 動畫路線可視化
  • 配送或拼車應用
  • 互動地圖遊覽
  • 地理空間數據敘事

主要特色

  • 平滑標記動畫
  • 跨平台支援
  • 可自訂的動畫速度
  • 緩動曲線控制
  • 簡單 API 結合
  • 即時位置更新

適合對象

  • 開發基於位置的應用程式之開發者
  • 需要動畫地圖標記的應用程式
  • 使用動態資料的 Google Maps 項目
  • 注重跨平台一致性的團隊

使用建議

  • 需要設定 Google Maps SDK
  • 僅限 Google 地圖整合
  • 性能取決於動畫的複雜程度
  • 可能需要針對高頻率更新進行優化

原始 README

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

Google Maps Marker Animation - Overview

Buy Me A Coffee

pub package

Sometimes you need more than place a Marker📍 at map canvas 🌍, you need to smoothly move through Google Maps.

This package will help you to animate Markers' position changes and more.

This version v3.0.0 includes many useful features, namely:

  • Marker's position animation
  • Multiple markers' animations at the same time
  • Null-safety compatible
  • Ripple effect over marker position
  • Marker's rotation or bearing/heading of direction
  • Multipoint linear animation (Piecewise Linear Approximation Algorithm)
  • Support animation curves and duration
  • Widget-based with fully customized behaviors
  • Animation warm-up for improving performance
  • Useful LocationTween, AngleTween and PolynomialLocationInterpolator core logic
Note

This package only animate the marker's changes. Both Geolocation and Google Maps configuration are out of the scope of this package. So, before trying this package to ensure that you place a marker you Google Map or get location updates.

Screenshots

Example

  Animarker(
    ...
    curve: Curves.bounceInOut,
    duration: Duration(milliseconds: 2000),
    markers: <Marker> {
      RippleMarker(
        markerId: MarkerId('MarkerId2'),
        position: LatLng(0, 0),
        ripple: true,
      ),
    },
    child: GoogleMap(
      ...
      onMapCreated: (gController) => controller.complete(gController), //Complete the future GoogleMapController
      ...
    ),
    ...
  )
    //Setting dummies values
    const kStartPosition = LatLng(18.488213, -69.959186);
    const kSantoDomingo = CameraPosition(target: kStartPosition, zoom: 15);
    const kMarkerId = MarkerId('MarkerId1');
    const kDuration = Duration(seconds: 2);
    const kLocations = [
      kStartPosition,
      LatLng(18.488101, -69.957995),
      LatLng(18.489210, -69.952459),
      LatLng(18.487307, -69.952759)
    ];

    class SimpleMarkerAnimationExample extends StatefulWidget {
      @override
      SimpleMarkerAnimationExampleState createState() => SimpleMarkerAnimationExampleState();
    }

    class SimpleMarkerAnimationExampleState extends State<SimpleMarkerAnimationExample> {
      final markers = <MarkerId, Marker>{};
      final controller = Completer<GoogleMapController>();
      final stream = Stream.periodic(kDuration, (count) => kLocations[count]).take(kLocations.length);

      @override
      void initState() {
        stream.forEach((value) => newLocationUpdate(value));

        super.initState();
      }

      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Google Maps Markers Animation Example',
          home: Animarker(
            curve: Curves.ease,
            mapId: controller.future.then<int>((value) => value.mapId), //Grab Google Map Id
            markers: markers.values.toSet(),
            child: GoogleMap(
              mapType: MapType.normal,
              initialCameraPosition: kSantoDomingo,
              onMapCreated: (gController) => controller.complete(gController), //Complete the future GoogleMapController
            ),
          ),
        );
      }

      void newLocationUpdate(LatLng latLng) {
         var marker = RippleMarker(
           markerId: kMarkerId,
           position: latLng,
           ripple: true,
         );
         setState(() => markers[kMarkerId] = marker);
      }
    }

Using Ripple Effect

You only need to use the marker wrapper class RippleMarker, and set the ripple flag in order you can the ripple state.

  Animarker(
    // Other properties
    rippleRadius: 0.5,  //[0,1.0] range, how big is the circle
    rippleColor: Colors.teal, // Color of fade ripple circle
    rippleDuration: Duration(milliseconds: 2500), //Pulse ripple duration
    markers: <Marker>{
      //Ripple Marker
      RippleMarker(
        markerId: MarkerId('MarkerId1'),
        position: LatLng(0, 0),
        ripple: true,  //Ripple state
      ),
      //Non-ripple marker
      Marker(
        markerId: MarkerId('MarkerId2'),
        position: LatLng(0, 0),
      ),
    },
    // Other properties
  )

So, Let's it rip!

Using Rotation

The Marker rotation can be useful for Uber-like or delivery apps. The bearing or heading is the angle of direction which the Marker is moving toward to over the earth.

  Animarker(
    // Other properties
    useRotation : true, // Actived by default
    markers: <Marker>{
      Marker(
      markerId: MarkerId('MarkerId2'),
      position: LatLng(0, 0),
      )
    },
  // Other properties
  )

This way useRotation = true, you control globally if Marker should rotate or not.

Using Curve and Duration

Just like a normal Flutter animation, you can set a Curve o Duration to get the desire effect or result. So flexible, right?

  Animarker(
    // Other properties
    curve: Curves.bounceInOut,
    duration: Duration(milliseconds: 2000),
    markers: <Marker>{
      Marker(
      markerId: MarkerId('MarkerId2'),
      position: LatLng(0, 0),
      ),
    },
    // Other properties
  )

License

BSD-3-Clause License Copyright 2020 Gauris Javier. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.```

所屬分類

依賴

依賴清單 2 項

  • google_maps_flutter_platform_interface^2.0.4
  • vector_math^2.1.0

原始碼儲存庫

使用此套件的專案