Java FX application onload event

∥☆過路亽.° 提交于 2019-12-06 13:22:28

Consider adding FirebugLite to debug your app:

<script src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>

If I understand correctly the question, you need to run this inside the 'document loaded' event listener:

webComponent.getEngine().load(getClass().getResource("googlemap.html").toString());

webComponent.getEngine().stateProperty().addListener(new ChangeListener<Worker.State>() {
    @Override
    public void changed(ObservableValue<? extends Worker.State> ov, Worker.State t, Worker.State t1) {
        if (t1 == Worker.State.SUCCEEDED) {
            // this will be run as soon as WebView is initialized.
            webComponent.getEngine().executeScript("document.goToLocation(\"" + urlField.getText() + "\")");               
        }
    }
});

UPDATE

The message means there is no such function, so you need to copy JS from your original HTML file into googlemap.html:

document.goToLocation = function goToLocation(searchString) {
    document.geocoder.geocode( {'address': searchString}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        document.map.setCenter(results[0].geometry.location);
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
}

UPDATE 2

Worked for me after this (need to do this for all functions):


document.goToLocation = function  goToLocation(searchString) {

You might consider adding FirebugLite to debug your JS app:

<script src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!