Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: How to use google maps in a frame and get string

  1. #1
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Smile 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
    Last edited by Nesh108; October 23rd, 2011 at 01:02 PM.


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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."
    Last edited by Nesh108; October 24th, 2011 at 03:46 PM.

  3. #3
    Member
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    69
    My Mood
    Bored
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Default 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.

  4. The Following 2 Users Say Thank You to william For This Useful Post:

    JavaPF (October 25th, 2011), Nesh108 (October 25th, 2011)

  5. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: How to use google maps in a frame and get string

    Quote Originally Posted by Nesh108 View Post
    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).

  6. #5
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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...

  7. #6
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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

  8. #7
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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.

  9. The Following User Says Thank You to Mr.777 For This Useful Post:

    Nesh108 (October 25th, 2011)

  10. #8
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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?

  11. #9
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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.

  12. The Following 2 Users Say Thank You to Mr.777 For This Useful Post:

    Nesh108 (October 25th, 2011), william (October 26th, 2011)

  13. #10
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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?

  14. #11
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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.

  15. #12
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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.

  16. #13
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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.
    Last edited by Nesh108; October 25th, 2011 at 12:37 PM.

  17. #14
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: How to use google maps in a frame and get string

    Yeah that's good. So far you are going fine??

  18. #15
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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....

  19. #16
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,104
    Thanks
    169
    Thanked 780 Times in 726 Posts
    Blog Entries
    5

    Default Re: How to use google maps in a frame and get string

    Try using Lobo: Java Web Browser and see if this works for you. Alternatively, look into JavaFX | Rich Internet Applications Development | RIAs Java FX

  20. #17
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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

  21. #18
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: How to use google maps in a frame and get string

    Did you try JWebBrowser?

  22. #19
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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...

  23. #20
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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.
    Last edited by Mr.777; October 27th, 2011 at 07:52 AM.

  24. #21
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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?

  25. #22
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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

  26. #23
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,986
    My Mood
    Hungover
    Thanks
    133
    Thanked 557 Times in 478 Posts

    Default 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
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  27. #24
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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

  28. #25
    Member
    Join Date
    Oct 2011
    Posts
    53
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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.
    Last edited by Nesh108; October 30th, 2011 at 01:06 PM. Reason: fixing some stuff

Page 1 of 2 12 LastLast

Similar Threads

  1. JAVA and Google Maps
    By aussiemcgr in forum Java Theory & Questions
    Replies: 7
    Last Post: February 1st, 2011, 07:57 PM
  2. [SOLVED] Maps and adding to sets as values
    By mds1256 in forum Collections and Generics
    Replies: 3
    Last Post: March 26th, 2010, 09:12 AM
  3. Design question about maps
    By KaleeyJ in forum Java Theory & Questions
    Replies: 1
    Last Post: February 2nd, 2010, 03:17 AM
  4. Need help with String Trimming.. and displaying Keys on maps.
    By bh-chobo in forum Algorithms & Recursion
    Replies: 1
    Last Post: November 9th, 2009, 12:15 PM
  5. Convert Maps of String to Map of Maps
    By abhay8nitt in forum Collections and Generics
    Replies: 1
    Last Post: October 27th, 2009, 07:27 AM

Tags for this Thread