0

I wanted to set an onmarkerclicklistener for the map, but I get:

"Attempttoinvokevirtualmethod'voidcom.mapbox.mapboxsdk.maps.MapboxMap.setOnMarkerClickListener(com.mapbox.mapboxsdk.maps.MapboxMap$OnMarkerClickListener)' on a null object reference"

I guess this is because I haven't initialized the map, but I dont know how to.

Anyone knows? Thanks!

1 Answers1

0

You can init mapBox with:

Mapbox.getInstance(getApplicationContext(), getString(R.string.mapbox_access_token));

Check documentation

Onix
  • 662
  • 3
  • 10
  • I have already done that, what I want to do is initializing the variable map which is a MapboxMap – Ruy Bensi Nov 15 '18 at 08:49
  • Check step "4. Add a map" in documentation and in method "onMapReady" you can add marker, set listeners etc. – Onix Nov 15 '18 at 08:52