Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with > 7.00 version : Uncaught (in promise) TypeError: Illegal constructor #124

Closed
alaindeseine opened this issue Feb 22, 2024 · 1 comment

Comments

@alaindeseine
Copy link

alaindeseine commented Feb 22, 2024

Hi,

i use google_maps version 6.3.0 without any problems. I tried to use 7.0.0 and just know 7.1.0 but got an error at execution time. There is no errors, no warning in VSCode.

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.0, on macOS 12.7.3 21H1015 darwin-x64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.86.0)
[✓] Connected device (3 available)
[✓] Network resources

Here is the implementation code (partial).

6.3.0 code (working code):

      _mapOptions = MapOptions()
        ..mapTypeId = gmapUtils!.getMapTypeFromPref()
        ..zoom = 8
        ..center = LatLng(51.5, 2.50)
        ..fullscreenControl = false // removes the full screen button
        ..scaleControl = true
        ..zoomControl = true
        ..clickableIcons = true
        ..zoomControlOptions =
            (ZoomControlOptions()..position = ControlPosition.RIGHT_BOTTOM)
        ..mapTypeControlOptions = (MapTypeControlOptions()
          ..style = MapTypeControlStyle.HORIZONTAL_BAR
          ..position = ControlPosition.TOP_RIGHT);

      final elem =DivElement()
        ..id = htmlId
        ..style.width = "100%"
        ..style.height = "100%"
        ..style.border = 'none';

      map = GMap(elem, _mapOptions);

adapted 7.0.0 (or 7.1.0) code (errored code):

import 'package:web/web.dart' as web;
 ...

      _mapOptions = MapOptions()
        ..mapTypeId = gmapUtils!.getMapTypeFromPref()
        ..zoom = 8
        ..center = LatLng(51.5, 2.50)
        ..fullscreenControl = false // removes the full screen button
        ..scaleControl = true
        ..zoomControl = true
        ..clickableIcons = true
        ..zoomControlOptions =
            (ZoomControlOptions()..position = ControlPosition.RIGHT_BOTTOM)
        ..mapTypeControlOptions = (MapTypeControlOptions()
          ..style = MapTypeControlStyle.HORIZONTAL_BAR
          ..position = ControlPosition.TOP_RIGHT);

      final elem = web.HTMLElement() // Also tried with web.HTMLDivElement() 
        ..id = htmlId
        ..style.width = "100%"
        ..style.height = "100%"
        ..style.border = 'none';

      map = GMap(elem, _mapOptions);

Chrome (Version 122.0.6261.57) devtools console:

image

Any ideas?

@a14n
Copy link
Owner

a14n commented Mar 4, 2024

If you use google_maps in a flutter app you shouldn't depend directly on google_maps and wait the plugin update (see flutter/packages#5254).

@a14n a14n closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants