首页 > 其他 > 详细

计算openlayers两点之间的距离

时间:2015-05-27 22:24:53      阅读:715      评论:0      收藏:0      [点我收藏+]
distanceTo: function(point) {

    var distance = 0.0;

    if ((this.x != null) && (this.y != null) &&

    (point != null) && (point.x != null) && (point.y != null)) {

        var dx2 = Math.pow(this.x - point.x, 2);

        var dy2 = Math.pow(this.y - point.y, 2);

        distance = Math.sqrt(dx2 + dy2);

    }

    return distance;

}

返回的单位为 km

计算openlayers两点之间的距离

原文:http://www.cnblogs.com/liuswi/p/4534479.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!