OpenLayers addon not working in an iframe

Hello,

We currently have a vaadin application that uses the google map add-on. Everything is working ok, but we want to move to the OpenLayers add-on to be able to use the google maps api v3.

The application can be embedded in other websites using an iframe. The problem is now that the OpenLayers add-on refuses to work inside a iframe. This can be reproduced very easily by creating a very simple OpenLayers application with the google maps layers :

public class MapApplication extends Application {
	@Override
	public void init() {
		
		Window mainWindow = new Window("Map Application");
		
		setMainWindow(mainWindow);

		final OpenLayersMap map = new OpenLayersMap();
        GoogleStreetMapLayer googleStreets = new GoogleStreetMapLayer();
        map.addLayer(googleStreets);
        map.setCenter(22.30083, 60.452541);
        map.setWidth("300px");
        map.setHeight("300px");
        mainWindow.addComponent(map);	
	}

}

Now, when using this application on itself in a browser window, everything works fine.

But, when trying to show the application inside an iframe, no map is shown :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<iframe src="http://localhost:8080/Map" height="500" width="500"></iframe>
</body>
</html>

Any ideas what could be causing this?

Thanks in advance.

Hi,

Probably the OpenLayers add-on or some part to the open layers library itself presumes it is always running on top level window.

Would you fill an issue report to the projects google code page? I could then look at the issue next time I open the project. If you are in hurry, I’d suggest to
go for Pro
and place an order for a quick fix.

cheers,
matti