GWT Maps with Geocoding

I could still remember the last time I work with maps using my old EIS project (GWT+GMaps) where address can be converted to longitude and latitude to view the location. It was kinda hard to understand the code.

Google has made a major update for its maps with the use of Geocoding in order to easily view your search address. It was indeed a breeze especially on the code. It was cleaner and better than ever.



Here's my main menu. As I type the location of the address and hit the search button I was totally amaze with the result.



I tried a lot of address and it was almost 100% accurate. For now I am very much satisfied with the results.

For the past 4 hours I have goggled for some simple code on how to use the geocoding but most of them are too complicated to understand. Here's my code:

LatLng addressLatlng = LatLng.newInstance(13.8666667000, 121.0166667000);

MapWidget map= new MapWidget(addressLatlng, 5);

map.setSize("100%", "100%");

// Add some controls for the zoom level
map.addControl(new LargeMapControl());

// Add some type controls for the different map types
map.addControl(new MapTypeControl());


//for the gecoding codes add this to your button...

Geocoder geocoder=new Geocoder();

geocoder.getLatLng("Philippines", new LatLngCallback(){

@Override
public void onFailure() {


}

@Override
public void onSuccess(LatLng point) {

addressLatlng = LatLng.newInstance(point.getLatitude(), point.getLongitude());

map.setCenter(addressLatlng);
Marker marker=new Marker(point);

map.addOverlay(marker);

}

});


I'll be working with the database.

Comments

Anonymous said…
thank you :D your code really helped me :)
McZizou said…
Thnaks man... I found it really useful for the project I'm doing.
kroiz said…
Thanks a lot. That helped. too bad this post is only showing on page 100 of google search for gwt geocoder. I was lucky to find it cause I looked for geocoding as well.

Popular posts from this blog

Apple's Edge Over Microsoft?

High Grounds Cafe - Best Internet Cafe in the Philippines

John Gokongwei Speech before Ateneo 2004 Graduates