Apple Maps Plugin for Flutter

Overview

apple_maps_flutter

A Flutter plugin that provides an Apple Maps widget.

The plugin relies on Flutter's mechanism for embedding Android and iOS views. As that mechanism is currently in a developers preview, this plugin should also be considered a developers preview.

This plugin was based on the google_maps_flutter plugin. Instead of reinventing the wheel it also uses the Flutter implementation of the google_maps_flutter plugin. This was also done to simplify the process of combining the google_maps_flutter plugin with apple_maps_flutter to create a cross platform implementation for Android/iOS called flutter_platform_maps.

Screenshots

Example 1 Example 2
Example 1 Example 2

iOS

To use this plugin on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app's Info.plist file, with the key io.flutter.embedded_views_preview and the value YES. You will also have to add the key Privacy - Location When In Use Usage Description with the value of your usage description.

Android

There is no Android implementation, but there is a package combining apple_maps_flutter and the google_maps_flutter plugin to have the typical map implementations for Android/iOS called platform_maps_flutter.

Sample Usage

class AppleMapsExample extends StatelessWidget {
  AppleMapController mapController;

  void _onMapCreated(AppleMapController controller) {
    mapController = controller;
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        Expanded(
          child: Container(
            child: AppleMap(
              onMapCreated: _onMapCreated,
              initialCameraPosition: const CameraPosition(
                target: LatLng(0.0, 0.0),
              ),
            ),
          ),
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            Column(
              children: <Widget>[
                FlatButton(
                  onPressed: () {
                    mapController.moveCamera(
                      CameraUpdate.newCameraPosition(
                        const CameraPosition(
                          heading: 270.0,
                          target: LatLng(51.5160895, -0.1294527),
                          pitch: 30.0,
                          zoom: 17,
                        ),
                      ),
                    );
                  },
                  child: const Text('newCameraPosition'),
                ),
                FlatButton(
                  onPressed: () {
                    mapController.moveCamera(
                      CameraUpdate.newLatLngZoom(
                        const LatLng(37.4231613, -122.087159),
                        11.0,
                      ),
                    );
                  },
                  child: const Text('newLatLngZoom'),
                ),
              ],
            ),
            Column(
              children: <Widget>[
                FlatButton(
                  onPressed: () {
                    mapController.moveCamera(
                      CameraUpdate.zoomIn(),
                    );
                  },
                  child: const Text('zoomIn'),
                ),
                FlatButton(
                  onPressed: () {
                    mapController.moveCamera(
                      CameraUpdate.zoomOut(),
                    );
                  },
                  child: const Text('zoomOut'),
                ),
                FlatButton(
                  onPressed: () {
                    mapController.moveCamera(
                      CameraUpdate.zoomTo(16.0),
                    );
                  },
                  child: const Text('zoomTo'),
                ),
              ],
            ),
          ],
        )
      ],
    );
  }
}

Suggestions and PR's to make this plugin better are always welcome.

Comments
  • Build ios-framework  fails, swift version attribute required

    Build ios-framework fails, swift version attribute required

    build ios-framework fails with the error:

    " [!] Unable to determine Swift version for the following pods:

    - `apple_maps_flutter` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set
    the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
    
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:125:in `verify_swift_pods_swift_version'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/xcode/target_validator.rb:39:in `validate!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:590:in `validate_targets'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:158:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:23:in `load'
    /usr/local/bin/pod:23:in `<main>'
    

    "

    opened by safarri 5
  • Adds support for my location with always authorization status

    Adds support for my location with always authorization status

    Currently, apple_maps_flutter will only show the user's location (i.e., a blue dot on the map) when the authorization status is authorizedWhenInUse.

    https://github.com/LuisThein/apple_maps_flutter/blob/f787ab1bd3bc65cac023e4df5c14e4963fd37298/ios/Classes/MapView/FlutterMapView.swift#L198-L208

    This PR enables the user's location when the authorization status transitions from authorizedWhenInUse to authorizedAlways. Closes LuisThein/platform_maps_flutter#28.

    opened by zgosalvez 3
  • circle updates not working

    circle updates not working

    In my map, I have something like this:

      pm.Circle _circle = pm.Circle(
        circleId: pm.CircleId('geoAvailabilityRadius'),
        fillColor: Colors.blue.withOpacity(0.3),
        center: pm.LatLng(35, -80),
        radius: 1000,
        strokeColor: Colors.blue,
        strokeWidth: 2,
      );
      Widget _map() {
        return pm.PlatformMap(
          initialCameraPosition: pm.CameraPosition(
            target: pm.LatLng(35, -80),
            zoom: 14.0,
          ),
          myLocationEnabled: true,
          myLocationButtonEnabled: true,
          zoomControlsEnabled: true,
          onMapCreated: (pm.PlatformMapController controller) {
            _mapController = controller;
          },
          onCameraMove: (pm.CameraPosition cameraPosition) {
            setState(() {
              _circle = _circle.copyWith(
                centerParam: LatLng(cameraPosition.target.latitude, cameraPosition.target.longitude),
              );
            });
          },
          circles: <pm.Circle>{
            _circle,
          },
        );
      }
    

    This logic is supposed to move the circle when the map moves. The logic works for markers, but it doesn't seem to update the circle. This works on the google version of platform_maps_flutter, but not the apple one.

    Am I missing something simple?

    bug 
    opened by wizawuza 3
  • Presence of android/ directory breaks Android builds on Flutter 2.10

    Presence of android/ directory breaks Android builds on Flutter 2.10

    Describe the bug See https://github.com/flutter/flutter/issues/97729

    To Reproduce Steps to reproduce the behavior:

    1. Make a new Flutter application project with 2.10
    2. Add apple_maps_flutter to it
    3. Try to build the app for Android

    Expected behavior Successful build.

    While this is a bug in Flutter, and will be fixed there, you can fix this in the plugin simply by removing the unused android/ folder; see https://github.com/flutter/flutter/issues/97729#issuecomment-1030139198.

    You should set its minimum Flutter version to 1.17 as part of that change.

    bug 
    opened by stuartmorgan 1
  • fix: Updated mapController.moveCamera to not animate

    fix: Updated mapController.moveCamera to not animate

    To match the API of google_maps_flutter, updated mapController.moveCamera to move the camera without animating the transition.

    To animate camera movement, mapController.animateCamera should be used instead.

    Fixes LuisThein/apple_maps_flutter#31


    From the GoogleMap API documentation:

    GoogleMap API - moveCamera public final void moveCamera (CameraUpdate update)

    Repositions the camera according to the instructions defined in the update. The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position. See CameraUpdateFactory for a set of updates.

    GoogleMap API - animateCamera public final void animateCamera (CameraUpdate update)

    Animates the movement of the camera from the current position to the position defined in the update. During the animation, a call to getCameraPosition() returns an intermediate location of the camera.


    Pre-launch Checklist

    • [x] I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
    • [x] I updated CHANGELOG.md to add a description of the change.
    • [x] I updated/added relevant documentation (doc comments with ///).
    • [ ] I added new tests to check the change I am making if a test is possible.
    • [x] All existing and new tests are passing.
    opened by ateich 1
  • mapController.moveCamera should not be animated

    mapController.moveCamera should not be animated

    Describe the bug mapController.moveCamera should move the map without animating the transition to match the API of google_maps_flutter.

    If an animated transition is required, mapController.animateCamera should be used instead.


    From the GoogleMap API documentation:

    GoogleMap API - moveCamera public final void moveCamera (CameraUpdate update)

    Repositions the camera according to the instructions defined in the update. The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position. See CameraUpdateFactory for a set of updates.

    GoogleMap API - animateCamera public final void animateCamera (CameraUpdate update)

    Animates the movement of the camera from the current position to the position defined in the update. During the animation, a call to getCameraPosition() returns an intermediate location of the camera.


    To Reproduce Steps to reproduce the behavior:

    1. In the example project, open Camera control
    2. Tap on any of the buttons
    3. Observe the map camera animating to the new position

    Expected behavior The map should instantly transition to the new position, rather than animating the transition.

    Screenshots Not applicable.

    Smartphone (please complete the following information):

    • Device: iPhone XS
    • Version iOS 15.0.2

    flutter doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-US)
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2020.3)
    [✓] Connected device (3 available)
        ! Error: iPhone is busy: Making the device ready for development. Xcode will continue when iPhone is finished. (code -10)
    
    • No issues found!
    

    Root Cause Lines 232 and 235 of apple_maps_flutter/ios/Classes/MapView/AppleMapController.swift show animated: true

    https://github.com/LuisThein/apple_maps_flutter/blob/d302d013d38315ac0e2b9742220df1fe6eeb17bf/ios/Classes/MapView/AppleMapController.swift#L228-L237

    Concerns While fixing this bug will make the API match what is expected from the Google Maps API (and google_maps_flutter), it is a breaking change for any users that have come to expect mapController.moveCamera to animate.

    While users can update their code to use mapController.animateCamera if they want the camera to animate, it should be very clear to anyone updating that this update will change existing behavior.

    Pull Request I'll submit a pull request changing mapController.moveCamera to no longer animate, if this sounds good to you.

    Given that this change breaks previous behavior, do you think it would warrant a major version bump?

    bug 
    opened by ateich 1
  • Adds null safety.  Refreshes the example app.

    Adds null safety. Refreshes the example app.

    • Adds null safety.
    • Refreshes the example app.
    • Updates .gitignore and removes files that should not be tracked.

    Notes: Tests pass on the package. Tests on the example app have not been performed because flutter_driver with null safety is not in the stable channel yet. Rather that merge this PR, it would be better to git fetch to create a new 1.x branch instead so that fixes can be added easily to the non-null safe version of this package.

    opened by jonbhanson 1
  • request to add CameraUpdate.newLatLngBounds

    request to add CameraUpdate.newLatLngBounds

    Hi there, thanks for your awesome library. I have just added a suggestion about adding new CameraUpdate.newLatLngBounds to animate camera to a bounds list but I can't push to create a Pull Request. What should I now. Thank you.

    opened by nghiashiyi 1
  • Tapping marker also takes tap on map

    Tapping marker also takes tap on map

    Hello,

    I have added a feature to add pins on tap of map. Pin also displays info window when tap is performed on pin. When I tap on pin to open info window, map also adds new pin because map takes tap event. I could not find anything to fix it and looks like a defect.

    opened by anuroopsinghal07 1
  • Map takes tap event when tap is performed on marker

    Map takes tap event when tap is performed on marker

    Hello,

    I have added a feature to add pins on tap of map. Pin also displays info window when tap is performed on pin. When I tap on pin to open info window, map also adds new pin because map takes tap event. I could not find anything to fix it and looks like a defect.

    opened by anuroopsinghal07 1
  • Memory leak while using in list view

    Memory leak while using in list view

    Hi,

    Thanks for making this plugin, it works great as a drop in replacement for google maps and apple maps are more performant on my old test iPhone.

    I had a memory leak while displaying a bunch of maps in a list view. While scrolling, memory keeps growing until iOS kills it at 1.3GB+. Looks like old map widgets are never disposed.

    Turns out this change applied to apple_maps_flutter fixes the issue: https://github.com/Unact/yandex_mapkit/commit/5ba2585f3f1837ab6520fd5f1faa46f022f8f835#diff-81b47307a81ee1170b367b6920b91830c3371d0012f8a54a737c8e7bf828d08bR30-R34

    I have a fix in my repo but I don't know enough Swift to do it properly :D

    opened by nuzelac 1
  • Complete Map Types list

    Complete Map Types list

    Add missing map types: SatelliteFlyover, Hybrid Flyover and Muted Standard

    Pre-launch Checklist

    • [ ] I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
    • [ ] I updated CHANGELOG.md to add a description of the change.
    • [x] I updated/added relevant documentation (doc comments with ///).
    • [ ] I added new tests to check the change I am making if a test is possible.
    • [ ] All existing and new tests are passing.
    opened by vini2001 0
  • feat: add colorScheme parameter

    feat: add colorScheme parameter

    This PR allows the developers to programmatically change the color scheme of the map, the current behavior is that the map always follows the system (not Flutter's theme Brightness) appearance settings. There is still a bug regarding using the app's Brightness but I figured it can be worked on later, as that is the exact behavior atm.

    This could be classified as a fix to #29, although that issue might involve more stuff than just the scheme.

    Pre-launch Checklist

    • [ ] I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
    • [ ] I updated CHANGELOG.md to add a description of the change.
    • [x] I updated/added relevant documentation (doc comments with ///).
    • [ ] I added new tests to check the change I am making if a test is possible.
    • [x] All existing and new tests are passing.
    opened by juaoose 0
  • fix: Odd movement of the Apple logo

    fix: Odd movement of the Apple logo

    Added insetsLayoutMarginsFromSafeArea parameter to control automatic update of layout margins. When placing a MapView inside a ScrollView such as a ListView, set this flag to false to prevent the Apple logo from moving.

    Fixes https://github.com/LuisThein/apple_maps_flutter/issues/40

    Pre-launch Checklist

    • [x] I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
    • [x] I updated CHANGELOG.md to add a description of the change.
    • [x] I updated/added relevant documentation (doc comments with ///).
    • [ ] I added new tests to check the change I am making if a test is possible.
    • [x] All existing and new tests are passing.
    opened by zuvola 1
  • Odd movement of the Apple logo

    Odd movement of the Apple logo

    Describe the bug When scrolling MapView in ScrollView to the bottom edge, the Apple logo and legal label move oddly.

    To Reproduce Steps to reproduce the behavior:

    1. Set the bottom of SafeArea to false in example's scrolling_map.dart.
    2. Run and go to 'Scrolling map'
    3. Scroll downwards

    Expected behavior Apple logo and legal label should not move.

    Screenshots map

    Smartphone (please complete the following information):

    • Device: [Simulator]
    • Version [iOS 15.5]

    flutter doctor

    flutter doctor

    [✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-arm, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.70.2) [✓] Connected device (3 available) [✓] HTTP Host Availability

    bug 
    opened by zuvola 0
  • Please add getLatLng method like google_maps_flutter

    Please add getLatLng method like google_maps_flutter

    Hello :) First off thanks for using your time to build this package!! I really appreciate it.

    Is your feature request related to a problem? Please describe. I'm working on a project that has a requirement to allow users to draw an area on a map. By following this example I was able to get it to work with the google maps package. What makes this possible is the getLatLng function of the controller. It takes screen coordinate and turns them into lat/long, but the apple_maps_flutter package does not.

    Describe the solution you'd like It'd be great if the apple_maps_flutter package had the same getLatLng function so I could allow users to draw on the map.

    enhancement 
    opened by sboyd 1
  • Add ability to filter Points of Interest

    Add ability to filter Points of Interest

    Describe the solution you'd like MapKit allows you to filter Points of Interest, eg. restaurants, airports etc. It would be nice to expose this functionality in the API.

    Describe alternatives you've considered Google Maps allows you to set a map style which allows reducing the number of points of interest.

    Additional context See the official MapKit docs about Points of Interest Filtering: https://developer.apple.com/documentation/mapkit/mkpointofinterestfilter

    enhancement 
    opened by RyanRamchandar 0
Releases(v1.2.0)
Owner
Luis Thein
Luis Thein
Apple Maps Plugin for Flutter

apple_maps_flutter A Flutter plugin that provides an Apple Maps widget. The plugin relies on Flutter's mechanism for embedding Android and iOS views.

Luis Thein 50 Dec 31, 2022
Flutter Maps A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Salsabil Mohamed Hemada 1 Jul 15, 2022
A flutter plugin for Google Maps

IMPORTANT: This plugin is no longer under development Why? We initially built this plugin to fill an early gap in flutter. Since then, Google has made

AppTree Software, Inc 415 Dec 29, 2022
Flutter plugin for launching maps

Map Launcher Map Launcher is a flutter plugin to find available maps installed on a device and launch them with a marker or show directions. Marker Na

Alex Miller 189 Dec 20, 2022
A Flutter plugin for integrating Google Maps in iOS, Android and Web applications

flutter_google_maps A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobi

MarchDev Toolkit 86 Sep 26, 2022
A flutter plugin that's decodes encoded google poly line string into list of geo-coordinates suitable for showing route/polyline on maps

flutter_polyline_points A flutter plugin that decodes encoded google polyline string into list of geo-coordinates suitable for showing route/polyline

Adeyemo Adedamola 75 Oct 25, 2022
A Flutter plugin which provides 'Picking Place' using Google Maps widget

Google Maps Places Picker Refractored This is a forked version of google_maps_place_picker package, with added custom styling and features.

Varun 5 Nov 13, 2022
Mapbox-flutter - A repository to demonstrate the use of Mapbox - it's Maps and Navigation SDKs in a Flutter application

MapBox Flutter This repository contains code corresponding to the Youtube video

AB Satyaprakash 39 Dec 30, 2022
Flutter Google Maps Tutorial

Flutter Google Maps Tutorial YouTube Video Setup Get an API Key at https://cloud.google.com/maps-platform/ Enable Maps SDK for Android, Maps SDK for i

Marcus Ng 85 Nov 30, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Youhaan bootwala 1 Mar 18, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Varun CN 2 Apr 19, 2022
This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with simple smooth animations, making a nice UI and UX.

search_map_place This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with

Lucas Bernardi 127 Oct 22, 2022
A Flutter package to provide the native maps to Android/iOS

platform_maps_flutter A Flutter package that provides a native map to both Android and iOS devices. The plugin relies on Flutter's mechanism for embed

Luis Thein 70 Aug 13, 2022
Here Maps Package for Flutter

here_maps_webservice About here_maps_webservice provides Here Maps Web Services API wrapper that serve different purposes from search, to geocoding. U

Ayush Bherwani 11 Dec 15, 2022
Easy Google Maps for Flutter

easy_google_maps Easy Google Maps for Flutter on Web and Mobile Getting Started Mobile Follow setup for Mobile Here Web Good to go! EasyGoogleMaps(

Rody Davis 69 Jul 19, 2022
A Mapbox GL flutter package for creating custom maps

Flutter Mapbox GL Please note that this project is community driven and is not an official Mapbox product. We welcome feedback and contributions. This

flutter-mapbox-gl 917 Dec 31, 2022
Place picker on Google Maps for Flutter

Google Maps Place Picker A Flutter plugin which provides 'Picking Place' using Google Maps widget. The project relies on below packages. Map using Flu

Terry Kwon 178 Dec 16, 2022
A car rental flutter application using firebase and google maps API

A car sharing & rental app using Flutter, Firebase & Google Maps APIs ?? About the App ?? hopOn is flutter based application for car sharing and renta

Shivani Singh 97 Dec 30, 2022
Simple flutter app demonstrating usage of Google Maps

flutter_maps_example Get an API key at GoogleCloud. Enable Google Map SDK for ea

Tornike Gogberashvili 0 Nov 23, 2022