-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
The Google Maps Flutter plugin does not support resolution-aware image assets when specifying marker icons i.e.:
.../marker_icon.png
.../2.0x/marker_icon.png
.../3.0x/marker_icon.png
The plugin requires that you use BitmapDescriptor.fromAsset('<path>/marker_icon.png') which does not resolve to the correct image. As a workaround I am using the following approach to get the correct image and then pass it to the BitmapDescriptor:
ImageConfiguration config = createLocalImageConfiguration(buildContext);
AssetImage('<path>/marker_image.png')
.obtainKey(config)
.then((resolvedMarkerImage) {
markerIcon = BitmapDescriptor.fromAsset(resolvedIMarkerImage.name));
});This works on Android. The AssetImage chooses the correct image according to the pixel ratio of the device and the maps plugin displays the marker at the expected size. However on iOS the image is not sized as per the asset, the image is getting enlarged.
My guess is that on iOS the image is being scaled up according to pixel ratio of the device, despite the fact I have already given an asset of the desired size. Perhaps it's the way the maps plugin creates an UIImage on iOS? Has anybody else seen this? Are there any known solutions/workarounds?