GoogleMaps JSP Taglibrary  

Example 14 -Integrating with JSTL

This example demonstrates (quite simply) how to integrate the Google Maps JSP Taglibrary with JSTL to use database data to generate a map.

What we've done is pulled address information from a database and let the <googlemaps:point> tags geocode them on the fly (as we don't store longitude and latitude information). If you did elect to store longitude and latitude data, this map would load even faster.

For simplicity sake, we did not integrate any <googlemaps:infowindow> tags with our markers, though we easily could have.

Here's the code we used:

<googlemaps:map id="map" width="780" height="300" version="2" type="STREET" zoom="14">
  	<googlemaps:key domain="localhost" key="xxxxx"/>
	<googlemaps:message>
		<img src="/GoogleMaps/images/loading.gif"/> Please wait...
	</googlemaps:message>
	<sql:query var="customers" dataSource="mydata/src" startRow="7" maxRows="10">
	SELECT seq AS seq, addr AS addr, city AS city, state AS state, zip AS zip FROM all_customers
	</sql:query>
	<c:forEach var="customer" items="${customers.rowsByIndex}">
		<googlemaps:point id="point_${customer[0]}" address="${customer[1]}" 
		    city="${customer[2]}" state="${customer[3]}" zipcode="${customer[4]}"/>
		<googlemaps:marker id="marker_${customer[0]}" point="point_${customer[0]}"/>
	</c:forEach>
</googlemaps:map>
  

Of course for security sake, I've changed the names of the innocent...but you get the idea.

Our next example demonstrates the new XML capabilities for supplying map data.

Return to the Examples page.

Google
Search for Google Maps technology:

Java JSP PHP ASP
Google™ and the GoogleMaps API are copyright of Google.