Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript draw directions when take data from json
    text
    copied!<p><em>This is a very basic question but please help becouse I try to solve this 3 days and I dont have any answer. I try many solutions but again is the same.</em></p> <p>Here I have a nArray functions which return me a bigArray JSON, which contain objects so like this: <strong><code>bigArray</code></strong></p> <pre><code> Array[5] 0: Object 1: Object DISTANCE_FROM_PREVIOUS_OBJECT_LOCATION: 2.087970147789207 lat: "48.866588" leftPosition: 183 lng: "2.309037999999987" topPosition: 57 __proto__: Object 2: Object 3: Object 4: Object length: 5 __proto__: Array[0] </code></pre> <p>So here I have "n" number of object. All objects contain lat and lng.</p> <p>I try to solve my problem with basic google example: <a href="http://jsfiddle.net/6Vz52/3/" rel="nofollow">http://jsfiddle.net/6Vz52/3/</a> but here i have a problem how to change <code>&lt;option value</code> in google example with my JSON(lat,lng) data from my code.</p> <p>I try this code:</p> <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt; &lt;script&gt; var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); var chicago = new google.maps.LatLng(41.850033, -87.6500523); var mapOptions = { zoom:7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: chicago } map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); directionsDisplay.setMap(map); } function calcRoute() { var start = document.getElementById('start').value; var end = document.getElementById('end').value; var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } google.maps.event.addDomListener(window, 'load', initialize); &lt;/script&gt; </code></pre> <p>but I don't know where and how to put my JSON (lat,lng) data and to draw multiple directions on map.</p> <p>How I can show directions in map with coordinates in my objects?</p> <p><strong>UPDATE: The google code not neccesary must be this (you can put some other google code example and integrate with my json), I just need a solution to draw direction based on my JSON array</strong></p>
 

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