黑色图像Google Streetview Javafx

时间:2018-07-14 05:35:25

标签: css javafx maps google-street-view

我正在编码一个javafx类以浏览Google Map。当我使用地图和地球时一切正常,但是当我打开街景视图时,javafx不会显示街道,只有黑屏和图形3d出了问题,并且所有内容消失并不断出现。我该怎么办才能解决这种情况的任何建议。仅在javafx浏览器上失败。当我在Chrome上打开html时,一切正常,并且我可以在街景视图上成功导航。

这是我的javafx代码类:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

import java    .net.URL;
import java.util.Vector;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
public class GoogleAppcreen extends Application {


   private Scene scene;
    private MyBrowser myBrowser;
//    private LocationClickHandler handler;
    private Vector<Button> buttons;
    //private Moderator moderator;



    /**
     * @param args the command line arguments
    */
   public static void main(String[] args) {

      launch(args);
   }

    @Override
      public void start(Stage primaryStage) {

  buttons = new Vector<Button>();
  //moderator = new Moderator();
//  handler=new LocationClickHandler();

  primaryStage.setTitle("java-buddy.blogspot.com extenden screen");

  myBrowser = new MyBrowser();
  //moderator.registerAddIconListener(myBrowser);
  VBox mainbox = new VBox();
  mainbox.getChildren().add(myBrowser);



 // mainbox.getChildren().add(generateEntitiesButtonBox());
//  mainbox.getChildren().add(generateSensorsButtonBox());
  scene = new Scene(mainbox, 1280, 760);

  primaryStage.setScene(scene);

  primaryStage.show();

 } 

    class MyBrowser extends Region {

  HBox toolbar;

  WebView webView = new WebView();
  WebEngine webEngine = webView.getEngine();


  public MyBrowser(){
      webView.setMinSize(1280, 400);
//      final URL urlGoogleMaps = getClass().getResource("../googlemaps2.html");
            final URL urlGoogleMaps = getClass().getResource("googlemaps2.html");

      webEngine.load(urlGoogleMaps.toExternalForm());

      getChildren().add(webView);
      /*webEngine.getLoadWorker().stateProperty().addListener(
              new ChangeListener<State>() {  
                @Override public void changed(ObservableValue<? extends State> ov, State oldState, State newState) {
                  if (newState == State.SUCCEEDED) {
                    JSObject win = (JSObject) webEngine.executeScript("window");
                    win.setMember("java", handler);
                  }
                }
              });*/


and this is my html file 

 <!DOCTYPE html>
    <html>
    <head>
    <title>Java-Buddy: Google Maps 55</title>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <style>#mapcanvas { height: 500px; width: 100%}</style>

    <script type="text/javascript">
    var map;
    var last_clicked;
    var elliptical=0;

    var sensors = new Array();
    var sensors_to_targets = new Array();
    var targets = new Array();
    var target_paths = new Array();
    var target_polys = new Array();

    var counter =0;
    //var marker;

    function loadmap(){

      var options = {
          zoom: 16,
          center: new google.maps.LatLng(51.507222, -0.1275),
          mapTypeId: google.maps.MapTypeId.terrain
      }
      map = new google.maps.Map(document.getElementById("mapcanvas"), options);
      google.maps.event.trigger(map,'resize');  
      google.maps.event.addListener(map, 'click', function(event) {

        java.saveLocation(event.latLng.lat(),event.latLng.lng());


       });



      }





    </script>

    </head>
    <body onload="loadmap()">
    <div id="mapcanvas"></div>
    </body>
    </html>

0 个答案:

没有答案