Reputation: 1598
I'm trying to use mapsforge to do a display maps on my phone.
Currently I'm having slight problems with regards to adding an overlay to display pins. This is the code that gives an error:
ArrayItemizedOverlay itemizedOverlay = new ArrayItemizedOverlay(defaultMarker, true);
myOpenMapView.getOverlays().add(itemizedOverlay);
getOverlays() will return List, as stated here
This line gives this error:
"The method add(Overlay) in the type List<Overlay> is not applicable for the arguments (ArrayItemizedOverlay)"
which is what I don't really understand is why the .add() method is invalid in this case, since ArrayItemizedOverlay class is a subclass of the Overlay class.
These are the class definitions and I hope someone can enlighten me what I can do so that the .add() method will accept the object.
public class ArrayItemizedOverlay extends ItemizedOverlay<OverlayItem> {
//codes....
}
public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay {
//codes...
}
Feel free to point out any missing information which you may need, thanks!
Upvotes: 0
Views: 2102
Reputation: 68
Were you able to find out the complete path of the calsses and interfaces used?
public List<Overlay> getOverlays()
returns a list of
public interface org.mapsforge.android.maps.overlay.Overlay
But the code base has a different overlay class
public abstract class Overlay extends Thread {
Is there an older version in the classpath? You probably have to cleanup the older JARs/APIs and make sure it refers to the correct overlay class.
Upvotes: 2
Reputation: 543
Use the method addAll() of List to add a Collection of Object.
Upvotes: 0