Vaadin and Google Maps


Vaadin and a Google Map Widget


One of my major irritations with Vaadin has been its lack of support for Google Maps as a standard widget.

The reality is that many commercial applications require some form of mapping feature and the lack of support for a standard Google Map widget has been a major problem.

However this has changed with Version 7.x of Vaadin, a new Google Map Addon has appeared and it fills a very important gap in the Vaadin feature set.

How to Use It.

If you use Maven in your development process then using the Addon in your Vaadin project is very easy. Just place this dependency in your POM file and make sure you have the correct repository established for the Vaadin Add On's.

<dependency>
   <groupId>com.vaadin.tapio</groupId>
   <artifactId>googlemaps</artifactId>
   <version>0.6.2</version>
</dependency>


Here is some simple code to get you started. It creates a Google Map which is centred on my home city of Brisbane, Australia.

googleMap = new GoogleMap(new LatLon(-27.47101, 153.02429), 10.0, apiKey);
googleMap.setSizeFull();
googleMap.setImmediate(true);
googleMap.setMinZoom(4.0);


The 10.0 value is the starting zoom position for the map and the apiKey is a String which contains your Google Maps API key that you can obtain from Google. If you are using localhost then this key can be an empty string ( "" ).

Look at the Demo

The best place to obtain a deeper understanding of the Add On is via the Demo source code which can be seen on the GIT Hub source code site.

This is a great extension to the base Vaadin framework, I just wish it was a standard widget.





Comments

Popular posts from this blog

Vaadin - GRID Component

Connecting a Vaadin SQL Container to a Combo Box

Web Cam and Vaadin