Wednesday Apr 15, 2009

JavaFX + Web Service + Maps + Navigation

Just a small demo of JavaFX + Web Services. From JavaFX, its quite easy to work on Web Services like maps, search, pictures .. There are lot of Web services demo in the sample space

Here I have contact list of person, which has name, email ID, phone no, address and thumbnail images. Everything has a different work but here we are willing to see the address work. On clicking contact list's, will show me his location in maps. Actually there are two ways to do that, fast way and good way. We can store the maps in Database and use it when required, other is we call the web service and take the map on demand from Yahoo or Google API, which will be slow. So, we will go with good way.

Considering only one contact.


Some fancy stuff, like clicking the + sign will open address option. Now, on clicking the address, we will call the yahoo maps API for showing the location of the person Joseph J.

Actually its a mobile application, and can be viewed in mobile as well(just that I am not putting image). So, in basic code of Map show, we did :

// in place of Sunnyvale and CA, it will be {city} and {state} which will be the variables and passed from main code.

var url = bind "http://local.yahooapis.com/MapsService/V1/mapImage?appid=GetApp;city=Sunnyvale&state=CA";

   var p: PullParser;
   var h: HttpRequest;
   init {
           if (url.length() > 0) {
           h = HttpRequest {
               location: url
                onException: function(exception: Exception) {
                }

                onInput: function(input) {

                   p = PullParser {
                       input: input
                       onEvent: function(event) {

                           if ((event.type == PullParser.END_ELEMENT)) {
                               if (event.qname.name == "Result") {
                                   location = event.text; //this will give a URL for image
                               }
                          }
                       }
                   };
                   p.parse();
                   p.input.close();
      .......

Lot of further code. Important of it is OnDone method where we have to write some code of cleaning or loading prev. data. I have also embed my long back code of navigation, which will help us into navigation in the map.

Ignore some minor mistakes, have a look at the jnlp:

Soon, I will post the whole application with code, but the basic idea is simple and can be doable. 

About

Hi, I am Vaibhav Choudhary working in Sun. This blog is all about simple concept of Java and JavaFX.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today