如何找到两地之间的位置? [英] How to find the location between two places?

查看:200
本文介绍了如何找到两地之间的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框在用户输入自己的源和目标,当用户按下提交按钮一个标记是在源吸收和另一种是在目标上绘制这样任何一个可以告诉我如何找到中间的位置?使用谷歌地图API版本3。

I have two text-boxes in which user enters his source and destination, when user presses submit button one marker is drawn at source and other one is drawn at destination so can any one tell me how to find the mid locations? Using google map api version3.

推荐答案

只是做数学一点点。基本上,您要查找的中点两点上线,下面这个公式:

Just do a little bit of math. You basically want to find the midpoint of two points on a line, following this formula:

x1 + x2
-------
   2

您会想这样做两次,一次为纬度和一次经度。然后,你可以放置一个标记在地图上。

You'll want to do this twice, once for latitude and once for longitude. Then you can place a marker on your map.

这篇关于如何找到两地之间的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆