Hello,
I'm trying to embed the pano viewer into an existing project which is based on the parcel bundler. When i just load an additional script via the index.html, the embedpano function can not be found (Uncaught ReferenceError: embedpano is not defined).
Does anyone know how to manage this? Any help is greatly appreciated!
Sebastian
Integration into parcel bundler
-
-
You need to call the embedpano function after the krpano script is loaded.
As it's done in the krpano default html synchronously or use load event if you load script dynamically. -
Thanks for your reply. The problem with this method is that the krpano is then loaded in separately, so in the other scripts of my site I can not access the krpano object and its functions. I want to interactively switch on/off panoramas using different buttons than the ones offered in the viewer, for example.
-
-
This does not work. The javascript is not loaded correctly. Here is an example:
index.html:
HTML
Display More<html><body> <divid="app"></div> <scriptsrc="src/krpano.js"></script> <script> embedpano({ xml:"tour.xml", target:"pano", html5:"only", mobilescale:1.0, passQueryParameters:"startscene,startlookat" }); </script> <divid="krpano" style="width: 100%; height: 100%;"></div> <scriptsrc="src/index.js"></script> </body>
index.js:Code
Display Moreimport"./styles.css"; document.getElementById("app").innerHTML=` <h1>Test krpano</h1> <div> We should be able to access the krpano object. Also, we should get an error as the tour.xml is not present (nor are any other needed files). </div> `; constkrpano=document.getElementById('krpano').get('global');
package.json:Code
Display More{ "name": "vanilla", "version": "1.0.0", "description": "JavaScript example starter project", "main": "index.html", "scripts": { "start": "parcel index.html --open", "build": "parcel build index.html" }, "dependencies": { "parcel-bundler": "^1.6.1" }, "devDependencies": { "@babel/core": "7.2.0", "typescript": "4.4.4" }, "resolutions": { "@babel/preset-env": "7.13.8" }, "keywords": ["javascript", "starter"] }
Error message:Quotedocument.getElementById(...).get is not a function
Live Sandbox: https://codesandbox.io/s/angry-varaha…kage.json:0-455 -
It seems this error is specific to Codesandbox or Parcel.
For example this works fine locally, but have an error in Codesandbox https://codesandbox.io/s/admiring-daw…ile=/index.html -
When you use static template without bundler it works https://codesandbox.io/s/gallant-pate…ile=/index.html
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!