How To Add Overlay Item In My Current Location In This Code
Here is my code !! i want to add overlay item in my current location !! but seems a problem i cant can any one check what i have to add to my code to just put overlay item appea
Solution 1:
Just add this piece of code at your onLocationChanged
@Override
public void onLocationChanged(Location l) {
// TODO Auto-generated method stub
overlayList = mapView.getOverlays();
MyLocationOverlay object = new MyLocationOverlay(yourclass.this, mapView);
overlayList.add(myLocation);
myLocation.enableMyLocation();
}
Solution 2:
I'm late to the party, but the reason you are getting the error:
The constructor HelloItemizedOverlay(Drawable, tryanabtry.MyLocationListener) is undefined
is because of your use of this
when calling the constructor of HelloItemizedOverlay
. In this context, this
refers to the instance of MyLocationListener
which the code is within, and not an instance of the class tryanabtry
.
Replace this line:
itemizedOverlay11= new HelloItemizedOverlay(drawable11,this);
with this:
itemizedOverlay11= new HelloItemizedOverlay(drawable11,tryanabtry.this);
Please also note that by convention Java classes should start with a capital letter, so Tryanabtry
instead of tryanabtry
.
Post a Comment for "How To Add Overlay Item In My Current Location In This Code"