aspose file tools*
The moose likes Web Services and the fly likes Google Maps in a java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Google Maps in a java application" Watch "Google Maps in a java application" New topic
Author

Google Maps in a java application

Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
Hello

Im not too sure if ive written this in the right section but here goes

Some of you may have seen my posts before, however this is a total new thing to me now.

I need to incorporate google maps into my (homemade) java application. Im replicating a sat nav system and ive got the user inputting a destination address etc but now i need some way of passing that information to Google Maps and then retrieving the list of directions as well as the overview of the map that shows the highlighted route.

I need to be able to somehow stick that into a JFrame or JPanel if possible, as im using CardLayout to navigate between 'screens'

Is this possible as a whole?

Also i have never used javascript before anyone mentions that and ive been told by colleagues that its pretty difficult to incorporate it into Java. Is this true?

My supervisor has mentioned using AJAX but ive never used that either and ive been trying to read up on it but it makes no sense to me - im pretty useless with web stuff

Anyone able to help???

p.s. ive been using NetBeans 6.5 to generate my GUI, just incase that makes any difference to people's expertise

Harv
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
Google Maps is based on HTML and JavaScript, and thus for use in a web browser. You may be able to use it in a Java application if you have a sophisticated embedded web browser component (like Lobo), but I wouldn't bank on it.

Maybe a Swing component like JXMapViewer is a better fit.


Ping & DNS - my free Android networking tools app
Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
Thanks for that, i actually came across that just after i posted on here but i hadnt read it yet

Do i need to change the classpath to use it? i added the .jar files that it mentioned but i still couldnt find the JXMapKit.class it was on about
Am i right to download the 'sources' from the http://swinglabs.org/downloads.jsp or should i download and unzip the 'binaries' or 'javadoc'?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
That class is part of https://swingx-ws.dev.java.net/

Why would you download the sources (unless you intend to compile it yourself)? You should download the javadocs if you intend to use any of the classes in your application and so may need to look up the API (in other words, yes).
Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
I tried using the JXMapViewer, did exactly as the tutorial said but when i dragged the class over to the panel, there was no image of a map at all, just a blank grey-ish screen with small images that i think were meant to represent a clock or a dial of some sort.

It didnt work at all when i ran it too, came up with the same thing.

I need to tap into google maps to access the directions list and to display the highlighted route that will be taken as you would see on a commercially available sat nav system. I cant seem to find anything else other than JavaScript stuff on the problem or the JXMapViewer and as mentioned, it aint working.

Is there any way of just tapping into Google Maps' "data" in order to just retrieve the directions list and then worry about the actually graphical display later?

Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
ive found out that JXMapViewer isnt 'legal' to use with Google Maps and that Google tend to change a parameter in their URL (i think) regularly to stop things like the JXMapViewer from accessing the service.

Has anyone used AJAX in java before? ive been told its a method of accessing a website which can update without actually having to refresh the entire page, slowing down the entire thing. Was wondering if a Google Maps key is required when using AJAX too or is that only when you use the Google Maps API?

Another thing is, is Google Earth any better to use in java or will it still pose the same problems as Google Maps does?

All help, asap, would be greatly appreciated as i have no idea!!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
Google Earth is a native desktop application; I don't see how it could help in a Java application.

AJAX is something you'd use in a browser, for instance if you were to go the "classical" integration route by using a browser component that I suggested in my first post. But you'd need a Google maps key either way, and you need to adhere to the license (which may mean purchasing a commercial package if you can't work within the restrictions of the free license).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Google Maps in a java application