Google Geo Kit With Zk Gmaps

From Documentation
Revision as of 09:47, 3 December 2010 by Tmillsclare (talk | contribs) (→‎Work with ZK Gmaps)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
DocumentationSmall Talks2010OctoberGoogle Geo Kit With Zk Gmaps
Google Geo Kit With Zk Gmaps

Jeff Liu, Freelance Senior Web Application Developer, [email protected]
October 14, 2010
ZK Gmaps 2.0


A controversial article was published 2 years ago, ZK vs. GWT : Server-Centric Matters!, which caused a large amount feedbacks on this topic. After 2 years , both frameworks have improved greatly. As the author of this article, rather than continue this debate, I will finish off the technology.

In the article, one sample was used to demonstrate the difference between ZK and GWT, Google Maps Locator. A fake geocoding class was used to locate the latitude and longitude for a certain address, which does nothing but couple exiting data. To actually geocode the latitude and longitude in Java, Google Geo Kit in Java is introduced.

Google Geo Kit in Java

Google Geo Kit in a java is an implementation of Google Geocoding API in Java, refer to A simple demonstration of it's usage is following.

SpotInfo sinfo = new SpotInfo();
sinfo.Address = "1600+Amphitheatre+Parkway,+Mountain+View,+CA";
Geocoder geo  = new Geocoder();
GeoResult result = geo.GetGeoResult(sinfo);
if (GeoResultStatus.OK.Equals(result.Status))//@since 0.1.1
	foreach (GeoObj obj in result.Results)
		Response.Write(obj.FormattedAddress + "<br>");

Work with ZK Gmaps

    <script src=";v=2&amp;key=KEY" type="text/javascript" >
        <div align="center">
            <vbox width="600px">
                <textbox id="tb" width="550px" value="1600+Amphitheatre+Parkway,+Mountain+View,+CA" />
                <button onClick="locate();" label="Search" />
                <gmaps id="mymap" zoom="16" height="300px" />
        import org.zkoss.gmaps.Ginfo;   
        import org.gglgeo.ggl.GeoInfo;
		import org.gglgeo.ggl.GeoLatLng;
		import org.gglgeo.ggl.GeoObj;
		import org.gglgeo.ggl.GeoResult;
		import org.gglgeo.ggl.Geocoder;  
        public void locate(){  
        	GeoInfo info = new GeoInfo();
			Geocoder gcoder = new Geocoder();
			GeoResult gresult = gcoder.get(info);
/*According to Google Geocoding API, "results" contains an array of geocoded address information and geometry information, 
getResult will return array of result objects rather than single one.*/
			GeoLatLng latlng = gresult.getResults().get(0).getGeometry().getLocation();
            mymap.panTo(latlng.getLat(), latlng.getLng());


Thanks All

I left the ZK development team 2 years ago to start my own startup but I still pay attention to ZK and its development. It have improved greatly during the past 2 years. Thanks for all the people from Potix for what I have learned during my time there and after.

For any questions, please contact: [email protected]

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.