user244394
user244394

Reputation: 13448

Can I draw a straight line in Google Maps?

Is there an API I can use to draw a straight line between two points in a Google map, and to show the line in different colors?

Example: draw a straight line between NYC and Los Angeles with green or red line?

Upvotes: 2

Views: 35885

Answers (4)

vinod_vh
vinod_vh

Reputation: 1061

Using Polylines, you can draw a straight line.

You can see an example here

Upvotes: 1

prasang7
prasang7

Reputation: 571

This worked for me. With the method mentioned here I was able to draw polylines on Google Maps V2. You can easily change color and width of these polylines. I drew a new line whenever the user location got changed, so the the polyline looks like the path followed by user on map.

Source code at. Github Repository: prasang7/eTaxi-Meter

Please ignore other modules of this project related to distance calculation and User Interface if you are not interested in them.

Upvotes: 0

Kristian
Kristian

Reputation: 6613

Yes. Have you checked out the Google Maps APIs?

For example check out the source code for this example

Upvotes: 8

dotcomXY
dotcomXY

Reputation: 1596

Check this out, http://www.birdtheme.org/useful/v3tool.html. This application uses the Google Maps API Version 3 (V3). When you draw the line between two cities, this tool will auto generate kml or javascript code for you, and you can import it into your website and load the map

Upvotes: 2

Related Questions