Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add google Directions in google maps
    primarykey
    data
    text
    <p>The current code retrieves all info, displays all markers on a map and if a marker is clicked, infowindow renders showing its content. What i want to do is that i want to implement directions in this. How can i add directions in my code so that it will also add directions? This is what i want to implement:</p> <p><strong>what to implement :</strong></p> <pre><code>var request = { origin: start,//it will be my first row(lat and lon) destination: end,//it will be my lastrow(lat and lon) waypoints: waypts, // it will be all lat and lon between first and last optimizeWaypoints: true, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function(response, status){ if (status == google.maps.DirectionsStatus.OK){ directionsDisplay.setDirections(response); } }); </code></pre> <p>My current code in which i want to implement the above functionality mean google maps directions:</p> <p><strong>already implemented :</strong></p> <pre><code>$("#directions").click(function(){ var lat_from_ip = $("#hidden_lat").val(); var lon_from_ip = $("#hidden_lon").val(); var latlng = new google.maps.LatLng(lat_from_ip, lon_from_ip); var options = {zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP}; var map = new google.maps.Map(document.getElementById('map'), options); $.ajax({type: "GET", dataType: 'json', url: url +'//abc/my_page.php', success: function(response){ var total=response.length; var data_array,name,type,address,lat,lon,infowindow; var infowindow = new google.maps.InfoWindow(); for(var i=0; i &lt; total; i++) { data_array=response[i]; name=data_array['name']; address=data_array['address']; notes=data_array['notes']; lat=data_array['lat']; lon=data_array['lon']; var propPos = new google.maps.LatLng(lat,lon); propMarker = new google.maps.Marker({ position: propPos, map: map, icon: icon, zIndex: 3}); var contentString = "&lt;div&gt;"+name+"&lt;br/&gt;&lt;label class='label'&gt;Location :&lt;/label&gt; "+address+"&lt;br/&gt;&lt;label class='label'&gt;Notes :&lt;/label&gt; "+notes + "&lt;/div&gt;"; function bindInfoWindow(marker, map, infowindow, html) { google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(html); infowindow.open(map, marker); }); } bindInfoWindow(propMarker, map, infowindow, contentString); } //end of for loop } //end of for success }); //end of for $.ajax return; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload