google_map_service 0.0.3 copy "google_map_service: ^0.0.3" to clipboard
google_map_service: ^0.0.3 copied to clipboard

A Flutter package providing Google Maps services: map control, markers, polylines, geocoding, directions, and place APIs.

πŸ—ΊοΈ Google Map Service for Flutter #

A complete Flutter package that wraps and simplifies Google Maps APIs into a clean, service-based architecture.
It provides easy-to-use methods for map interactions, directions, geocoding, places, and distance calculations β€” all using the official Google Maps Platform.


πŸš€ Features #

  • 🧭 Map Initialization – Effortlessly display and control Google Maps widgets.
  • πŸ“ Markers & Polylines Management – Add, update, and remove markers and polylines dynamically.
  • πŸ—ΊοΈ Geocoding / Reverse Geocoding – Convert between coordinates and addresses.
  • 🧠 Places API Integration – Search, autocomplete, and get detailed place info.
  • πŸ›£οΈ Directions API – Get routes, distances, and durations between two or more locations.
  • πŸ“ Distance Matrix API – Calculate travel distance and time for multiple origins/destinations.
  • 🌍 Custom Map Styles – Apply dark/light/custom themes easily.
  • ⚑ Async, Null-safe, and Well-structured – Built for modern Flutter and Dart.

πŸ“¦ Installation #

Add the dependency to your pubspec.yaml:

dependencies:
  google_map_service: ^0.0.1

Then run:

flutter pub get

πŸ”‘ Setup #

  1. Enable Google APIs

    Make sure the following APIs are enabled on your Google Cloud Console:

    • Maps SDK for Android
    • Maps SDK for iOS
    • Geocoding API
    • Places API
    • Directions API
    • Distance Matrix API
  2. Add your API key

    In your AndroidManifest.xml:

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="YOUR_API_KEY_HERE" />
    

    In your AppDelegate.swift (iOS):

    GMSServices.provideAPIKey("YOUR_API_KEY_HERE")
    
  3. Initialize the service

    import 'package:google_map_service/google_map_service.dart';
    
    final mapService = GoogleMapService(apiKey: 'YOUR_API_KEY_HERE');
    

🧩 API Usage #

πŸ—ΊοΈ Displaying a Google Map #

GoogleMap(
  initialCameraPosition: CameraPosition(
    target: LatLng(37.7749, -122.4194),
    zoom: 12,
  ),
  onMapCreated: mapService.onMapCreated,
  markers: mapService.markers,
  polylines: mapService.polylines,
);

πŸ“ Add a Marker #

mapService.addMarker(
  id: 'marker1',
  position: LatLng(37.7749, -122.4194),
  title: 'San Francisco',
  snippet: 'California',
);

🧭 Get Directions #

final route = await mapService.getDirections(
  origin: LatLng(37.7749, -122.4194),
  destination: LatLng(34.0522, -118.2437),
);

mapService.addPolylineFromDirections(route);

🌍 Geocode an Address #

final coordinates = await mapService.geocodeAddress('1600 Amphitheatre Parkway, Mountain View, CA');

πŸ“« Reverse Geocode a Coordinate #

final address = await mapService.reverseGeocode(LatLng(37.4219999, -122.0840575));

🧠 Place Autocomplete #

final results = await mapService.autocompletePlaces('Eiffel Tower');

βš™οΈ Configuration Options #

GoogleMapService(
  apiKey: 'YOUR_API_KEY',
  language: 'en',
  region: 'US',
  mapStyle: MapStyle.dark,
);

πŸ“˜ Example App #

See /example folder for a complete Flutter demo using all APIs.

Run:

flutter run example/

πŸ§ͺ Testing #

Mock services are included for unit testing.

final mockService = MockGoogleMapService();

πŸ” Permissions #

Add these permissions in your AndroidManifest.xml and Info.plist:

  • Android:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    
  • iOS:

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>This app needs access to your location.</string>
    

🧰 Supported Platforms #

  • βœ… Android
  • βœ… iOS
  • βœ… Web (limited APIs – requires JS Maps SDK)

πŸ“„ License #

This project is licensed under the MIT License – see the LICENSE file for details.


πŸ’‘ Contributing #

Pull requests are welcome!
Please make sure to:

  • Write clear commit messages.
  • Add documentation and test coverage for new features.

🏁 Roadmap #

  • ❌ Support for custom map overlays
  • ❌ Offline maps support
  • ❌ Route optimization
  • ❌ Street View integration

πŸ‘¨β€πŸ’» Author #

Raj kumar Patel
Flutter Developer | Open Source Contributor
πŸ“§ rajkumar07793@gmail.com

0
likes
150
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package providing Google Maps services: map control, markers, polylines, geocoding, directions, and place APIs.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, google_maps_flutter_platform_interface, http

More

Packages that depend on google_map_service