Loading PNG as Google Maps Marker?

1,762 views
Skip to first unread message

Eric Knudstrup

unread,
Aug 29, 2019, 7:45:41 PM8/29/19
to Flutter Development (flutter-dev)
My searches all come up with ways that don't work.  What's the new non-deprecated way to load a PNG file into a BitmapDescriptor?

EthicCoders Apps

unread,
Aug 29, 2019, 7:52:59 PM8/29/19
to Eric Knudstrup, Flutter Development (flutter-dev)
We load the map marker png this way:

Marker(
markerId: MarkerId(place.place_id),
icon: BitmapDescriptor.fromAsset(Platform.isIOS ? 'assets/images/app_icon_48.png' : 'assets/images/app_icon_128.png'),
position: LatLng(place.geometry.location.lat, place.geometry.location.lng),
  ...
);

Does this work for you?


On Fri, Aug 30, 2019 at 5:15 AM Eric Knudstrup <eknu...@gmail.com> wrote:
My searches all come up with ways that don't work.  What's the new non-deprecated way to load a PNG file into a BitmapDescriptor?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/4bf8477e-2075-4e76-85ea-af1bb5e79790%40googlegroups.com.

Eric Knudstrup

unread,
Aug 29, 2019, 8:00:11 PM8/29/19
to EthicCoders Apps, Flutter Development (flutter-dev)


On 8/29/19 4:52 PM, EthicCoders Apps wrote:
We load the map marker png this way:

Marker(
  markerId: MarkerId(place.place_id),
  icon: BitmapDescriptor.fromAsset(Platform.isIOS ? 'assets/images/app_icon_48.png' : 'assets/images/app_icon_128.png'),
  position: LatLng(place.geometry.location.lat, place.geometry.location.lng),
  ...
);

          
Does this work for you?
I'm getting warnings that BitmapDescriptor.fromAsset() is deprecated.

masuod panahpoury

unread,
Aug 31, 2019, 7:55:42 AM8/31/19
to Eric Knudstrup, EthicCoders Apps, Flutter Development (flutter-dev)
Marker(
          markerId: markerId,
          position: LatLng(lat, lng),
          infoWindow: InfoWindow(title: "$lat , $lng", snippet: '*'),
          icon: await BitmapDescriptor.fromAssetImage(
              createLocalImageConfiguration(context), 'images/box_pin.png'),
          rotation: rotation);

this is work for me.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.


--
lvl.P

Eric Knudstrup

unread,
Sep 5, 2019, 6:16:59 AM9/5/19
to Flutter Development (flutter-dev)
I'm trying to initialize a list of four icons from Google Maps' initState():
BitmapDescriptor.fromAssetImage(createLocalImageConfiguration(context),
'Images/XYZ.png').then((value) {
XYZIcon = value;
});
I get the Red Screen of Death saying that inheritFromWidget(), etc. was called before initState() finished.
I thought that the ".then" made everything wait?
Reply all
Reply to author
Forward
0 new messages