开发者

Missing methods in Google Maps API v3. How can I emulate latRadians() and lngRadians()?

开发者 https://www.devze.com 2023-04-13 04:06 出处:网络
I need to calculate the latitude and longitude radians for 2 lat,lng points in a google maps by using api v3.

I need to calculate the latitude and longitude radians for 2 lat,lng points in a google maps by using api v3.

In api v2 they had th开发者_如何学Goese methods available: latRadians() and lngRadians()

How can I emulate that same functionality in api v3?

Long story short: I need to calculate the angle of a polyline in Google Maps API 3.


You can just extend for example google.maps.LatLng object to have your methods:

google.maps.LatLng.prototype.latRadians = function()
{
  return (Math.PI * this.lat()) / 180;
}

google.maps.LatLng.prototype.lngRadians = function()
{
  return (Math.PI * this.lng()) / 180;
}


Conversion between radians and degrees is a well-known mathematical function:

  • radians = (π × degrees) / 180
0

精彩评论

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