Com.tomtom.sdk:maps-display:0.3.344 sample code

Hi all,

Are there any newer sample code available for the maps version 0.3.344 ?
I am looking for sample code for Marker with clustering implementation in Java.
This sample tomtom-international - map-sdk-for-android-examples on GitHub does not seem to be
compiling properly, deprecated ?



Most up-to-date examples are published in the developer portal.
You can find Markers for Android SDK here:

If you have any more questions, feel free to reply.

Thank you very much for your response. I have created my TomTom app framework from the following link to display the map and it works just fine.

Then I decided to add map marker to the map from the code you have shown me earlier but I encountered a bunch of errors which are not related to missing import . I’m kinda stucked at this point and do not know how to proceed further. Could you please lend me a helping hands and points me in the correct direction as currently I am at a total lost in this map marker thing…
I have included my build.gradle (module), the main source file for your reference.


package com.example.ttmapstuff;

import android.os.Bundle;

import androidx.annotation.NonNull;

import android.provider.CallLog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tomtom.sdk.maps.display.TomTomMap;
import com.tomtom.sdk.maps.display.MapOptions;
import com.tomtom.sdk.common.location.GeoCoordinate;
import com.tomtom.sdk.maps.display.image.Image;
import com.tomtom.sdk.maps.display.image.ImageFactory;
import com.tomtom.sdk.maps.display.marker.Marker;
import com.tomtom.sdk.maps.display.marker.MarkerOptions;

import timber.log.Timber;


dependencies {
implementation “com.tomtom.sdk:maps-display:0.3.344”
implementation “com.tomtom.sdk:location-android:0.3.344”
implementation “com.tomtom.sdk:search-client-online:0.3.344”
implementation “com.tomtom.sdk:routing-client-online:0.3.344”

implementation 'androidx.appcompat:appcompat:1.5.0'
implementation ''
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation ''
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


Thank You,

1 Like

Using ImageFactory requires using INSTANCE as well.
Therefore, the invocation should look like this:


We can also see that you are mixing the Java class with Kotlin code.

Thank you very much for the tips! that sure works for ImageFactory now…
Regarding the Kotlin code in Java I have no other choice since my main program was written purely in Java code only and the map is my last module to be integrated with it. TTMapStuff was just a simplified framework for testing of TomTom map Android SDK before exporting the code to the main program.
What would the code looked like in Android Java for the following TomTom code ?

val amsterdam = GeoCoordinate(52.379189, 4.899431)
val markerOptions = MarkerOptions(
coordinate = amsterdam,
pinImage = ImageFactory.fromResource(R.drawable.ic_marker_pin)

Currently, on my Android Studio Chipmunk 2021.2.1 Patch 1 the error looks like this…

The problems appears to be in the R.drawable.markerpin_foreground

Also, I am a complete newbie with Kotlin…

Please respond,
Thank you very much!

Hi again,

Regarding MarkerOptions, you need to write down all arguments when using Java.
You can see default values here

The @Override issue looks like you didn’t declare the OnMapReadyCallback implementation on this class.

Ok, noted!
Thank you very much!!!


These declarations got rid of all my previous errors.

public void onMapReady(@NonNull TomTomMap tomTomMap) {
    TomTomMap ttmap = null;
    GeoCoordinate amsterdam = new GeoCoordinate(52.379189, 4.899431);
    GeoCoordinate coordinate;
    Image pinImage;
    Object markerOptions;
    Image pinIconImage;
    Image shieldImage;

    Object tag;
    Label label;
    String balloonText;

    markerOptions = new MarkerOptions(
            coordinate = amsterdam,
            pinImage = ImageFactory.INSTANCE.fromResource(R.drawable.markerpin_foreground),
            pinIconImage = null,
            shieldImage = null,
            tag         = null,
            label       = null,
            balloonText = "Bahloon"
    //ttmap.addMarker((MarkerOptions) markerOptions);

As for the OnMapReadyCallback I declared it on the fragment class like so…

public class MapFragment extends Fragment implements com.tomtom.sdk.maps.display.ui.OnMapReadyCallback {

From here I just right clicked on the above line and then clicked the ‘implement’ that generate the below function

public void onMapReady(@NonNull TomTomMap tomTomMap)

But this function did not get called when the map is finished loading… why?
Do I have to called the OnMapReadyCallback from the MainActivity instead ?

Also, from your website at the end of the page

Where is the function getMapAsync() hidden at ? I can’t seem to be able to located this function at all !!!

Thank You very much!

Hi All,

Now I’m getting this error in the getMapAsync() function
error: incompatible types: cannot be converted to
mapFragment.getMapAsync(new com.tomtom.sdk.maps.display.ui.OnMapReadyCallback() {

mapFragment.getMapAsync(new com.tomtom.sdk.maps.display.ui.OnMapReadyCallback() { });
if I switched the above to
mapFragment.getMapAsync(new OnMapReadyCallback() { });
public void onMapReady(@NonNull TomTomMap tomTomMap) {}
public void onMapReady(@NonNull GoogleMap googleMap) {}

essentially back to Google Map those errors went away.

My question is, how to I go about keeping TomTom map in the code without causing those red error lines ?


In line 49, you are casting to SupportMapFragment, which is Google’s.
You should cast to TomTom’s MapFragment class. Assuming you already declared the fragment correctly in the layout.xml (with the android:name attribute).

The reason for the used of SupportMapFragment is the access to member function getMapAsync().
With MapFragment there isn’t any member function named getMapAsync() !? From my understanding getMapAsync() is the entry point to onMapReady() ?. If this is the case then where is getMapAsync() in MapFragment ?

The following is my fragment_map.xml

<?xml version="1.0" encoding="utf-8"?>

< xmlns:tomtom=“
tomtom:mapKey=“1234567890” />

Thanks again,