Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSMdroid - error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable

While extending OSMdroid Overlay class in an application

import org.osmdroid.views.overlay.Overlay;
...
public class MapOverlayArea extends Overlay implements TextToSpeech.OnInitListener, OnTouchListener  {

...

I receive an error:

error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable

like image 825
tony gil Avatar asked Apr 21 '16 16:04

tony gil


1 Answers

As indicated by the error message, the required constructor was missing.

public class MapOverlayArea extends Overlay implements TextToSpeech.OnInitListener, OnTouchListener  {

    public MapOverlayArea(Context ctx) {
        super(ctx);
    }

    //....
}

Including the constructor as above, and calling it correctly from main activity using

MapOverlayArea mapOverlayArea = new MapOverlayArea(context);

solves the problem.

like image 194
3 revs, 3 users 65% Avatar answered Nov 12 '22 13:11

3 revs, 3 users 65%