integrate a Google Map into a Website using JSF

The Challenge is to implement a Google Map into a Website. The should be option to add a mark on the map using for example the address or the latitude and longitude.
1 answer

integrate a Google Map into a Website using JSF

If you are implementing a Website using JSF and Java, and you want to add a Google Maps, there can be different solutions.

You can use one of the PrimeFaces components. There is a nice little component called GMap: http://www.primefaces.org/showcase/ui/gmapHome.jsf
However it is doesn’t offer every function we are used to have with a Google Map.

A better possibility is to use gmap4jsf. To add a Google Mao into your JSF Page you need to add the gmaps4jsf tab library.
Here is a simple Example of who you can use it:

<%@ taglib uri="http://code.google.com/p/gmaps4jsf/" prefix="m" %>

The Example in the attachment uses the latitude and longitude to present a marker on a specific point on the Google Map. The picture in the attachment presents the resulting outcome.

Further examples can be found using the following link:
http://www.mashups4jsf.com/gmaps4jsf-examples/home.jsf

The gmpas4jsf provides JSF tags that make it easy to create a map using latitude and longitude or an address. You can add a marker to the map or an information text. Also some nice additional function like a zoom in and out or switching between map types can be used.
You can read an overview about the functionalities of gmaps4jsf using the following link: http://code.google.com/p/gmaps4jsf/

To calculate your coordinates you can use the Java API for Google geocoder v3
An overview about the functionality and also information about the Maven Repository can be found under the following link: http://code.google.com/p/geocoder-java/
The geocoder is an easy possibility if you want to search for a specifiy city or route that you want to presents in your Google Map.

Taggings: