Draw a line between two point on a Google map using jQuery?

后端 未结 3 518
别跟我提以往
别跟我提以往 2020-12-28 17:47

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

3条回答
  •  無奈伤痛
    2020-12-28 18:13

    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.

提交回复
热议问题