Skip to content

Google Maps Plugin - Marker icon has incorrect size on iOS #27393

@irevans

Description

@irevans

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?

Metadata

Metadata

Assignees

Labels

p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallywaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions