Skip to content

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

Description

@chenwenjingdev

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions