Repository navigation
[google_maps_flutter] Add support for custom marker size #34657
Description
Activity
- addedcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.
on Feb 28, 2020 Any updates on this? Happy to help if needed ;)
Reacted by Sammius, Niraj Joshi and Hayk GalstyanAny updates on this? Happy to help if needed ;)
I've issue on this, do you any way so I could change it with customSize?
I use this as a workaround, may be useful for you. It creates a redimensioned version of the asset image on the fly.
import 'dart:typed_data'; import 'dart:ui' as ui; import 'package:flutter/services.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; Future<Uint8List> getBytesFromAsset(String path, int width) async { ByteData data = await rootBundle.load(path); ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); ui.FrameInfo fi = await codec.getNextFrame(); return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List(); } Future<BitmapDescriptor> getBitmapDescriptorFromAssetBytes(String path, int width) async { final Uint8List imageData = await getBytesFromAsset(path, width); return BitmapDescriptor.fromBytes(imageData); }
Usage:
final icon = await getBitmapDescriptorFromAssetBytes("asset/image.png", 35);
Reacted by Erli Soares, Bryan Pei, Nazanin Nasab, inossan, Sarang Kartikey, Jack Wittmayer, Akshay Galande, Fernando Pinedo, Niraj Joshi, Morita Naoki and 43 moreReacted by Niraj Joshi, harlekintiger, DarkMikey, Marko Filipović, Koen Van Looveren, Lays Dragon, Sun Lee , Dominik Mrugalski, Igor Kulishov and GiovanniBCECReacted by Gastón Giménez, Hussain Mustafa, Christian Garcerant, LuchoAGN, Daniel Firebanks-Quevedo and Igor KulishovI tried today to apply a custom marker using
google_maps_flutterand alsodevicePixelRatioandSizeoptions are ignoredIt's been over a year now and Size and devicePixelRatio are still ignored.
It's been over a year now and Size and devicePixelRatio are still ignored. @giancarlopro I wish your workaround worked but the icon is still the same size no matter if I put 100 or 1 for the width.
it should work if you're using
.pngformat. have you tested with other images?Reacted by DarkMikey and Lays Dragonit should work if you're using
.pngformat. have you tested with other images?Sorry, I actually just did a poor job implementing the code. It works great!
Reacted by Giancarlo RochaAny progress on this?
Reacted by Alexey Lepskii, Radu Zubascu, Hudson Afonso, Jason Wong, Heorhii Teriaiev, harlekintiger, Muhemmad Asbah Riyas, Juan D. Diaz, Tom Nijs, Ali Furkan Budak and 5 moreReacted by Bilal Bşş, Edy Tama Kusumajaya, DarkMikey and Lays Dragon- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Feb 18, 2021 @TahaTesser @darshankawar any updates on that?
16 remaining items
- addedtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
on Jul 8, 2023 - added a commit that references this issue
on May 24, 2024 - added a commit that references this issue
on Jun 4, 2024 - added a commit that references this issue
on Jun 5, 2024 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Jun 5, 2024 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jun 19, 2024 - added a commit that references this issue
on May 24, 2025 - added a commit that references this issue
on Jun 10, 2026 - added a commit that references this issue
on Jun 19, 2026
Currently we ignore the marker size in the
ImageConfigurationand only use it to resolve the asset imagedpi. This is to scale the image after picking the right resolution per thesizeparameter passed.