Java 9 JDK webview не показывает карту открытых слоев должным образом - PullRequest
1 голос
/ 15 апреля 2020

Поэтому я использовал java jdk 9.0.4 для своего проекта, чтобы я мог использовать библиотеку j phoenix в своем проекте javafx. Я создал веб-страницу с openlayers, чтобы я мог показать карту в своем приложении javafx с помощью веб-просмотра. Но веб-просмотр сокращает карту веб-страницы, и курсор открытых слоев смещается влево. Но то же самое f xml работает для JDK 1.8.0_241. Я не знаю, что является причиной проблемы. Кто-то, пожалуйста, помогите .....

Вот изображение веб-просмотра на JDK 9.0.4 9.0.4 JDK webview

И вот изображение webview на jdk 1.8.0_241 1.8.0_241 JDK webview

А вот html, построенный с открытыми слоями

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Draw Features</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.2.1/css/ol.css" type="text/css">
    <style>
        #map {
            height: 100%;
        }
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.2.1/build/ol.js"></script>
</head>
<body>
    <div id="map" class="map"></div>
    <script type="text/javascript">
        var lat=null;
        var lon=null;
        function getLat(){
            return lat;
        }
        function getLng(){
            return lng;
        }
        var raster = new ol.layer.Tile({
            source: new ol.source.OSM()
        });
        var source = new ol.source.Vector({wrapX: false});
        var vector = new ol.layer.Vector({
            source: source,
            style: new ol.style.Style({

                image: new ol.style.Circle({
                    radius: 8,
                    fill: new ol.style.Fill({
                        color: 'red'
                    })
                })
            })
        });
        var map = new ol.Map({
            layers: [raster, vector],
            target: 'map',
            view: new ol.View({
                center: ol.proj.fromLonLat([90.4125,23.8103]),
                zoom: 15
            })
        });
        var modify = new ol.interaction.Modify({source: source});
        map.addInteraction(modify);
        var draw = new ol.interaction.Draw({
                source: source,
                type: "Point"
        });
        map.addInteraction(draw);
        map.on('contextmenu', function(evt){
            remove();

            var coords = ol.proj.toLonLat(evt.coordinate);
            lat = coords[1];
            lon = coords[0];
            var locTxt = "Latitude: " + lat + " Longitude: " + lon;
        });
        function remove(){
            var features = source.getFeatures();
            var lastFeature = features[features.length-1];
            source.clear();
            console.log(lastFeature);
            source.addFeature(lastFeature);
        }
        map.on('click', function(evt){
            remove();
            var coords = ol.proj.toLonLat(evt.coordinate);
            lat = coords[1];
            lon = coords[0];
        });
</script>
</body>
</html>

А вот java код контроллера

package sample;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.web.WebView;

/**
 * FXML Controller class
 *
 * @author MeawMeawPotatoChips
 */
public class PostController implements Initializable {
    @FXML
    private WebView postWebView;

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        postWebView.getEngine().setJavaScriptEnabled(true);
        postWebView.getEngine().load("http://localhost/map/setaddress.php?key=cse299&lng=90.4125&lat=23.8103");
    }    

}

И, наконец, код F XML

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.web.WebView?>

<AnchorPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="637.0" prefWidth="825.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.241" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.PostController">
   <children>
      <WebView fx:id="postWebView" layoutX="37.0" layoutY="128.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="900.0" AnchorPane.bottomAnchor="60.0" AnchorPane.leftAnchor="33.0" AnchorPane.rightAnchor="22.0" AnchorPane.topAnchor="185.0" />
   </children>
   <effect>
      <DropShadow />
   </effect>
</AnchorPane>
...