Sai's Stack
Sai's Stack

Reputation: 1385

Unable to create custom marker icon in Mapbox

I have to display custom icon for the marker in the mapbox.

I am trying with this code :

IconFactory mIconFactory = IconFactory.getInstance(this);
        Drawable mIconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_directions_boat_black_18dp);
        Icon icon = mIconFactory.fromDrawable(mIconDrawable);

Problem: with IconFactory i.e shows there is no class for IconFactory.

And for the marker

mapView.addMarker(new MarkerOptions()
                        .position(new LatLng(latitude, longitude)
                         .icon())

When I was trying with this above marker code Getting

Problem : there is no code for icon().

I am using

 compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:2.1.0@aar') {
        transitive = true
    }

in the build.gradle.

I thought my problem is with this map box library. Can you please help me. Thanks in Advance.

You can see my code here. enter image description here

Upvotes: 2

Views: 1290

Answers (2)

Sina
Sina

Reputation: 97

just update your library dependency as below :

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.3.0'

and then you can use it just like you did earlier :

    IconFactory mIconFactory = IconFactory.getInstance(this);
    Drawable mIconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_directions_boat_black_18dp);
    Icon icon = mIconFactory.fromDrawable(mIconDrawable);

Upvotes: 0

Shoeb Siddique
Shoeb Siddique

Reputation: 2825

Please add this in your gradle dependency.

dependencies {
       compile 'com.google.maps.android:android-maps-utils:0.3+'
}

Upvotes: 1

Related Questions