Sie sind nicht angemeldet.

1

Freitag, 15. Mai 2020, 08:51

Uncaught TypeError: Cannot read property 'index' of undefined in tour.js

I am sometimes getting this issue when on the loadscene command running from javascript. Sometimes it is work find and switch between panoramas but sometimes not. Do you guys have any ideas about why this could happen? Thank you in advance.


Quellcode

1
krpano_services.call("goto_pano('pano-scene-"+pano.id+"', 'hsp_"+$scope.local.hotspot.id+"');")


Quellcode

1
2
3
4
5
6
7
<action name="goto_pano">
showlog(true);
trace(%1);
trace(%2);
looktohotspot(%2, 45, smooth(500,500,500));
loadscene(%1, null, MERGE, BLEND(1));
</action>


Quellcode

1
2
3
INFO: krpano 1.20.6 (build 2020-04-15)
INFO: pano-scene-16105
INFO: hsp_25566

Zitat

VM3678:1 Uncaught TypeError: Cannot read property 'index' of undefined
at vb.removearrayitem.removeItem (eval at embedpano (tour.js:10), <anonymous>:1:49198)
at k (eval at embedpano (tour.js:10), <anonymous>:1:150007)
at v (eval at embedpano (tour.js:10), <anonymous>:1:153101)
at eval (eval at embedpano (tour.js:10), <anonymous>:1:149196)
at eval (eval at embedpano (tour.js:10), <anonymous>:1:74850)
at w (eval at embedpano (tour.js:10), <anonymous>:1:74572)
at G (eval at embedpano (tour.js:10), <anonymous>:1:74683)
at eval (eval at embedpano (tour.js:10), <anonymous>:1:74818)
at Object.b [as loadxml] (eval at embedpano (tour.js:10), <anonymous>:1:149125)
at Function.n.loadscene (eval at embedpano (tour.js:10), <anonymous>:1:102553)
removearrayitem.removeItem @ VM3678:1
Virtual tours 360° and panoramas hosting - https://trvi.tours. Up to 500MB per panorama

2

Sonntag, 17. Mai 2020, 07:17

This problem was solved. The "Uncaught TypeError: Cannot read property 'index' of undefined" issue was caused that I have had set the global variable index in my dragondown action. If the 'index' global variable was changed the loadscene(%1, null, MERGE, BLEND(1)); action was bringing me that issue.
Virtual tours 360° and panoramas hosting - https://trvi.tours. Up to 500MB per panorama

3

Montag, 14. März 2022, 06:20

In JavaScript almost everything is an object, null and undefined are exceptions. This error occurs when a property is read or a function is called on an undefined variable. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

If you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. To avoid getting these types of errors, you need to make sure that the variables you are trying to read do have the correct value. This can be done in various ways. You can do if checks before dealing with objects whose values are bound to change:

"
if (myVar !== undefined) {
...
}"


Or

"
if (typeof(myVar) !== 'undefined') {
...
}"