Curved Lines on Google Maps
It seems to me that soon Google will give us the opportunity to draw not only a broken line on our maps, but also a curve. And I faced the need to draw a curved line now, in the process of working with one project. And I had to turn around.
I usually really like reading posts on the Habr kind of “See what I did” (especially when it's not a startup). Therefore - look what I did - I implemented a dirty hack that will help draw the curves.
First - a picture (not clickable):

1) Tell me what is wrong. In the comments, in the mail or in any other convenient way.
2) Clone the branch on github, make changes and let me know if you want them to merge into my branch.
And he knows how to
No, and yet he does not know how to replace gnuplot and other programs that draw graphs for you. Therefore, anyone who wants to draw, for example, the tangent on the gap [-10; 10], I want to say right away - it will turn out badly, because the control points are distributed evenly. Because I won’t know why to draw graphs of unlimited functions on maps :-)
Although the tangent is on the segment [-1; 1] looks very personal - because it is limited and continuous.

I usually really like reading posts on the Habr kind of “See what I did” (especially when it's not a startup). Therefore - look what I did - I implemented a dirty hack that will help draw the curves.
First - a picture (not clickable):

Before reading a lot of letters, I want to try!
I would also like to. Go to this address . There will be a map. Click it once, then click elsewhere, some distance from the first click. Look at the result. You can click on.What for?
I usually want to draw a curved line when I draw a pedestrian path on a map. After all, people do not walk through houses, do not levitate over small rivers and generally love the sidewalk. Therefore, I always wanted to depict their curve path.How to set curves?
Forcing people to learn the theory from Bezier curves is not very cool. Therefore, I decided that it was enough to define curves with functions of one variable. I personally love sine and cosine most of all. They colorfully depict the path of a drunken pedestrian.How will they be displayed?
Function graphs will be approximated by polynomial graphs. In Russian: several points on the chart will be selected and connected by segments. The quality of the resulting graph and the speed of work depend on the number of points.How does it look in code?
my_poly = ApproxPolyline(gmap, lls, f, range, points);
map_instance.addOverlay(my_poly.get_polyline());gmap- an object of a class GMap2(it is needed because it has a method of converting geographical coordinates to Cartesian coordinates), lls- an array of two points that must be connected by a graph (objects of a class GLatLng), f- a function of one variable that you want to depict, range- an array of two numbers ( displayed gap), points- the number of points that will be connected by segments.Where can I download?
References
I posted this on GitHub: the repository page and archive links with the latest revision script: zip and tar .The size
The script source at the time of publication weighs 3400 bytes, after compression YUICompressor - 2026 bytes.License
The code is licensed under MIT.How to help?
There are two ways:1) Tell me what is wrong. In the comments, in the mail or in any other convenient way.
2) Clone the branch on github, make changes and let me know if you want them to merge into my branch.
And he knows how to "rob the cows" ?
No, and yet he does not know how to replace gnuplot and other programs that draw graphs for you. Therefore, anyone who wants to draw, for example, the tangent on the gap [-10; 10], I want to say right away - it will turn out badly, because the control points are distributed evenly. Because I won’t know why to draw graphs of unlimited functions on maps :-) Although the tangent is on the segment [-1; 1] looks very personal - because it is limited and continuous.
[: ||||:]
Oh yes, maybe someone already did it, but I don’t know. I wanted to shake antiquity and recall a bit of mathematics. If this is really not relevant, let me know and I will hide the topic (only teach me how first).