Plotting Jonathan's pink dots using Netbeans 5.5 Visual Web Pack

You must be impressed by the Jonathan's pink dots showing the worldwide Solaris growth. It would be equally impressive if we could create the pink dots Google Map mashup using Netbeans - Sun's another successful product. Yes, it is very simple  to create such mashup using Netbeans 5.5 Visual Web Pack AJAX components with as few as 10-20 lines of pure Java code. Also, it is possible to make the mashup much more interactive, like providing a dropdown list to select the dots only in particular country or show the dots only above or below certain threshold value.

Here is how you can do it.

Assume you have some data  like city, country and some reletaded data to plot. Ex:

"Oxford, United Kingdom", 105663 
"Louisville, Kentucky, United States", 85108

In order to plot this using the VWP Google map viewer component, you must first convert the city, country  information to corresponding Latitude and Longitude. This can be easily done by writing a simple web service using Netbeans. Now the converted data would look like

"Oxford, United Kingdom", 105663, 51.75, -1.2599
"Louisville; Kentucky; United States", 85108, 38.24, -85.7699

Once we include the Latitude & Longitude of the cities in the data, it is very easy to plot the data. After following the tutorial Using the AJAX Map Viewer Component , the additional code you need is to place the markers corresponding to different cities. Following are the additional few lines of code I added to the "prerender" method of the page bean.

        int maxCount = 2000;
        markers = new MapMarker[maxCount];
        ServletContext context = (ServletContext) getExternalContext().getContext();
        String realPath = context.getRealPath("/resources/sample_data.txt");
            BufferedReader in = new BufferedReader(new FileReader(realPath));
            String str;
            while ((str = in.readLine()) != null) {
                String[] data = str.split(",");
                markers[count] =  new MapMarker();
                if(count++ > maxCount) break;
        }catch (Exception exc) {

It is possible to show the intensity at a point by using different icons (like various shades and size of dots) for the marker. I used just the default icon for the markers and some dummy data for the locations (I don't have the actual pink dots data). The plots looked like the pictures below




It's great to see how easy it is to create maps mashups using NetBeans. One difference worth noting is that our "pink dots" map uses tile image overlays instead of the JavaScript-based markers shown here. JavaScript-based markers are great (and indeed are what people usually use with such mashups)--they just don't work well once you're talking about thousands of data points, as we have in the Solaris Registrations Map. More info is available in the "Maps" Category of my blog.

Posted by jamey on January 12, 2007 at 03:26 AM PST #

Yes, I hit this performance also when plotting 1000 conference participants (using Creator BTW). 1000 was pretty much an upper limit.
Haven't you seen some (google maps) performance problems?

Oh, and what's up with Australia, no NetBeans there? ;)

Posted by Alexis MP on January 12, 2007 at 03:43 AM PST #

Oh, and you probably have to batch-resolve the addresses into coordinates given geocoder DOS restrictions when using any real data.

Posted by Alexis MP on January 12, 2007 at 03:47 AM PST #

Yes, I agree. Browser crawls when the data points are more than few hundreds. Jamey, I would like to know more about the trick you guys used and see if I can use the same from Netbeans VWP AJAX component.

Posted by Winston Prakash on January 12, 2007 at 04:50 AM PST #

> Oh, and what's up with Australia, no NetBeans there? ;) You sensed it correctly, Alexis!. I think it is a bug in Microsoft Terraservice. It didn't give me the Lat/Lon for Australian cities. Also, you are correct that I have to geocode the cities one by one. Too slow and I couldn't do it in real time to plot it in the map.

Posted by Winston Prakash on January 12, 2007 at 04:55 AM PST #

i have a hacked-up, needs-refactoring j2ee google map tileserver available here for anyone who wants to see how its done: You'll need to do a few things to make this servlet-based image server worthwhile: 1: prerender the images 2: serve the prerendered images 3: don't serve dynamic images :) At the very least it should show you how to create a custom tile layer with Google Maps and Java. And Eclipse because personally, I can't stand NetBeans.

Posted by jeremiah johnson on January 12, 2007 at 06:35 AM PST #

java is the bomb : {}

Posted by vivek goel on January 24, 2007 at 11:47 PM PST #

I am unable using the above code in Studio creator it gives me error telling "Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error. Exception Details: javax.servlet.ServletException null Possible Source of Error: Class Name: org.apache.jasper.runtime.PageContextImpl File Name: Method Name: doHandlePageException Line Number: 827 " ////////////////////////////// "Exception Details: javax.faces.FacesException javax.servlet.ServletException Possible Source of Error: Class Name: com.sun.faces.context.ExternalContextImpl File Name: Method Name: dispatch Line Number: 327 " //////////////////////////////// "Exception Details: com.sun.rave.web.ui.appbase.ApplicationException javax.servlet.ServletException Possible Source of Error: Class Name: com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl File Name: Method Name: destroy Line Number: 601 "

Posted by Ashish Samant on June 25, 2007 at 05:41 PM PDT #

Dear Everyone, Anyone, Someone I have problem with creating .complib file. i used jar to create complib but creator IDE cant read. Can anybody help me on this. Regards, Ashish Samant

Posted by Ashish Samant on July 22, 2007 at 06:02 PM PDT #

Hi All,

I have problem and I need anyone of you here to give me some point of view on how am I supposed to develop a map application using NetBeans.I am planning to develop it in mobile application but I am not sure how to do it. How to call the map and create lines on it to show the path from the starting point and destination allocate by user. My application enable user to choose their preferable route selection, such as shortest path/ scenic route or least jam route.Please help.Thank You.

Posted by Sharon on October 29, 2007 at 03:13 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« August 2016