Search This Blog

Saturday, 12 January 2013

Drawing overlay on map in android, we have discusses in previous article. I suggest you to go through that article for easy way to get current concept. Projection class is responsible for converting device coordinate to Geo point and vice-versa. Once we convert these point to each other, our task of drawing path between two Geo point becomes very easy.

So lets start consider that you have already make one map simple application in android. And look at screen of simple map application result using your Map API Key

Now divide further task in steps----

Step 1) Create two point to draw on map using OverlayItem. After creating two Geo point, we will create one class ItemizedOverlayItem to populate these point on MapView

Some points and lines need to be discusses here. One important thing is Projection which allows us to interchange device coordinate to Geo point. So look at thisGeoPoint geopoint = new GeoPoint(230286706, 72509145);Point pointOne = projection.toPixels(geopoint, null);geopoint = new GeoPoint(222286706, 71509145);Point pointtwo = projection.toPixels(geopoint, null);
Attaching Layer name Overlay class to map to create any figure OverLayClass mOverLayClass = new OverLayClass(projection, this, mapView);mapView.getOverlays().add(mOverLayClass);So now its time for complete source code