I have been trying this for a month and a lot of my readers asked to write a tutorial that makes it easy to draw a line on Google Maps for Android between two locations. I have gone through a lot of material. Most of the articles on this exact issue are not exactly addressing this specific issue. So their code is way too complex for this simple task. I have tried to make this as simple as possible.
Assumption About The Reader:
At this point I assume that reader of this article have already configured everything and Google Maps are displayed in their emulator properly. For those who don’t have Google Maps properly displayed in their emulator, they can read my earlier articles. Links provided at the end of this article.
Objective:
Draw a line that between two points on Google Maps lets say City “A” and City “B”. Repeat the process to draw a line between City “B” and City “C”.
What we need:
Coordinates of 3 cities or any 3 locations that we want to connect.
- Abbottabad : 34159000,73220000
- Islamabad : 33695043,73050000
- Rawalpindi : 33615043, 73050000
I have taken relative coordinates of 3 Pakistani cities starting from Abbottabad (where my family lives), moving to Islamabad (Capital of Pakistan). From Islamabad moving to Rawalpindi.
Coding (the part everyone’s been waiting for):
Create an overlay class lets say by the name of MyOverlay inside our main activity class named “GoogleMapsDrawPath” that extends MapActivity
class MyOverlay extends Overlay{ public MyOverlay(){ } public void draw(Canvas canvas, MapView mapv, boolean shadow){ super.draw(canvas, mapv, shadow); //Configuring the paint brush Paint mPaint = new Paint(); mPaint.setDither(true); mPaint.setColor(Color.RED); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(4); GeoPoint gP1 = new GeoPoint(34159000,73220000);//starting point Abbottabad GeoPoint gP2 = new GeoPoint(33695043,73050000);//End point Islamabad GeoPoint gP4 = new GeoPoint(33695043, 73050000);//Start point Islamabad GeoPoint gP3 = new GeoPoint(33615043, 73050000);//End Point Rawalpindi Point p1 = new Point(); Point p2 = new Point(); Path path1 = new Path(); Point p3 = new Point(); Point p4 = new Point(); Path path2 = new Path(); projection.toPixels(gP2, p3); projection.toPixels(gP1, p4); path1.moveTo(p4.x, p4.y);//Moving to Abbottabad location path1.lineTo(p3.x,p3.y);//Path till Islamabad projection.toPixels(gP3, p1); projection.toPixels(gP4, p2); path2.moveTo(p2.x, p2.y);//Moving to Islamabad location path2.lineTo(p1.x,p1.y);//Path to Rawalpindi canvas.drawPath(path1, mPaint);//Actually drawing the path from Abbottabad to Islamabad canvas.drawPath(path2, mPaint);//Actually drawing the path from Islamabad to Rawalpindi } }
Explanation:
The code is pretty self explanatory as I have commented the parts that required explanation. First we configure the paint brush. To draw a line between two points we need to have coordinates of at least two locations but as I am connecting 3 locations, I have taken 4 GeoPoints , repeating the coordinates of Islamabad. I have done this to demonstrate that each time we draw a line we will need two points. After that I have created 4 Points and 2 Paths. Than setting the Projection. In simple words associating the GeoPoints to Points. After this setting the Paths like moving it to a starting location and defining the end point of the Path. Lastly call the canvas.drawPath(path1, mPaint) method providing it the path and the brush to actually draw the line on the map.
Configuring the Main Activity Class:
Add the following code in the onCreate method of GoogleMapsDrawPath class.
mapView = (MapView) findViewById(R.id.mapview1);//Creating an instance of MapView mapView.setBuiltInZoomControls(true);//Enabling the built-in Zoom Controls gP = new GeoPoint(33695043, 73000000);//Creating a GeoPoint mc = mapView.getController(); mc.setCenter(gP); mc.setZoom(9);//Initializing the MapController and setting the map to center at the //defined GeoPoint mapOverlays = mapView.getOverlays(); projection = mapView.getProjection(); myoverlay = new MyOverlay(); mapOverlays.add(myoverlay);
Explanation:
Create instance of the mapView, enable the built-in zoom controls. Create GeoPoints and move the map to center at the created GeoPoint. Lastly add overlays from the myOverlay class to the map.
Some Extras that need explanation:
I feel the need of explaining a few more things that even if we don’t understand the code will work. But the readers have the right to know why a certain method, object, class etc is used.
- GeoPoint :An immutable class representing a pair of latitude and longitude, stored as integer numbers of microdegrees
- Projection :A Projection serves to translate between the coordinate system of x/y on-screen pixel coordinates and that of latitude/longitude points on the surface of the earth.
- Point :Converts the given
GeoPoint
to onscreen pixel coordinates, relative to the top-left of theMapView
that provided this Projection
Complete Code for GoogleMapsDrawPath Application:
package com.android.googlemapsdrawpath; import java.util.List; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.Projection; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Point; import android.os.Bundle; public class GoogleMapsDrawPath extends MapActivity { /** Called when the activity is first created. */ private List mapOverlays; private Projection projection; private MapController mc; private MapView mapView; private GeoPoint gP; //private GeoPoint gP2; private MyOverlay myoverlay; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview1);//Creating an instance of MapView mapView.setBuiltInZoomControls(true);//Enabling the built-in Zoom Controls gP = new GeoPoint(33695043, 73000000);//Creating a GeoPoint mc = mapView.getController(); mc.setCenter(gP); mc.setZoom(9);//Initializing the MapController and setting the map to center at the //defined GeoPoint mapOverlays = mapView.getOverlays(); projection = mapView.getProjection(); myoverlay = new MyOverlay(); mapOverlays.add(myoverlay); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } class MyOverlay extends Overlay{ public MyOverlay(){ } public void draw(Canvas canvas, MapView mapv, boolean shadow){ super.draw(canvas, mapv, shadow); //Configuring the paint brush Paint mPaint = new Paint(); mPaint.setDither(true); mPaint.setColor(Color.RED); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(4); GeoPoint gP1 = new GeoPoint(34159000,73220000);//starting point Abbottabad GeoPoint gP2 = new GeoPoint(33695043,73050000);//End point Islamabad GeoPoint gP4 = new GeoPoint(33695043, 73050000);//Start point Islamabad GeoPoint gP3 = new GeoPoint(33615043, 73050000);//End Point Rawalpindi Point p1 = new Point(); Point p2 = new Point(); Path path1 = new Path(); Point p3 = new Point(); Point p4 = new Point(); Path path2 = new Path(); projection.toPixels(gP2, p3); projection.toPixels(gP1, p4); path1.moveTo(p4.x, p4.y);//Moving to Abbottabad location path1.lineTo(p3.x,p3.y);//Path till Islamabad projection.toPixels(gP3, p1); projection.toPixels(gP4, p2); path2.moveTo(p2.x, p2.y);//Moving to Islamabad location path2.lineTo(p1.x,p1.y);//Path to Rawalpindi canvas.drawPath(path1, mPaint);//Actually drawing the path from Abbottabad to Islamabad canvas.drawPath(path2, mPaint);//Actually drawing the path from Islamabad to Rawalpindi } } }
Related articles
- Android Google Maps Tutorial Part 1. Basic Development. (mirnauman.wordpress.com)
- Android Google Maps Tutorial Part 2. Using GPS in Android and Animating Google Maps to the Current GPS location. (mirnauman.wordpress.com)
- Android Google Maps Tutorial Part 3. Adding An Image to GoogleMaps Using Map Overlays. (mirnauman.wordpress.com)
- Android Google Maps Tutorial Part 5, Adding Multiple Images To Google Maps Using ItemizedOverlay. (mirnauman.wordpress.com)
- Android Google Maps Tutorial Part 6, Getting The Location That Is Touched. (mirnauman.wordpress.com)
67 comments
Comments feed for this article
April 27, 2012 at 4:34 am
Android Google Maps Tutorial Part 3. Adding An Image to GoogleMaps Using Map Overlays. « Mir
[…] Android Google Maps Tutorial Part 7, Drawing A Path or Line Between Two Locations (mirnauman.wordpress.com) […]
April 27, 2012 at 4:37 am
Android Google Maps Tutorial Part 4, Adding Menu & Some Additional Functionality Like Zooming, Changing Map View, Animating To GPS Current Location Using Menu Button. « Mir
[…] Android Google Maps Tutorial Part 7, Drawing A Path or Line Between Two Locations (mirnauman.wordpress.com) Share this:TwitterLinkedInFacebookEmailPrintLike this:LikeBe the first to like this post. Categories […]
May 9, 2012 at 3:57 am
Mir
Reblogged this on Mir.
May 13, 2012 at 8:37 am
andrias
Hi Mir i have a question can you help me with this i want when i touch one of the stars in the map to open an information viewer for example information
about Islamabad
May 17, 2012 at 9:45 am
satyanarayana
Hi, I have one doubt did you check the same code work for from France to Abbottabad.
May 17, 2012 at 10:46 am
Mir
ideally it should work, coz the code needs a starting lat, long and and ending lat, long. now it depends on u which ever start end locations u select. but if u have tried it and its not working than u should zoom in or out a lil. thay may solve the issue.
May 21, 2012 at 8:07 am
Ahmed
Great tutorial .. you are talented in making the tutorial clear and easy to follow.
I can see that your tutorial explaining how to draw a path between two Geopoints, do you have any idea of how to implement a complete route between two locations, i.e not only the direct path?
thanks
May 21, 2012 at 8:25 am
Mir
Dear Ahmed,
Thanks for appreciating my efforts, to draw a complete route u need the same code that is in the tutorial, all u need is to have more geo points. End of one Geo Point will the the start of the next one and so on. By connecting multiple geo points u can get the complete route. there are a number of ways to do this. First , provide all Geo points Statically in the code as i have done, defined three points drawing two lines. The second one would be to get the Coordinates directly from the GPS and move along a path or u can even get the coordinates by touching a multiple locations on the map and getting coordinates from it. There can be many more but the basic logic stays the same i.e, u need two points to draw a single line, 3 points to draw 2 lines and so on.
Hope this helps.
May 21, 2012 at 7:24 pm
Shakeel (android Developer)
A dedicated person working whole heartedly for the welfare of beginners……I think developing all these application is his interest. Good Job..Keep it up…This person also helped me lot.
May 22, 2012 at 7:41 pm
Ahmed
Thanks a lot Mir!
You’re right about the basic logic of routing, but what I meant here is “I believe” much more complicated .. it is about an algorithm that does the following:
1- calculates the several routes “could be thousands”, and decide the best route among them.
2- recognizes google maps ” i.e recognize the streets, junctions …etc” and draw the path along these streets – which of-course must be provided by google itself-.
So I think google must have these options for developers.
I hope my point was clear, and thanks anyway you were very helpful 🙂
May 24, 2012 at 1:17 pm
Mir
Dear Ahmed,
I don’t know about that right now as i have not explored it yet, but i ll go through some googling. if i find something i write a tutorial about it and will share it wid every1
May 25, 2012 at 5:04 pm
Ahmed
thanks!
I’ll do the same 🙂
June 2, 2012 at 5:23 pm
sabu
did you know how
to display the name of the location or address against the latitude and longitude ?..
June 3, 2012 at 5:10 pm
Mir
yes , the process is called Geocoding, and getting coordinates from location names is called Reverse Geo Coding. i ll soon write a tutorial about it. check back soon.
June 7, 2012 at 10:02 am
Mir
plz go through my tutorial that explains geocoding and reverse geocoding
June 3, 2012 at 10:40 am
Alex
Great tutorial Mir!
Do you have any ideea what i should use if i want to draw a line from my current location to a placed geo point on the map?
June 3, 2012 at 5:09 pm
Mir
hi aliex,
its simple , first use my tutorial to get ur current location and animate the map to the current location, this will be location A. when u r done with that. than u must have another geo point that will be location B, either u can hard code it or touch a location on the map. get the touched location as location B. Than use this tutorial to draw a path between these two points
June 11, 2012 at 12:26 pm
Bogdan
Just wanted to say thank you, Great job man!
June 18, 2012 at 4:42 pm
roman
grate tutorial,
i was interested to find something similar on direction proc.
what i found:
a) KML usage : http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
b)how to draw a path with KML: http://stackoverflow.com/questions/3109158/how-to-draw-a-path-on-a-map-using-kml-file/3109723#3109723
any ideas : how to make it more simple way?
June 19, 2012 at 5:09 am
Mir
i am currently working on KML parsing. i ll try to come up wid something simpler.
June 18, 2012 at 5:10 pm
manu
great tutorial mir thank u>…………!!!!!!!!!
July 4, 2012 at 12:41 pm
pramod
Great its working fine,but i want to draw route from current location to target location can you help me
July 11, 2012 at 4:21 pm
zodiac
great totorial, now i make some app where idon’t use tracking from google, how i can load data longitude|lantitude from database to draw point and overlay it in map(take from google)?
July 12, 2012 at 4:03 am
Mir
there r two ways of doing that, first u create a kml file and parse it in android code, get lat-long pairs form it and map them on google maps. second method would be to store coordinates in sqlite db and read data from it. my next tutorial in google maps section would be on kml parsing. hope that will solve the problem
July 13, 2012 at 2:53 pm
zodiac
if i have some data in array(this data take from database) lilke this for example
(data1, lat, long,)
(data2, lat, long)
(data3, lat, long)
(data4, lat, long)
my question : can i draw line/straight line continues from data1->data2->data3->data4? thanks mir
July 18, 2012 at 5:35 am
Mohit
Thanks Mir…Im developing an android app for bus route finder for sholapur city just like mumbai bestbus app by chetan temkar….spo plz will u help me in this…..
July 18, 2012 at 5:41 pm
Mir
sure i will but i can only guide u. as am stuck wid my office app development i wont be able to go along step by step with the whole application. i have worked on my next tutorial but i don’t even have time to document it and publish it. but as soon as am done wid the office development. i ll be back on the track
August 8, 2012 at 1:52 pm
Aprido Sandyasa
Dear Mr. Mir Nauman Tahir,
Before i read your tutorial, my apps can only draw line/path between two locations(in my apps, source is my location). But now, my perspective has become more broaden coz your tutorial shows me that the map can draw line/path between more than two locations.
Thanks for your tutorial, i could develop more at my apps how to draw more line in between a lot points.
Best regards,
Aprido Sandyasa
August 8, 2012 at 6:20 pm
Mir
Dear aprido sandyasa,
thanks for appreciating my efforts. two draw more line u need to have a set of multiple coordinates. you can either store them in an array or in SQLite DataBase or you can get the coordinates from a KML file (to get coordinates from KML files u will need to manually parse the KML file to get each pair of latitude and longitude). as u can see i have used 3 points. end point of one line becomes the start of the other line and so on. all u need is two points to draw a line, now its up to u how and from wat source u get those 2 points. bottom line, to draw more lines between a lot of points is simple . make the end point coodinates of a line as the start point for the next line and so on. that way u will get a continuous line of multiple points
August 23, 2012 at 1:17 pm
sumit
Mir Sir this program draws a line between two location or points can we show the driving path between then.??
August 27, 2012 at 6:25 am
Mir
ya we can show driving paths but for that we need to use the open street map api. its on my tutorial agenda. will write something about it , hopefully soon
September 27, 2012 at 5:25 pm
umar
i need some help
i am making a projrect in which i received the GPS coordinates througth sms into the google andriod phone .
my problem is i want to put the the coordinates from inbox of the andriod phone in to the google map through some application.
Means the app should continuously get the coordinates from inbox and insert the coordinates for real time tracking plzzzzzz plzzzzzzzzzz plzzzzzzzzzzz any one help me out
Email:omar3228422552@gmail.com
September 28, 2012 at 4:08 am
Mir
its not a big deal bro. will write a tutorial reading contents from sms in inbox. after that the rest u will find in the already published tutorials.
November 9, 2012 at 8:56 am
Pete Heller
Hello Mir,
I want to encapsulate the drawing function so I can call it with two points. This is called by:
itemizedoverlay_line.drawLine(prev_map_point, map_point); //create a line between previous and current point
To add the overlay I use this:
mapOverlays.add(itemizedoverlay_line); //add the overlay
This code is all executing (proved by the Log.d) but the lines are never displayed (all my other layers are displaying correctly). Is there something else I need to do to make the canvas visible? Here is the code:
public class MapLineStyleOverlay extends Overlay {
private ArrayList mOverlays = new ArrayList(); // not sure about this…..
public MapLineStyleOverlay(){ }
public void drawLine(GeoPoint geoPt_1, GeoPoint geoPt_2) {
//Canvas canvas;
//MapView mapv;
boolean shadow = false;
super.draw(canvas, mapView, shadow);
//Configuring the paint brush
Paint paintBrush = new Paint();
paintBrush.setDither(true);
paintBrush.setColor(Color.RED);
paintBrush.setStyle(Paint.Style.FILL_AND_STROKE);
paintBrush.setStrokeJoin(Paint.Join.ROUND);
paintBrush.setStrokeCap(Paint.Cap.ROUND);
paintBrush.setStrokeWidth(12); //originally 4
Point p1 = new Point();
Point p2 = new Point();
Path line_path = new Path();
projection.toPixels(geoPt_2, p1);
projection.toPixels(geoPt_1, p2);
line_path.moveTo(p1.x, p1.y); //Move brush to start poing
line_path.lineTo(p2.x,p2.y); //set line (path) to end point
Log.d(“debug”,”line_path points (p1.x=”+p1.x+ ” p1.y=” +p1.y+ “)”);
canvas.drawPath(line_path, paintBrush); //Actually draw the path
} // [END draw function]
} // [ END MapLineStyleOverlay ]
November 26, 2012 at 10:29 am
Sagar Trehan
Hey,Pete heler
I am facing the same problem as you are.Have you got the solution of it.It got them please explain me.Thanks in advance
Also thanks to Mir as this is the best map tutorial for me.
November 29, 2012 at 12:08 pm
Durratulmazd Rokadia
hey mir awesome tut buddy…but m stuck in my app as i want to show real time driving path in map means start location will be location from where user starts driving and as he drives he should be able to view the dotted lines till he reaches the destination.can you help me do you need any more info then please let me know…….thnx
November 29, 2012 at 12:20 pm
sagar trehan
To show the real time path that you have followed while driving from source to destination you need to run your app on real android device.
For this as Mir had posted his awesome tutorial of how to draw a path between between two latitude and longitude pair.You just have to follow that.
For it you have to use requestLocationUpdate() method in this you must pass the minTime and minDistance after which you want to take latitude and longitude points.You have to store all these latitude and longitude pair in SQLite database later on reaching destination you must call the tutorial-7 of Mir iteratively on the latitude and longitude pair present in SQLite database.
I have tested it today in my emulator with the help of emulator control.So I think if you follow my advice then you’ll definitely do it.
November 29, 2012 at 12:16 pm
Durratulmazd Rokadia
after showing route i need to calculatae distance between the start and end point.
November 29, 2012 at 12:41 pm
Durratulmazd Rokadia
thnx sagar i wl definately try it…
November 30, 2012 at 6:08 am
Durratulmazd Rokadia
hey sagar i tried googling about what you adviced but didnt succeed can you recomend some tutorials for the same or sample code…thnx..
November 30, 2012 at 6:46 am
sagar trehan
Hey Durratulmazd Rokadia,
just give your email-id I will send my project source to you.
November 30, 2012 at 6:53 am
Durratulmazd Rokadia
durrat_rokadia2007@yahoo.com
send it on above id
thnx…
December 3, 2012 at 8:23 am
Durratulmazd Rokadia
hey sagar thnx for helping ur code helped lot but my issue was solved by invoking google native google maps application using intent and passing url as i ws in need to show turnby turn direction….thnx lot for helping…
December 3, 2012 at 8:41 am
sagar trehan
Thanks buddy…It my pleasure..
December 18, 2012 at 6:48 am
Android Google Maps Tutorial Part 4, Adding Menu & Some Additional Functionality Like Zooming, Changing Map View, Animating To GPS Current Location Using Menu Button. « Mir
[…] Android Google Maps Tutorial Part 7, Drawing A Path or Line Between Two Locations (mirnauman.wordpress.com) […]
December 28, 2012 at 9:45 am
Tutorial Membuat Marker Line di Google Map | garisbesar
[…] referensi : https://mirnauman.wordpress.com/2012/04/26/android-google-maps-tutorial-part-7-drawing-a-path-or-line… […]
January 7, 2013 at 3:49 am
LiJuan
Hi,
If i want to draw a line between two points which those points define by myself, how should i do it? Those points are store in a text file
January 8, 2013 at 10:39 am
Pravin Divraniya
Hi Mir,
I just wanted to know that is it possible in Android to draw particular area on map view and fill it with specific color?
Your help would be highly appreciated.
January 14, 2013 at 6:14 pm
mbakrizq
Great tutor. Thanks tm Mr @mirnauman.
February 21, 2013 at 4:26 am
coolspirits
hi mir,
can u plz tell how to show route between two points (source and destination ) also alternative routes …… (without using website or kml file) we want this functionality to be embedded in our application!! PLZ REPLY SOON!!
February 21, 2013 at 4:31 am
Mir
there is no shortcut in Google Maps API V1. i ll explore the API V2, if google provides anything that makes this route drawing easy, i ll post the tutorial about it.
February 21, 2013 at 4:39 am
coolspirits
we are trying to copy google directions service …. in our application…eg. in two textboxes we specify source and destination… (with google map behind the overlay) and when we press enter… the routes are displayed! ……
thanks 🙂
February 21, 2013 at 7:29 am
coolspirits
Please reply!!!! its REALLY important!!!!! we have to submit first deliverable!!! 😦
February 24, 2013 at 6:16 pm
Maimoonah
Thanks for the tutorial.
I want to draw points with lines ?How?
February 26, 2013 at 8:16 am
Mir
this articles is about drawing lines between two points. if u r trying to do something else, please clearly explain ur question in detail.
February 26, 2013 at 8:30 pm
Maimoonah
yes ,I want to show points or “circles” above the lines ,
To show that this place is visited here
((not just lines))
Or in a more clear explanation:” how to draw points on map in android?”
February 26, 2013 at 8:43 pm
Maimoonah
I’ve another question , in this tutorial you have entered GPS coordinates (in the code”,without using GPS classes and functions.
So I want to draw path if the “location changed “according to updates .so I think I will need a database to store points, my question is :how to connect between GPS and the Map-overlay class …
To make it more clear :
se this inst in this tutorial :
GeoPoint gP1 = new GeoPoint(34159000,73220000);//starting point Abbottabad
GeoPoint gP2 = new GeoPoint(33695043,73050000);//End point Islamabad
GeoPoint gP4 = new GeoPoint(33695043, 73050000);//Start point Islamabad
GeoPoint gP3 = new GeoPoint(33615043, 73050000);//End Point Rawalpindi
these instructions are put in :”class MyOverlay” ,and the function :”Onlocationchanged” is put in another class , so how to do this?
(((((((( drawing path between 2 taken GPS locations))))))
Thanks
February 27, 2013 at 6:34 am
Mir
it is simple. the overlay class is written inside the main activity class in the same file. so no extra effort of mechanism required to access the gp1 and gp2 etc. just create and object of the overlay class and use the objects inside it.
March 3, 2013 at 5:21 pm
myusro
Hi…Friend,
Good Tutorial, Thanks
Regards
March 3, 2013 at 5:25 pm
Drawing A Path or Line Between Two Locations » Muhammad Yusro
[…] By. Mir Nauman Tahir in His Blog […]
March 24, 2013 at 12:39 pm
sonalshines
Hi,could you please provide me the code for search location as well as show_routes from source(current location as GPS) to destination..I have followed your tutorial and have got the expected output
March 28, 2013 at 4:24 am
Mir
i have changed several machines in the past few month , survived some severe crashes. so i dont have a compiled source code of all the mini projects that you see on my blog. but i have included the complete source code in the articles.
March 28, 2013 at 6:08 pm
Moe
im having problem. how do i make it get location from edittext when a button is clicked?
March 29, 2013 at 5:06 am
Mir
check the above article. this might solve alot of ur issues. its not actually a button click, rather its a menu button that is clicked. but it will get u the idea of how things work.
June 17, 2013 at 2:16 pm
shishram
Hi Mir,
First of all awesome tut!!, thanks for sharing your knowledge.
second, i am facing issue in showing route according to driving direction ,what i’m getting only straight line so pls help me out here
thanks in advance for your consideration.
June 17, 2013 at 3:26 pm
Mir
Dear Shishram,
Thanks for the compliment. Google has changed alot with the launch of Android Google Maps API Ver 2.0. Everything that used to work with API Ver 1.0 is history now. still if you managed to get the api key before google changed the whole process you can develop but there will be a point when u will switch to Android google maps API ver 2.0. I have started working on writing tutorials for Android google maps API Ver 2.0. and will address every issue one by one. so you need to follow my latest series of article to keep updated.
Now coming to ur specific issue. if you use openstreetview api or some other open source streetview api, that will give you the right driving directions along the paths as we see them in navigation section of google maps. I have not written anything on using that api . u can check the links
openstreetmap.org and openstreetview.org
hope this helps,
thanks and best regards.
September 24, 2013 at 9:14 am
Ravi Kumar
nice article ..
I have also found another example to draw interactive polyline path from source to destination in Google Maps v3 visit http://www.etechpulse.com/2013/09/draw-interactive-polyline-path-from.html
Thanks!