更改谷歌地图 API v2 的颜色

changing color of google map api v2

本文关键字:颜色 v2 API 谷歌地图      更新时间:2023-09-26

如何在谷歌地图 API 中更改方向线的颜色 我检查了gdriection,但没有任何关于颜色的内容,这是我的代码

function direction() 
{
    var txtAddress = document.getElementById("<%=txtAddress.ClientID %>");
    var address = txtAddress.value;
    var TextBox1 = document.getElementById("<%=TextBox1.ClientID %>");
    var address1 = TextBox1.value;
    directions = new GDirections(map, directionsPanel);
    directions.load("from: " + address1 + " to: " + address + "");
  //  var address =txtAddress.value + "  " + TextBox3.value;
}

谢谢

在地图谷歌组看到这个类似的答案:https://groups.google.com/forum/?fromgroups#!topic/google-maps-api/-1yGOmMwd7I

似乎在实例化GPolyLine后您无法更改颜色,因此您需要构建两个GPolyLine并从叠加层中添加/删除它们以显示不同的颜色。

不知道更好,一种方法是:

  1. 不要GMap传递GDirections构造函数,因此它不会添加任何GPolyLine S
  2. 从 构建GLatLng顶点数组 GDirections.getVertex(index)
  3. 构建您自己的GPolyLine不同的颜色
  4. 在地图上叠加
  5. GPolyLine GMap2.addOverlay(GOverlay)