开发者

Can I draw a straight line in Google Maps?

开发者 https://www.devze.com 2023-03-22 00:28 出处:网络
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?

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 w开发者_StackOverflow社区ith green or red line?


Yes. Have you checked out the Google Maps APIs?

For example check out the source code for this example


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


Using Polylines, you can draw a straight line.

You can see an example here


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消