在使用jQuery的Google地图上的两点之间画一条线? [英] Draw a line between two point on a Google map using jQuery?

查看:193
本文介绍了在使用jQuery的Google地图上的两点之间画一条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery或Javascript在谷歌地图API中绘制两点之间的线(经度和纬度)?我需要两点之间的最短路径。它可以是任何类型的行。

解决方案

仅限API v2!



以下代码段在两点之间创建一个10像素宽的红色多段线:

  var polyline = new GPolyline([
new GLatLng(37.4419,-122.1419),
new GLatLng(37.4519,-122.1519)],
#ff0000,10);
map.addOverlay(polyline);

您可以找到 here

How to draw a line between two points (Latitude and Longitude) with the Google map API using jQuery or Javascript? I need the shortest path between the two points. It may be any type of line.

解决方案

For API v2 only!

The following code snippet creates a 10-pixel-wide red polyline between two points:

var polyline = new GPolyline([
  new GLatLng(37.4419, -122.1419),
  new GLatLng(37.4519, -122.1519)],
  "#ff0000", 10);
map.addOverlay(polyline);

You can find the documentation here.

这篇关于在使用jQuery的Google地图上的两点之间画一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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