Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过JXBrowser将Java ArrayList变量索引传递给JavaScript_Javascript_Java_Google Maps_Jxbrowser - Fatal编程技术网

通过JXBrowser将Java ArrayList变量索引传递给JavaScript

通过JXBrowser将Java ArrayList变量索引传递给JavaScript,javascript,java,google-maps,jxbrowser,Javascript,Java,Google Maps,Jxbrowser,我有两个班在我的项目。一个是名为Test的主类,它包含代码的所有函数。 它还定义了多个数组列表,我想使用其中的两个,并使用JXBrowser库将它们的值放入JavaScript中。 请看一下我添加评论的地方。 基本上,我试图在Java类中使用JXBrowser库使用JavaScript的GoogleMaps,并通过从主类获取经度和纬度并将它们添加到JavaScript代码中来添加多个标记 final Browser browser = new Browser(); BrowserView

我有两个班在我的项目。一个是名为Test的主类,它包含代码的所有函数。 它还定义了多个数组列表,我想使用其中的两个,并使用JXBrowser库将它们的值放入JavaScript中。 请看一下我添加评论的地方。 基本上,我试图在Java类中使用JXBrowser库使用JavaScript的GoogleMaps,并通过从主类获取经度和纬度并将它们添加到JavaScript代码中来添加多个标记

final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);


    JFrame frame = new JFrame("Map");
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(900, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);


    browser.loadHTML("<html>\n"
            + "    <head>\n"
            + "   <meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\"/>\n"
            + "   <style type=\"text/css\">\n"
            + "       html { height: 100% }\n"
            + "       body { height: 100%; margin: 0; padding: 0 }\n"
            + "       #map-canvas { height: 100% }\n"
            + "   </style>\n"
            + "   <script type=\"text/javascript\"\n"
            + "           src=\"https://maps.googleapis.com/maps/api/js?key=AIzaSyC-6h0sjJTfO2Kf5JxJYKdD-DwHwPHKVZI&sensor=false\"></script>\n"
            + "   <script type=\"text/javascript\">\n"
            + "     var map;\n"
            + "     function initialize() {\n"
            + "       var mapOptions = {\n"
            + "         center: new google.maps.LatLng(48.209331, 16.381302),\n"
            + "         zoom: 4\n"
            + "       };\n"
            + "      var marker, i;\n"
//This is where the problem is and what i'm trying to do.
            + "      for (i = 0; i < Test.keywordIndex.getsize() ; i++) {\n" 
            + "         marker = new google.maps.Marker({\n"
            + "         position: new  google.maps.LatLng(Test.latitude.get(Test.keywordIndex.get(i), Test.longitude.get(Test.keywordIndex.get(i),\n"
            + "         map: map\n"
            + "       });\n"
            + "     var marker = new google.maps.Marker({\n"
            + "    position:  new google.maps.LatLng(48.209331, 16.381302),\n"
            + "    map: map,\n"
            + "    title: 'Hello World!'\n"
            + "});"
            + "     }\n"
            + "     google.maps.event.addDomListener(window, 'load', initialize);\n"
            + "\n"
            + "   </script>\n"
            + "</head>\n"
            + "<body>\n"
            + "<div id=\"map-canvas\"></div>");
最终浏览器=新浏览器();
BrowserView BrowserView=新建BrowserView(浏览器);
JFrame=新JFrame(“地图”);
frame.add(browserView、BorderLayout.CENTER);
框架。设置尺寸(900500);
frame.setLocationRelativeTo(空);
frame.setVisible(true);
browser.loadHTML(“\n”
+“\n”
+“\n”
+“\n”
+“html{height:100%}\n”
+“正文{高度:100%;边距:0;填充:0}\n”
+“#地图画布{高度:100%}\n”
+“\n”
+“\n”
+“\n”
+“变量映射;\n”
+“函数初始化(){\n”
+“var mapOptions={\n”
+“中心:新建google.maps.LatLng(48.209331,16.381302),\n”
+“缩放:4\n”
+“};\n”
+变量标记,i;\n
//这就是问题所在,也是我要做的。
+“对于(i=0;i

我有这个想法,但不确定代码本身的执行情况

JxBrowser将在2015年10月至11月发布的6.0版本中支持ArrayList。

您应该先运行它,看看是否得到了预期的结果。如果我没有运行它,也没有得到它,我不会问这个问题results@Validimir简单的呢基于某个对象的数组?我无法使arrays.isArray(passedToJs)工作。passedToJs.splice!==未定义…如何传递java数组以使其成为有效的javascript数组?