Google Maps API:获取两个位置的距离并在地图上绘图 [英] Google Maps API: get two locations distance and plot on map

查看:18
本文介绍了Google Maps API:获取两个位置的距离并在地图上绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Google 地图的新手.我想获得从一个地方到另一个地方的距离并将其绘制在地图上.

I am new at Google Maps. I want to the get distance from one place to another place and plot it on a map.

例如:Place1 和 Place2距离 - xxx 公里(xx 英里)并将其绘制在地图上.

e.g: Place1 and Place2 Distance - xxx Km (xx miles) and plot it on map.

看看.

推荐答案

使用 几何库 computeDistanceBetween() 函数.如果您没有坐标,请使用 Geocoder 获取它们.

Use the geometry library computeDistanceBetween() function. If you don't have the coordinates, use the Geocoder to get them.

示例(基于 文档中的示例)

这篇关于Google Maps API:获取两个位置的距离并在地图上绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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