title: Cannot read property
body: <p>This is my script:</p>
  
  <pre><code>            if(entfernung2&lt;=1 &amp;&amp; drive=="AUT"){
                  dauer = new google.maps.DistanceMatrixService();
                  dauer.getDistanceMatrix({
                  origins: ["48.142362,11.549859"],
                  destinations: ["48.2,11.4"],
                  travelMode: google.maps.TravelMode.WALKING,
                  unitSystem: google.maps.UnitSystem.METRIC,
                  })
              dauer1=dauer.rows.elements.duration.text;
              };
  </code></pre>
  
  <p>if i log dauer1 following errors are shown:</p>
  
  <p>Uncaught TypeError: Cannot read property 'elements' of undefined 
  Uncaught TypeError: Cannot read property 'apply' of undefined </p>
  
  <p>Whats wrong? :/</p>
  
  <p>EDIT:</p>
  
  <pre><code>            if(entfernung2&lt;=1 &amp;&amp; drive=="AUT"){
                  dauer = new google.maps.DistanceMatrixService();
              dauer.getDistanceMatrix(
              {
                origins: ["48.142362,11.549859"],
                destinations: ['"'+data.position.latitude+','+data.position.longitude+'"'],
                travelMode: google.maps.TravelMode.WALKING,
                unitSystem: google.maps.UnitSystem.METRIC
              }, setDauer1);
  
              function setDauer1(response, status) {
                dauer1 = response.rows[0].elements[0].duration.value;
                console.log(dauer1);
              }};
  </code></pre>