Skip to content

[google_maps_flutter] Add support for custom marker size #34657

Description

@iskakaushik

Currently we ignore the marker size in the ImageConfiguration and only use it to resolve the asset image dpi. This is to scale the image after picking the right resolution per the size parameter passed.

Activity

  1. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on Feb 28, 2020
  2. tzvc commented on Mar 10, 2020

    @tzvc

    Any updates on this? Happy to help if needed ;)

  3. dranoer commented on Apr 17, 2020

    @dranoer

    Any updates on this? Happy to help if needed ;)

    I've issue on this, do you any way so I could change it with customSize?

  4. giancarlopro commented on Apr 17, 2020

    @giancarlopro

    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);
  5. enricobenedos commented on May 5, 2020

    @enricobenedos

    I tried today to apply a custom marker using google_maps_flutter and also devicePixelRatio and Size options are ignored

  6. JackWittmayer commented on Jun 29, 2020

    @JackWittmayer

    It's been over a year now and Size and devicePixelRatio are still ignored.

  7. giancarlopro commented on Jun 30, 2020

    @giancarlopro

    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 .png format. have you tested with other images?

  8. JackWittmayer commented on Jun 30, 2020

    @JackWittmayer

    it should work if you're using .png format. have you tested with other images?

    Sorry, I actually just did a poor job implementing the code. It works great!

  9. matijamatija commented on Sep 22, 2020

    @matijamatija

    Any progress on this?

  10. added
    P2Important issues not at the top of the work list
    on Feb 18, 2021
  11. fernando-s97 commented on Sep 2, 2021

    @fernando-s97

    @TahaTesser @darshankawar any updates on that?

  12. 16 remaining items

  13. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 5, 2024
  14. github-actions commented on Jun 19, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttercustomer: crowdAffects or could affect many people, though not necessarily a specific customer.p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions