-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/plugins
#2998Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 1.22Found to occur in 1.22Found to occur in 1.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: mapsGoogle Maps pluginGoogle Maps pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specifically
Milestone
Description
Steps to Reproduce
class MapSample extends StatefulWidget {
@override
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
final Completer<GoogleMapController> _controller =
Completer<GoogleMapController>();
final Set<Marker> _markers = <Marker>{};
BitmapDescriptor _icon;
@override
void initState() {
super.initState();
BitmapDescriptor.fromAssetImage(
ImageConfiguration(), 'assets/images/marker.png')
.then((BitmapDescriptor onValue) {
_icon = onValue;
});
}
@override
Widget build(BuildContext context) {
return GoogleMap(
onMapCreated: _onMapCreated,
markers: _markers,
mapType: MapType.normal,
initialCameraPosition: CameraPosition(
target: LatLng(lat, long),
zoom: 12,
),
);
}
void _onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
DefaultAssetBundle.of(context)
.loadString('assets/styles/map_style.json')
.then((String value) => controller.setMapStyle(value));
for (final ShopLocationData sld in shops) {
_markers.add(_createMarker(context, sld));
}
}
Marker _createMarker(BuildContext context, ShopLocationData sld) {
return Marker(
markerId: MarkerId(sld.coordinates.toString()),
position: sld.coordinates,
infoWindow: InfoWindow(
title: sld.name,
snippet: sld.address,
),
icon: _icon, // ERROR
);
}
}
Expected results:
Expected to see my markers with my .png image
Actual results:
No markers visible on the map and following error is thrown:
TypeError: Cannot read property 'toJson' of null
at Object._markerOptionsFromMarker (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:1528:45)
at google_maps_flutter_web.MarkersController.new.[_addMarker] (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:1246:55)
at _HashSet.new.forEach (http://localhost:46719/dart_sdk.js:38271:11)
at google_maps_flutter_web.MarkersController.new.addMarkers (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:1228:39)
at google_maps_flutter_web.GoogleMapController.new.updateMarkers (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:616:30)
at google_maps_flutter_web.GoogleMapsPlugin.new.updateMarkers (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:251:27)
at updateMarkers.next (<anonymous>)
at runBody (http://localhost:46719/dart_sdk.js:37623:34)
at Object._async [as async] (http://localhost:46719/dart_sdk.js:37654:7)
at google_maps_flutter_web.GoogleMapsPlugin.new.updateMarkers (http://localhost:46719/packages/google_maps_flutter_web/src/types.dart.lib.js:250:20)
at google_maps_flutter.GoogleMapController.__.[_updateMarkers] (http://localhost:46719/packages/google_maps_flutter/google_maps_flutter.dart.lib.js:180:61)
at google_maps_flutter._GoogleMapState.new._updateMarkers$ (http://localhost:46719/packages/google_maps_flutter/google_maps_flutter.dart.lib.js:652:35)
at _updateMarkers$.next (<anonymous>)
at http://localhost:46719/dart_sdk.js:37603:33
Logs
Your Flutter application is created using an older version of the Android embedding. It's being deprecated in favor of Android embedding v2. Follow the steps on
https://flutter.dev/go/android-project-migration to migrate your project.
Analyzing *project*...
No issues found! (ran in 2.2s)
[✓] Flutter (Channel beta, 1.21.0-9.1.pre, on Linux, locale en_US.UTF-8)
• Flutter version 1.21.0-9.1.pre at /home/rke/flutter
• Framework revision be9bc8cb39 (13 days ago), 2020-08-18 09:46:08 -0700
• Engine revision 267070c17a
• Dart version 2.10.0 (build 2.10.0-7.2.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /home/rke/Android/Sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: /home/rke/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 4.0)
• Android Studio at /home/rke/android-studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 85.0.4183.83
• No issues found!
name: *name*
description: *description*
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.0.1+1
environment:
sdk: ">=2.3.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.16.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
# This is used for state management.
provider: ^4.0.4
# Protocol buffers
protobuf: ^1.0.0
http: 0.12.0+2
# Web Views
webview_flutter: ^0.3.19+9
uuid: ^2.0.2
# dependency injection
get_it: ^3.0.1
# responsive layout
fluid_layout: ^0.1.0
# launching a URL in the mobile platform
url_launcher: ^5.4.2
# carousel slider widget
carousel_slider: ^1.4.1
# dots indicator for carousel slider widget
dots_indicator: ^1.0.0
# a markdown renderer
flutter_markdown: ^0.3.4
# to provide a persistent store for simple data
shared_preferences: ^0.5.6+3
# gets the device locale data
flutter_device_locale: ^0.4.0
# gridview
flutter_staggered_grid_view: ^0.3.2
video_player: ^0.10.11+2
google_maps_flutter: ^0.5.30
google_maps_flutter_web: ^0.1.0+1
dev_dependencies:
flutter_test:
sdk: flutter
intl_translation: ^0.17.9
icon_font_generator: ^1.0.0
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
fonts:
- family: Gilroy
fonts:
- asset: assets/fonts/Gilroy-Bold.otf
weight: 700
- asset: assets/fonts/Gilroy-Medium.otf
weight: 600
- asset: assets/fonts/Gilroy-Regular.otf
weight: 500
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/logo/
- assets/images/advertise/
- assets/images/welcome_screen/
- assets/images/support/
- assets/images/about/
- assets/icons/
- assets/styles/
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 1.22Found to occur in 1.22Found to occur in 1.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: mapsGoogle Maps pluginGoogle Maps pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specifically