Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QWebengineview ( Qt/C++) Uncaught ReferenceError: parseGeoraster is not defined #93

Open
chenwenjingdev opened this issue Oct 7, 2024 · 0 comments

Comments

@chenwenjingdev
Copy link

Describe the bug

when i created a application using georaster and QWebengineview ( Qt/C++, buildt on Qt5.10 msvc2017/Qt5.15 msvc2019 ),i encounter some annoying problems: js: Uncaught ReferenceError: parseGeoraster is not defined,but it successed to run in vscode, for example: http://127.0.0.1:3000/index.html.

main.cpp

#include <QApplication>
#include <QWebEngineView>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWebEngineView *view = new QWebEngineView();
    view->load(QUrl("qrc:/web/index.html"));
    view->show();

    return a.exec();
}

index.html

<!DOCTYPE html>
<html>

<head>
  <script src="./georaster/georaster.browser.bundle.min.js"></script>
  <script src="./jquery/jquery-3.7.1.min.js"></script>
</head>

<body>
  <div id="container">***</div>
  <script>
    window.onload = () => {

      // success
      $.getJSON('./json/demo.json', function (data) {
        document.getElementById('container').textContent = JSON.stringify(data);
      });

      // error
      $.ajax({
        url: "./tif/area.tif",
        type: 'GET',
        xhr: function () {
          var xhr = new window.XMLHttpRequest();
          xhr.responseType = 'blob';
          return xhr;
        },
        success: function (data) {
          let reader = new FileReader()
          reader.readAsArrayBuffer(data)

          reader.onload = function () {
            let arrayBuffer = reader.result;

            parseGeoraster(arrayBuffer).then(georaster => {
              const min = georaster.mins[0];
              const max = georaster.maxs[0];
              const range = georaster.ranges[0];

              document.getElementById('container').textContent = min.toString() + " " + max.toString() + " " + range.toString();
            });
          }
        }
      });

    }
  </script>
</body>

</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant