I've been busy for a long time finding out how to draw a line between two (GPS) points on the map in HelloMapView but with no luck.
Could anyone please tell me how to do so.
Suppose I use the HelloMapView which extends MapView. Do I need to use overlays? If so do I have to override the onDraw() method of the overlay and draw a line here? I actually tried these things but with no result.
Thank you in advance!
just i will find draw with some rectangle in
mapview
just we want change paint as we likeEmptyOverlay.java
MapExampleActivity.java
MapOverlay.java
see this http://n3vrax.wordpress.com/2011/08/13/drawing-overlays-on-android-map-view/
It is really easy with Google Maps Android API v2
Just copy the example from Developer documentation
(of course you have to init your map first)
Yes you need to use overlays.
You need to get the MapView's overlays and add your new overlay onto it.
Your class extends Overlay, which is a transparent canvas in which you can draw on it like any other canvas.
You can use mapView.getProjection() to get projection of map view.
...
More info found here: http://blogoscoped.com/archive/2008-12-15-n14.html
This is full source code to draw direction path from source latitude and longitude to destination latitude and longitude. I have changed the above code to fit for latitude and longitude rather than source and destination. So anyone who is accessing his latitude and longitude through his gps can get the direction from his gps device to the destination coordinates.
Thanks to above answers we could make such a change and get path direction.
Hope it helps for other Stack Overflow users
This can be done by using intents too: