Search code examples
apibrowsergoogle-street-view

Strange Google StreetView Internet Explorer warning


I have a small problem with a SWT.Browser widget who throws a quite puzzling alert.

I tried to test the Google StreetView API in a browser so I made this page (actually I did not make anything, juste pasted it from Google's snippet.) and I get the following message : alt text

(Puzzling, ain't it ?)

My code is very simple (here it is)

public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell(display);
    shell.setText("Tentative API Google avec un SWT.Browser");
    shell.setLayout(new GridLayout());
    final Browser browser = new Browser(shell,SWT.BORDER);
    browser.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
    browser.setText("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"+
                    "<html xmlns=\"http://www.w3.org/1999/xhtml\" mlns:v=\"urn:schemas-microsoft-com:vml\">"+
                      "<head>"+
                        "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>"+
                        "<script src=\"http://maps.google.com/maps?file=api&v=2.x&key=AnyKey\" type=\"text/javascript\"></script>" +
                        "<title>"+
                          "Google Maps JavaScript API Example: Simple Streetview Example"+
                        "</title>" +
                        "<script type=\"text/javascript\">var myPano;function initialize(){var fenwayPark = new GLatLng(42.345573,-71.098326);panoramaOptions = { latlng:fenwayPark };myPano = new GStreetviewPanorama(document.getElementById(\"pano\"), panoramaOptions);GEvent.addListener(myPano, \"error\", handleNoFlash);}function handleNoFlash(errorCode){if(errorCode == FLASH_UNAVAILABLE){alert(\"Error: Flash doesn't appear to be supported by your browser\");return;}}</script>" +
                      "</head>" +
                      "<body onload=\"initialize()\" onunload=\"GUnload()\">" +
                        "<div name=\"pano\" id=\"pano\" style=\"width: 500px; height: 300px\">" +
                        "</div>" +
                      "</body>" +
                    "</html>");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

The problem might come (more or less) from the API because when I do not include it, I get no error. Anyway this very page works perfectly on any standard browser. Even more surprising is that I do not get any error if my second Script tag is not closed (well then nothing happens and if we go this way, when I have absolutly no code I have absolutly no error...)

Here I stand ... A bit confused about what to do ... (Any help is very welcome ...)


Solution

  • This probleme disappeared as it came when I displaced all my HTML code in a file that is called by

    browser.setUrl("http://my.url-string.html");

    So In fact I can't solve the problem but It does not bother me anymore...

    ps : the method to get my local page Url (that I have put in the same directory as my java file) is Class.getRessource("My File Path to which I can add its path in the classpath")