javafxwebengine中的单张图

javafxwebengine中的单张图,java,javafx,onclick,leaflet,javafx-webengine,Java,Javafx,Onclick,Leaflet,Javafx Webengine,我在javafxwebengine中使用传单时遇到了一些问题。我想用geoJson格式可视化GPS轨迹。下面的代码清单显示了我迄今为止开发的HTML和JavaScript代码 单张地图! #地图{高度:100%} var map=L.map('map').setView([48.70,8.98],13); L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map)//这将是我们的底图。 功能onEac

我在javafxwebengine中使用传单时遇到了一些问题。我想用geoJson格式可视化GPS轨迹。下面的代码清单显示了我迄今为止开发的HTML和JavaScript代码


单张地图!
#地图{高度:100%}
var map=L.map('map').setView([48.70,8.98],13);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map)//这将是我们的底图。
功能onEachFeature(功能,图层){
if(feature.properties){
layer.bindPopup(“+feature.properties.phase+”从“+feature.properties.from+”到“+feature.properties.to”);
}
}
//map.tap.disable();
var streets=新L.geoJson(道路、{
onEachFeature:onEachFeature,
样式:函数(特性){return{color:feature.properties.color};}
}).addTo(地图);

可能您试图处理Browser类上的鼠标单击。 在我看来,JavaFx确实会阻止任何鼠标点击,所以你不能点击任何地方

我在你的浏览器类中添加了一些处理内容。也许它有用

public Browser() {
    //apply the styles
    getStyleClass().add("browser");
    // load the web page
    webEngine.load("file:///test2.html");
    webEngine.setJavaScriptEnabled(true);

    //webEngine.load("http://openstreetmap.de/karte.html");
    //add the web view to the scene
    getChildren().add(browser);

    //clickevent
            this.setOnMouseClicked(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent event){
                onActionProperty().get().handle(event);
            }

        });


    }

/**
 * MouseHandler
 */
private ObjectProperty<EventHandler<MouseEvent>> propertyOnAction = new SimpleObjectProperty<EventHandler<MouseEvent>>();

public final ObjectProperty<EventHandler<MouseEvent>> onActionProperty() {
    return propertyOnAction;
}

public final void setOnAction(EventHandler<MouseEvent> handler) {
    propertyOnAction.set(handler);
}

public final EventHandler<MouseEvent> getOnAction() {
    return propertyOnAction.get();

}    


private Node createSpacer() {
    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    return spacer;
}

@Override protected void layoutChildren() {
    double w = getWidth();
    double h = getHeight();
    layoutInArea(browser,0,0,w,h,0, HPos.CENTER, VPos.CENTER);
}

@Override protected double computePrefWidth(double height) {
    return 750;
}

@Override protected double computePrefHeight(double width) {
    return 500;
}
公共浏览器(){
//应用样式
getStyleClass().add(“浏览器”);
//加载网页
webEngine.load(“file:///test2.html");
setJavaScriptEnabled(true);
//webEngine.load(“http://openstreetmap.de/karte.html");
//将web视图添加到场景中
getChildren().add(浏览器);
//点击事件
this.setOnMouseClicked(neweventHandler()){
@凌驾
公共无效句柄(MouseeEvent事件){
onActionProperty().get().handle(事件);
}
});
}
/**
*鼠手
*/
private ObjectProperty propertyOnAction=新的SimpleObject属性();
公共最终对象属性onActionProperty(){
返回属性操作;
}
公共最终无效设置操作(EventHandler){
propertyOnAction.set(处理程序);
}
公共最终事件处理程序getOnAction(){
返回propertyOnAction.get();
}    
私有节点createSpacer(){
区域间隔=新区域();
HBox.setHgrow(间隔符,优先级,始终);
回位垫片;
}
@重写受保护的void layoutChildren(){
双w=getWidth();
双h=getHeight();
布局区域(浏览器,0,0,w,h,0,HPos.CENTER,VPos.CENTER);
}
@覆盖受保护的双computePrefWidth(双高){
返回750;
}
@覆盖受保护的双computePrefHeight(双宽度){
返回500;
}