Skip to content

[google maps flutter] Polygon Coordinates incorrectly drawn on Android #94146

@AlvinaC

Description

@AlvinaC

Steps to Reproduce

  1. Clone the example project for google maps flutter given here: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter/example
    (the dependancy in pubspec.yaml is made to point to google_maps_flutter 2.1.1 )
  2. In place_polygon.dart refer to definition of _createPoints()
  3. Change the existing coordinates to the following:
List<LatLng> _createPoints() {
    final List<LatLng> points = <LatLng>[];
    points.add(LatLng(43.03725568057, -87.90466904649));
    points.add(LatLng(43.03725731832, -87.90464007847));
    points.add(LatLng(43.03725828717, -87.90462285996));
    points.add(LatLng(43.03722281233, -87.90461934180));
    points.add(LatLng(43.03722510007, -87.90458103485));
    points.add(LatLng(43.03717671100, -87.90457575590));
    points.add(LatLng(43.03717236124, -87.90466049694));
    points.add(LatLng(43.03725568057, -87.90466904649));
    return points;
  }
  1. Change the initial camera position to the following on line 179 in the build method of PlacePolygonBodyState class.
initialCameraPosition: const CameraPosition(
                target: LatLng(
                    /*52.4478, -3.5402*/
                    43.03725568057,
                    -87.90466904649),
                zoom:22.0,
              ),
  1. Optional : Change the polygon fill color and stroke width for better visibility: line no 89 where Polygon is initialized.
strokeWidth: 1,
fillColor: Colors.yellowAccent,

Expected results: The polygon drawn should look the same on both platforms.

Actual results: The polygon drawn is not at right coordinates on android. The LatLng object shows the right coordinates given to it at runtime. But it looks like when drawn on map, the coordinates are not right. This works fine on iOS. Attaching the screenshots here for android and ios.

flutter doctor output for machine where android app is run from:

flutter doctor -v
[√] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Version 10.0.19043.1288], locale en-US)
• Flutter version 2.5.2 at C:\Ravi\Android\flutter_windows_2.2.3-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (8 weeks ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Ravi\Android\Sdk
• Platform android-S, build-tools 30.0.3
• Java binary at: C:\Ravi\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.2)
• Android Studio at C:\Ravi\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.61.2)
• VS Code at C:\Users\jranjar1\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.27.0
[√] Connected device (3 available)
• SM G930F (mobile) • ce0817183c44c0620b • android-arm64 • Android 8.0.0 (API 26)
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.69
• Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.44

• No issues found!

flutter doctor output for machine where iOS app is run from:

flutter doctor -v
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.5.2 20G95 darwin-x64, locale en-IN)
• Flutter version 2.5.2 at /Users/tauheed/TA-Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (8 weeks ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/tauheed/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.61.0)
• VS Code at /Users/tauheed/Downloads/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• iPhone 11 Pro (mobile) • C17D35E1-097F-43B4-A669-ED27A00DCF2D • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55
! Doctor found issues in 1 category.
screenshots
android ios
Polygon_on_android Polygon_On_iphone

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions