相关疑难解决方法(0)

Google Maps&JavaFX:单击JavaFX按钮后在地图上显示标记

当我点击我的JavaFX应用程序的Button时,我一直在尝试在地图上显示标记.所以当我点击该按钮时,我在JSON文件中写入该位置,该文​​件将被加载到包含该地图的html文件中.问题是当我在浏览器中打开html页面时,它工作得很好,但在JavaFX的Web视图中没有任何反应,我不知道为什么!

这是html文件:

<!DOCTYPE html>
<html>
  <head>
  <title>Simple Map</title>
  <meta name="viewport" content="initial-scale=1.0">
  <meta charset="utf-8">
  <style>
  /* Always set the map height explicitly to define the size of the div
   * element that contains the map. */
  /*#map {
    height: 100%;
  }*/
  #map{width:100%;height:100%;margin:auto;}
  /* Optional: Makes the sample page fill the window. */
  html, body {
    height: 100%;
    margin: 0;
    padding: 0;
  }
</style>
</head>
<body>
<div id="map"></div>
<script>
  var map;
  var marker;
  // Multiple Markers
  var markers = [];
  var pos …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps javafx javafx-webengine

359
推荐指数
3
解决办法
4万
查看次数

从java代码调用外部javascript函数

通过使用Java Scripting API,我可以在Java中执行JavaScript.但是,有人可以解释我需要添加到此代码中的内容,以便能够调用C中的函数:/Scripts/Jsfunctions.js

import javax.script.*;

public class InvokeScriptFunction {
public static void main(String[] args) throws Exception {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("JavaScript");

    // JavaScript code in a String
    String script1 = (String)"function hello(name) {print ('Hello, ' + name);}";
    String script2 = (String)"function getValue(a,b) { if (a===\"Number\") return 1; 
                     else return b;}";
    // evaluate script
    engine.eval(script1);
    engine.eval(script2);

    Invocable inv = (Invocable) engine;

    inv.invokeFunction("hello", "Scripting!!" );  //This one works.      
 }
}
Run Code Online (Sandbox Code Playgroud)

javascript java rhino function-call

37
推荐指数
1
解决办法
10万
查看次数