-
How to use google maps in a frame and get string
Hello,
I am new here, but not new in the programming field, I would like to know, whether it is possible, how to implement a map (I was thinking about google maps) which will highlight only some specific locations; whenever the user clicks on one of them, the program will get the variable (e.g. the name of the location) and save it into a String.
Example:
A wild map appears.
User will see the map of the area, with (let's say) 10 Points Of Interest.
The user can click on one of them, if so, the program will show on a JOptionPane (this is just for testing purposes, to see if the variable is correct) the name of the location (I have chosen before, maybe directly on google maps).
Would it be possible?
Of course, I don't want the code, but just to know if there is another way I should try, or if there are already threads talking about this.
Thanks :)
Peace,
Nesh
-
Re: How to use google maps in a frame and get string
"Everytime someone does not reply to a post, a 5c coin is lost in an old couch and forever forgotten."
-
Re: How to use google maps in a frame and get string
I attempted to use maps for user interface a while back, It did not last long then our funding ran out. I use OpenGL to create a map viewer and totally user friendly. the code was crazy and we ended up stopping. That was my first taste of OpenGL and I liked it. Otherwise I think C++ would have done the job, our second option but too many people were new to coding.
The map we used was a picture and we just scrolled and zoomed in on different locations. The refresh map to different location ended up using another picture.
-
Re: How to use google maps in a frame and get string
Quote:
Originally Posted by
Nesh108
Would it be possible?
Yes, it is possible.
You can integrate the map API or you can either draw the maps by yourself (infact a bad strategy).
-
Re: How to use google maps in a frame and get string
Hello,
thanks for the replies.
I have studied OpenGL, but I do not think I am going for that direction.
What I was thinking is to implement Google's API for google.maps and importing a specific map I have created before (where I highlight the important POI). Once it is loaded on the application, I want that the user is able to click on one of these points and change the value on a ComboBox (basically I give the user the chance to either select the point by using a ComboBox or by simply clicking on the area).
I have tried to google it, but I can't find anything. But I know someone manage to do it, somehow...
-
Re: How to use google maps in a frame and get string
I have found 'PrimeFaces'. Great for what I am looking for, but it appears to be available only for JSF.
Can I use it maybe with my desktop application as well?
Here is the link to the code. It does what I want, but not sure whether I can import it on my app or not.
http://www.primefaces.org/showcase/u...rkerSelect.jsf
-
Re: How to use google maps in a frame and get string
Google maps doesn't allow to let use their images in desktop application.
So, you can't directly do this. Infact you must have to create a web service to adopt/fulfill the functionality. So, you can do either of these options
1. Try to embed a browser in your java desktop application.
2. Go at this link and download the world wind java sdk, they are implementing the maps but not the google maps but most of the goolge maps are taken off this.
I hope, it will help you.
Good Luck.
-
Re: How to use google maps in a frame and get string
what I was thinking is to create a JSF file and load it onto the Java Application. Would that be possible?
-
Re: How to use google maps in a frame and get string
JSF is actually a java framework that allows you to create java web applications.
And in my above post, i have mentioned you two options, So, now improving your statement, you want to create a web page and embed it into the desktop application.
And yes, it is possible.
You can do this. But the main motive of desktop application will be spoiled (dead). So, why don't you try to create a web service, instead of embedding a web page in your desktop application?
That web service will fetch all the data from the web, will take images of maps and you can then use that data in order to deploy to your desktop application.
Anyways, simply answering to your question, YES, the thing you want to do is ofcourse possible.
-
Re: How to use google maps in a frame and get string
The fact is that I need to be able to catch whenever the User clicks on a marker I previously put.
Would a web service do the same? If so, do you have any hint on how?
-
Re: How to use google maps in a frame and get string
Well, yes, web service can act like same.
1. Create a web service, that will allow to fetch data from the server.
2. Call this web service;
(i). When your applications loads.
(ii). When user performs some event (events that should fetch the data from server).
(iii). Use that fetched data to design the map again now.
3. You just need to create web service intelligently, so that you could call it, in two different behaviours.
-
Re: How to use google maps in a frame and get string
I created a web service, but now I am wondering how I can do what I need...
Because if I use primefaces, I already have everything done (even if it is getting extremely hard to setup, I thought it would be way easier), otherwise I need to find a way to get the map I want and catch the clicks... Same old story.
-
Re: How to use google maps in a frame and get string
I actually found a way to get the event from a webpage using javascript. Now I just need to send the information from Javascript function to the Java application...
And load the html page from java.
-
Re: How to use google maps in a frame and get string
Yeah that's good. So far you are going fine??
-
Re: How to use google maps in a frame and get string
Nope. I just found out that Java does not really supports any kind of JWebPane...
So I would need to implement a browser (long time) for then trying to use the html page + jsp for getting the information....
Flash on google maps is now tagged as deprecated...
So, is there a quick way to implement a google map, create markers and apply events on them?
The best one I found so far is the use of Primeface, but I tried to start some tutorials for JSF, but it is quite challenging and I foresee I might get off the path (you know, maybe finding at the end of the way that I am not able to run JSF from my desktop application...)
So my problem is still not solved....
-
Re: How to use google maps in a frame and get string
-
Re: How to use google maps in a frame and get string
Lobo was the best solution, but it sadly does not work properly with google maps (too much AJAX on it)............................. cursed component
-
Re: How to use google maps in a frame and get string
-
Re: How to use google maps in a frame and get string
I tried it, but I could not run it on my Eclipse (on Mac). I will try eventually on Windows, but this application must be cross-platform.
Whenever I try to run the sample, following all the steps, the imports do not work...
Other browser as well, but same thing. The only one which worked was Lobo, but sadly no google maps...
-
Re: How to use google maps in a frame and get string
Well, as we all know that Java is platform independent and once you developed in windows or any platform, you can run it anywhere.
Well, i don't know much about using Eclipse over Mac, but i have tried Web browser in my desktop application (windows) and it worked all fine, though i didn't try google maps but i can for sure say that, web browser is the solution to your problem and it should work in all cost.
Well, i will recommend you to read these links... May be these could help you anyhow...
1
2
A code found on internet, works on MAC too.
-
Re: How to use google maps in a frame and get string
I will try to follow the tutorial for DJ Native on my Windows PC and see if it works.
But they also ask to download files for each of the OS I want to support... that's crazy to me, but anyway. I will give it a try.
Before even trying: can I get values from a javascript function? I found the code for catching the event of a click on a marker on google maps, but I need to send the information (a String) to the Java application in order to use it. Is it possible?
-
Re: How to use google maps in a frame and get string
Yes you can pass the values from javascript to java, but you must have to use hidden applets.....
And let me know in case of any success or failure, related to those links, Must read the third link i provided there. That's purely for MAC
-
Re: How to use google maps in a frame and get string
Nesh108, please stop posting questions that are basically "is it possible to do XYZ" or "how do I do ABC". People here have been incredibly patient with you, but those kinds of questions aren't really answerable. Do some googling. Post what you find, and why exactly it didn't work. Post an SSCCE if you have a question about code. Read the link in my signature on asking questions the smart way.
From a quick google, I found several map viewing projects in Java. It took me all of 5 minutes to download one and get it working. I'll even list a few here:
Java Swing MapViewer
Building Maps into Your Swing Application with the JXMapViewer | Java.net
-
Re: How to use google maps in a frame and get string
Thanks for the reply, but the first link does not work on Mac (tested only on Windows 32-bit, but might also work on 64). And the second one, I wonder how you could make it work as the link for download of the library is not working (at least for me): http://swinglabs.org/
And on the java.net website there is no downloadable library available.
I will try to google myself, and thanks Mr.777, a lot!
Whenever I come to a conclusion, I will let you know.
If you get news, let me know as well :P
-
Re: How to use google maps in a frame and get string
Ok guys, I managed to do it.
Thanks for the help.
I would suggest to leave this post open in case anyone else needs help with this.