map_navigation_utils 0.0.3
map_navigation_utils: ^0.0.3 copied to clipboard
A Flutter package that provides smooth Google Maps marker animation, polyline decoding, and distance/bearing calculation utilities for navigation apps.
map_navigation_utils #
A powerful Flutter package that helps you easily work with Google Maps by providing smooth marker animations, polyline decoding, and distance/bearing calculations.
π Features #
- β Smooth marker animation
- β Google-style encoded polyline decoder
- β Distance calculator (Haversine formula)
- β Bearing angle calculator
- β Lightweight & easy to use
π¦ Installation #
Add this to your pubspec.yaml:
dependencies:
map_navigation_utils: ^1.0.0
Import the package:
import 'package:map_navigation_utils/map_navigation_utils.dart';
π― Usage Examples #
πΉ 1. Decode Polyline #
final points = PolylineDecoder.decode(encodedString);
πΉ 2. Calculate Distance Between Coordinates #
final distance = GeoUtils.calculateDistance(
lat1,
lon1,
lat2,
lon2,
);
πΉ 3. Calculate Bearing #
final bearing = GeoUtils.calculateBearing(
lat1,
lon1,
lat2,
lon2,
);
πΉ 4. Smooth Marker Animation #
MarkerAnimator.smoothMove(
controller: mapController,
markerId: MarkerId('bus'),
from: oldLatLng,
to: newLatLng,
);
π Example Project #
A full working demo is available inside:
example/lib/main.dart
πΊ Roadmap #
- Add route snapping
- Multi-marker smooth animation
- Route prediction & ETA utilities
π Advanced Usage #
π₯ Smooth Marker Animation with Duration #
await MarkerAnimator.smoothMove(
controller: mapController,
markerId: const MarkerId('vehicle'),
from: oldPosition,
to: newPosition,
duration: const Duration(seconds: 2),
);
π§ Recalculate Polyline + Bearing #
final decoded = PolylineDecoder.decode(encodedPolyline);
final bearing = GeoUtils.calculateBearing(
decoded.first.latitude,
decoded.first.longitude,
decoded.last.latitude,
decoded.last.longitude,
);
πΈ Screenshots (Add your images here) #
Place your package screenshots in:
/example/assets/
And reference them like:

π Example (Full Code Snippet) #
Use this snippet in your example/lib/main.dart:
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:map_navigation_utils/map_navigation_utils.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MapExample(),
);
}
}
class MapExample extends StatefulWidget {
const MapExample({super.key});
@override
State<MapExample> createState() => _MapExampleState();
}
class _MapExampleState extends State<MapExample> {
GoogleMapController? mapController;
LatLng from = const LatLng(26.9124, 75.7873);
LatLng to = const LatLng(26.9154, 75.7893);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Map Utils Example')),
body: GoogleMap(
initialCameraPosition: CameraPosition(target: from, zoom: 14),
onMapCreated: (controller) => mapController = controller,
markers: {
Marker(
markerId: const MarkerId('bus'),
position: from,
),
},
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
await MarkerAnimator.smoothMove(
controller: mapController!,
markerId: const MarkerId('bus'),
from: from,
to: to,
);
setState(() => from = to);
},
child: const Icon(Icons.navigation),
),
);
}
}
π License #
This package is available under the MIT License.
β€οΈ Contribute #
Pull requests and feature suggestions are welcome!