I want to draw a line in OSM between 2 points ,but i cant find anything that help me. something likes Polyline in googlemap.
public class MainActivity extends Activity {
private MapView mMapView;
private MapController mMapController;
public TextView textView;
public String longitude;
public String latitude;
public Drawable marker;
private ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay;
ArrayList<OverlayItem> overlayItemArray;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.osm_main);
mMapView = (MapView) findViewById(mapview);
textView = (TextView) findViewById(R.id.textView);
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapView.setBuiltInZoomControls(true);
mMapController = (MapController) mMapView.getController();
mMapController.setZoom(16);
Double latE6 = (52.507621 )* 1E6;
Double lngE6 = (13.407334 )* 1E6;
GeoPoint gPt = new GeoPoint(latE6.intValue(), lngE6.intValue());
mMapController.setCenter(gPt);
}
}
I place this code in onCreate after this line:
mMapController.setCenter(gPt);
GeoPoint gPt0 = new GeoPoint(52.507621d, 13.407334d);
GeoPoint gPt1 = new GeoPoint(52.527621d, 13.427334d);
PathOverlay myPath = new PathOverlay(Color.RED, this);
myPath.addPoint(gPt0);
myPath.addPoint(gPt1);
mMapView.getOverlays().add(myPath);
Note:Use d after your point .