title: Show direction from the current location to desired location using google maps in asp.net
body: <p>Currently i'm trying to find code for getting directions from current location to a desired location in google map. Scenario: Onloading my aspx page the map should view my current location and when i click a desired location in the drop down box it should show direction from my current location. I'm just a beginner as a programmer and forgive me if my question is silly..</p>
  
  <p>the code for showing my current location is.....</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
      &lt;title&gt;Get User Current Location using Google Map Geolocation API Service in asp.net website&lt;/title&gt;
      &lt;style type="text/css"&gt;
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
      &lt;/style&gt;
      &lt;script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD1axwAuIx3vQ0oIJLxkUg9P1SF38AkT2A&amp;sensor=false"&gt;
      &lt;/script&gt;
      &lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"&gt;
      &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(success);
          } else {
              alert("Geo Location is not supported on your current browser!");
          }
          function success(position) {
              var lat = position.coords.latitude;
              var long = position.coords.longitude;
              var city = position.coords.locality;
              var myLatlng = new google.maps.LatLng(lat, long);
              var myOptions = {
                  center: myLatlng,
                  zoom: 12,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
              var marker = new google.maps.Marker({
                  position: myLatlng,
                  title: "lat: " + lat + " long: " + long
              });
  
              marker.setMap(map);
             // var infowindow = new google.maps.InfoWindow({ content: "&lt;b&gt;User Address&lt;/b&gt;&lt;br/&gt; Latitude:" + lat + "&lt;br /&gt; Longitude:" + long + "" });
              infowindow.open(map, marker);
          }
      &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body &gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div id="map_canvas" style="width: 500px; height: 400px"&gt;&lt;/div&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>