简体   繁体   中英

changing color of google map api v2

How can I change the color of direction line in google map api I checked the gdriection,but there's nothing about color this is my code

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;

}

Thank you

See this similar answer on the Maps Google group: https://groups.google.com/forum/?fromgroups#!topic/google-maps-api/-1yGOmMwd7I

Seems you can't change the colour after instantiating the GPolyLine , so you need to build two GPolyLine s and add/remove them from the overlay to display a different colour.

Without knowing any better, a way of doing it would be:

  1. Don't pass the GDirections constructor a GMap , so it doesn't add any GPolyLine s
  2. Build an array of GLatLng vertices from GDirections.getVertex(index)
  3. Build your own GPolyLine s with different colours
  4. Overlay the GPolyLine on the map with GMap2.addOverlay(GOverlay)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM