I am new to Android development and navigation applications. I am developing navigation app same as Google Navigation but with different path. I am able to get my own path. Now I want to show my path in app in the same fashion as Google Navigation app does. But I don't want to use Google Navigation API. In the Google navigation app, they represent the current position by an arrow.
Does any one knows how to use the same representation? Or any one can give me any hints where should I look for?
The Android Asset Studio is quite a good website for icons, you can create one very similar to the usual google maps marker.
Adding a marker to map is done using overlays in android. The code below is in an activity's onCreate that extends MapActivity.
MapView myMap = ((MapView)findViewById(R.id.myMapView));
Drawable marker = getResources().getDrawable(R.drawable.marker);
List<Overlay> mapOverlays = null;
GeoPoint point = new GeoPoint(Latitude, Longitude)
myOverlays overlays = new myOverlays(marker, this);
Overlay item oi = new OverlayItem(point, "Desc", "");
overlays.add(oi);
mapOverlays = myMap.getOverlays();
mapOverlays.add(overlays);
myOverlays class:
import java.util.ArrayList;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
@SuppressWarnings("rawtypes")
public class myOverlays extends ItemizedOverlay {
private ArrayList<OverlayItem> overlays = new ArrayList<OverlayItem>();
Context context;
public myOverlays(Drawable marker) {
super(boundCenter(marker));
}
public myOverlays(Drawable marker, Context act) {
super(boundCenter(marker));
context = act;
}
public void addOverlay(OverlayItem overlay) {
overlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return overlays.get(i);
}
@Override
public int size() {
return overlays.size();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With