The Google layer allows you to use Google maps imagery as a raster layer in Geomajas. There are three possible types of images which can be displayed,
Make sure your include the plug-in in your project. If you are using Maven, add the following dependency to your pom:
<dependency>
<groupId>org.geomajas.plugin</groupId>
<artifactId>geomajas-layer-google</artifactId>
<version>${geomajas-layer-google-version}</version>
</dependency>
Example 2.1. Google layer dependency
A complete Google layer configuration looks as follows:
<bean name="googleInfo" class="org.geomajas.configuration.RasterLayerInfo">
<property name="crs" value="EPSG:900913"/>
<property name="maxExtent">
<bean class="org.geomajas.geometry.Bbox">
<!--
see http://cfis.savagexi.com/2006/05/03/google-maps-deconstructed
-20037508.342789, -20037508.342789 to 20037508.342789, 20037508.342789
-->
<property name="x" value="-20026376.393709917"/>
<property name="y" value="-20026376.393709917"/>
<property name="width" value="40052752.787419834"/>
<property name="height" value="40052752.787419834"/>
</bean>
</property>
<property name="tileWidth" value="256"/>
<property name="tileHeight" value="256"/>
</bean>
<bean name="google" class="org.geomajas.layer.google.GoogleLayer" >
<property name="layerInfo" ref="googleInfo" />
<property name="satellite" value="false" />
<property name="maxZoomLevel" value="21" />
</bean>
Example 2.2. Google layer configuration
| GoogleLayer configuration | |
|---|---|
| satellite | Set to true to use satellite view from Google. When this and physical are false (the default), the normal view (showing streets) will be used. Setting to true will reset physical to false. |
| physical | Set to true to use physical view from Google. When this and satellite are false, the normal view (showing streets) will be used. Setting to true will reset satellite to false. |
| maxZoomLevel | Set to a number for which maps are available in the region of interest, defaults to 19. The first zoom level has one tile for the entire world, the second has four tiles etc. |
Table 2.1. GoogleLayer configuration
The layer info inner bean has the same general content as usual. There are some simplifications though. There is no need to provide resolutions or tile size (256x256 is always used). The crs should always be set to Mercator ("EPSG:900913").
On the layer, you can set the "satellite" or "physical" property to choose between using normal display (showing streets), satellite view (by setting this to "true"), or physical view (the modes are exclusive, last set will be valid). You can also set the maximum tile level on the layer, this defaults to 19 which is supported by Google in most places.
You can also set the display type using the dataSourceName parameter of layerInfo, for example for physical use G_PHYSICAL_MAP@GoogleLayer.
You need to assure that you comply with Google's terms of use (see
http://code.google.com/apis/maps/).
Some of the things you need to do include adding the Google API code in
your application (using a Google API key when not running on localhost),
and (from the GWT face, using the GoogleAddon class to
assure the copyright notes are displayed on the map.