views:

194

answers:

3
+2  Q: 

google maps api

How do you access google maps API from a Java application?

+1  A: 

Your best bet for client side Java would be the Static Maps API. For server-side Java, the answer will heavily depend on what framework you are using for development. Having said that, the Google Maps API is well documented.

jsight
+1  A: 

Hello, you can use Swing Labs, JXMapKit from swingx: http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html

It is pretty straight forward. For more info refer to the website.

JXMapKit mapView = new JXMapKit();
mapView.setDefaultProvider(DefaultProviders.OpenStreetMaps);
mapView.setDataProviderCreditShown(true);
add(mapView)

It will look like this:

alt text

Take a look at the source code in the article above, with three lines of code, you can view a map easily:

Mohamed Mansour
+1  A: 

You can use Swing-WS, a component JXMapViewer is available and provides similar functionality as JavaScript version. However it is still not legal to access Google tile servers outside the provided APIs : JavaScript and Flash.

There is an issue opened to track this request : http://code.google.com/p/gmaps-api-issues/issues/detail?id=1396. It is approved but who knows when it's gonna be available.

adrian.tarau