question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vector Marker Support

See original GitHub issue

Is your feature request related to a problem? Please describe.

Hi i was trying to add a vector image to marker but realized it only supports BitmapDescriptor

Example icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_icon_png)

Describe the solution you’d like

I think you could change BitmapDescriptor to something more general and accept drawable and than based on that you can create Bitmap or maybe even overloaded function.

Describe alternatives you’ve considered

I have tried this:

Marker(
...
  icon = getBitmapFromVector(context,theme)
)

fun getBitmapFromVector(context: Context, theme: Resources.Theme): Bitmap? {
    return ResourcesCompat.getDrawable(context.resources, R.drawable.ic_vector, theme)?.toBitmap();
}

also might be usefull for someone

Marker(
  icon = getBitmapFromVector(
    LocalContext.current,
    R.drawable.ic_image,
    0xffff0000.toInt()
  )
)

fun getBitmapFromVector(
    context: Context,
    drawableRes: Int,
    color: Int = 0x00000000.toInt()
): BitmapDescriptor? {
    val drawable = ResourcesCompat.getDrawable(context.resources, drawableRes, null)
    if (drawable != null) {
        drawable.colorFilter = BlendModeColorFilterCompat
            .createBlendModeColorFilterCompat(
                color,
                BlendModeCompat.SRC_ATOP
            )
        return BitmapDescriptorFactory.fromBitmap(drawable.toBitmap())
    }
    return null;
}

Additional context

Using Build.gradle

    // Google Maps
    implementation "com.google.maps.android:maps-compose:2.1.0"
    implementation 'com.google.android.gms:play-services-maps:18.0.2'
    implementation 'com.google.maps.android:android-maps-utils:2.3.0'

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
stale[bot]commented, Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

<marker> - SVG: Scalable Vector Graphics - MDN Web Docs
Tip: you can click/tap on a cell for more information. Full support: Full support.
Read more >
Marker Vector Art, Icons, and Graphics for Free Download
Browse 40847 incredible Marker vectors, icons, clipart graphics, and backgrounds for royalty-free download from the creative contributors at Vecteezy!
Read more >
Scalable vector graphics support—ArcGIS Pro | Documentation
Scalable Vector Graphics (SVG) is a vector image format for 2D graphics. ... You can import SVG files as marker symbol layers within...
Read more >
Tissue Orientation Marker For Physicians - Vector Surgical
Vector Surgical's tissue orientation system provides physicians with solutions to support successful surgical outcomes from the OR through recovery.
Read more >
Markers with Vector-Based Icons | Maps JavaScript API
This example uses SVG path notation to add a vector-based symbol as the icon for a marker. The resulting icon is a marker-shaped...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found