Anonymous user  |  Log in  |  Create Account

Advanced GDirections

If we do not want to autogenerate GDirection, and we prefer to design a more personal interface, set "autoGenerate" to false.

GMaps still does most of the work. All we have to do is set the boxes for start and end points, the submit button, and "div" where the directions will go.

In addition, define "locale" to indicate Language-Culture in which we want to work.

Define the following properties for correct operation:

  • buttonElementId: The button ID. Input must be "< type=button/>" NOT "< asp:Button/>". 
  • fromElementId: The Textbox that corresponds to the starting point.
  • toElementId: The Textbox that corresponds to the ending point.
  • divElementId: The div ID where the directions will go.
  • locale: string that defines the culture. For example "Es-ES", "in-GB", "fr-CA", etc.
  • travelMode: The mode of travel, such as driving (default) or walking.
  • avoidHighways: If true directions will attempt to exclude highways when computing directions. Note that directions may still include highways if there are no available alternatives.
  • preserveViewport: By default, when a Directions object has a map, the map is centered and zoomed to the bounding box of the the directions result. When this option is set to true, the viewport is left as is (unless it was never set in the first place).
Start Location: End Location:
Start Location: <asp:TextBox ID="tb_fromPoint" runat="server" meta:resourcekey="tb_fromPointResource1"></asp:TextBox>
End Location: <asp:TextBox ID="tb_endPoint" runat="server" meta:resourcekey="tb_endPointResource1"></asp:TextBox>
<input type="button" id="bt_Go" value="Let's go!" />
<cc1:GMap ID="GMap1" runat="server" />
<div id="div_directions"></div>
GDirection direction = new GDirection();
direction.autoGenerate = false;
direction.buttonElementId = "bt_Go";
direction.fromElementId = tb_fromPoint.ClientID;
direction.toElementId = tb_endPoint.ClientID;
direction.divElementId = "div_directions";
direction.clearMap = true;

//direction.avoidHighways = true;
//direction.travelMode = GDirection.GTravelModeEnum.G_TRAVEL_MODE_WALKING;
//direction.locale = "en";

Powered by Subgurim.NET