Openlayer doesn't display a map

For my project I need to have a google map view on my page. For this I choose the add-on OpenLayer.
I extract the zip file and added then jar file to the lib folder
When I try it it doesn’t show a map. I also do not get any error and the widget is compiled correctly.

My code is from the project example.

When I run the project I only see a blank window.
Who know what I do wrong.

Chris

public void init() {
	Window mainWindow = new Window("Openlayer Application");
	
	final OpenLayersMap map = new OpenLayersMap();
         
            OpenStreetMapLayer osm = new OpenStreetMapLayer();
            GoogleStreetMapLayer googleStreets = new GoogleStreetMapLayer();
           map.addLayer(osm);
           map.addLayer(googleStreets);
           map.setCenter(22.30083, 60.452541);
           mainWindow.addComponent(map);
    	
	setMainWindow(mainWindow);
}

Hi,

Have you injected the google maps v3 scripts to your host page? Does the map render with just OSM layers?

cheers,
matti

No, I only used the jar file.

Would be nice if that is documented by the openlayer project.
But when I look at the google site I do not see the script that I can download.
If I am correct you don’t need to download just add the js file.
Is that correct?

Doe somebody have a working example that I can view.

Thanks

Hi,

Indeed, Google don’t let you download the script, but insists you to serve it from their site. This way they keep control of the map and can e.g. add advertisements, new features etc. if the decide so. This is one of the biggest reasons I prefer OSM for even free services even though googles map data is generally still better.

BING maps API is also quite nice. Maps data is at least as good as in Google maps, satellite images are sharper in most places, and with API key they let developers just use tile images so e.g. OpenLayers don’t require no specific helpers scripts to be added like with google maps.

Here is one example widget set that includes the google maps script:
http://code.google.com/p/vopenlayers/source/browse/exampleapp/src/main/java/org/vaadin/addons/vol/example/gwt/VolExampleWidgetSet.gwt.xml

The layers class javadocs should also state the same. Too bad I have not found the right time-motivation combo to build better manuals for this add-on. We should at least have some short tutorials on various features. GIS stuff especially in browser environment isn’t the most easiest stuff and there are lots of small gotchas that are hard to resolve for newcomers. If you have motivation to contribute on this area I’d be more than happy to give you rights to projects wiki pages. Let me know if you wish to help.

cheers,
matti