Note that there are some explanatory texts on larger screens.

plurals
  1. POName database child in Firebase?
    text
    copied!<p><img src="https://i.stack.imgur.com/ApKd5.png" alt="enter image description here"></p> <p>This is the code I have.</p> <pre><code>function saveTrip() { routeData.clear(); for (var i = 0; i &lt; dirDisplay.directions.routes[0].legs.length; i++) { for (var j = 0; j &lt; dirDisplay.directions.routes[0].legs[i].steps.length; j++) { routeData.push(dirDisplay.directions.routes[0].legs[i].steps[j].path); } } routeLinesRef.push(routeData, function(error){ if (error) { $('#savedSpan').html('Data could not be saved.' + error); } else { $('#savedSpan').html('Data saved successfully!'); } }); } Array.prototype.clear = function() { this.splice(0, this.length); }; routeLinesRef.limit(10).on('child_added', function(snapshot) { // loop over each route we get from firebase route = snapshot.val(); </code></pre> <p>What function should be written to write into the hierarchy as shown in the image?</p> <pre><code>id = snapshot.name(); // make an array that is initially blank // It will contain all the latitude and longitudes of each point on in the route var routeCoordinates = []; // This loops over each point on the route for (var i=0; i&lt;route.length; i++) { for (var j in route[i]) { if (j==0 &amp;&amp; i&gt;0) { continue } else { </code></pre> <p>This part just takes each point on the route, and converts it into a google maps LatLng object. For example, if the data is [58.23, 18.8], it will do: new google.maps.LatLng(58.23, 18.8) to it, which turns it into a format that google maps likes.</p> <pre><code>if (route[i][j].lb &amp;&amp; route[i][j].mb) { routeCoordinates.push(new google.maps.LatLng (route[i][j].lb, route[i][j].mb)); //console.log(j + ' ' + snapshot.val()[route][i][j].lb, snapshot.val()[route][i][j].mb); } } } } </code></pre> <p>What should I do? I can't find any tutorial or anything.</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