Skip to content

[google_maps_flutter_web] GoogleMapController.getLatLng() does not work #67606

@Sammius

Description

@Sammius

GoogleMapController.getLatLng() function constantly returns the same strange value LatLng(85.05112877980659, -180).
At the same time, it works correctly in applications.

Code:

  @override
  Widget build(BuildContext context) {
    return GoogleMap(
      initialCameraPosition: const CameraPosition(target: LatLng(0, 0)),
      onMapCreated: (controller) {
        googleMapController = controller;
      },
      onCameraIdle: () async {
        if (googleMapController == null) return;
        debugPrint('getLatLng        ---> ${await googleMapController.getLatLng(ScreenCoordinate(x: 0, y: 0))}');
        debugPrint('getVisibleRegion ---> ${await googleMapController.getVisibleRegion()}');
      },
    );
}

Responses:

getLatLng        ---> LatLng(85.05112877980659, -180)
getVisibleRegion ---> LatLngBounds(LatLng(34.59802573078672, 32.940006322361796), LatLng(35.24659556096226, 33.76260764072117))
getLatLng        ---> LatLng(85.05112877980659, -180)
getVisibleRegion ---> LatLngBounds(LatLng(34.573272235389624, 32.466006576657946), LatLng(35.22203687139637, 33.28860789501732))
getLatLng        ---> LatLng(85.05112877980659, -180)
getVisibleRegion ---> LatLngBounds(LatLng(34.49634436830695, 32.512698471189196), LatLng(35.145713649644826, 33.33529978954857))
% flutter doctor -v         
[✓] Flutter (Channel master, 1.23.0-8.0.pre.220, on Mac OS X 10.15.7 19H2 x86_64, locale en-CY)
    • Flutter version 1.23.0-8.0.pre.220 at /Users/Sammius/Flutter/flutter
    • Framework revision 0b78110b26 (4 hours ago), 2020-10-07 19:29:47 -0700
    • Engine revision 2eac514f26
    • Dart version 2.11.0 (build 2.11.0-186.0.dev)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/Sammius/android
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /Users/Sammius/android
    • ANDROID_SDK_ROOT = /Users/Sammius/android
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java
    • Java version Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.10.0.rc.1

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

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2019.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 39.0.5
    • Dart plugin version 192.7402

[✓] VS Code (version 1.49.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

[✓] Connected device (3 available)
    • iPhone 11 Pro (mobile) • 932ADBE8-AFEE-49F6-BED9-109EC9869A1B • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • Web Server (web)       • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 85.0.4183.121

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listp: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.platform-webWeb applications specifically

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions