code, Java, MapXtreme

Intro to GIS using MapXtreme Java

Part of a small project i  worked on during the summer using NetBeans and MapXtreme Java.With Google Maps , YahooMaps and Openstreet Maps you are genrally spoilt for choice for mapping  applications to build on.However for a few of the more customizable map applications you can roll your own maps and have a suitable interface built using JavaBeans in no time at all.


MapXtreme Java
Prepared Map (mdf format)

Rolling the code

The MapXtreme beans are based on swing tech so integrating them into any java project isnt that muchof a hassle.Main ones to be aware of are and the ones that will be used :

  • VisualMapJ Bean
  • Map ToolBar Bean
  • Tool Beans
  • LayerControl Bean

The visualmapj displays within its content pane built on MapJ base object from which they all inherit.The MapXtreme components come with buildt in webserver (tomcat) from which the map is loaded and served via jsp.After loading the map and checking that it displays ok on the browser.The next step is serving the data from the webserer to a desktop client.

Loading Map into tomcat webserver
Loading Map into tomcat webserver

and displaying the map in the browser:

Webview of Map
Webview of Map

finally putting the desktop app into shape:

imports added to the top of the app:

import com.mapinfo.beans.vmapj.RendererParams;
import com.mapinfo.beans.vmapj.VisualMapJ;
import com.mapinfo.mapdefcontainer.FileMapDefContainer;
import com.mapinfo.xmlprot.mxtj.ImageRequestComposer;

preparing the colors for the display panel and the map:

int maxColors = ImageRequestComposer.MAX_COLORS_TRUECOLOR;
String mimeType = “image/gif”;
String filename = “working.mdf”; 

introducing the beans to hold the map and the control panel:

VisualMapJ vMapJ = new VisualMapJ();
MapToolBar mapToolBar1 = new MapToolBar();

specifying the address of the server running and the container that will receie the displayed map:

String m_mapxtremeURL = “http://Cass1opeA:8090/mapxtreme482/servlet/mapxtreme”;
FileMapDefContainer fmdc = new FileMapDefContainer(“/home/wakwanza/Cod/Maps/data/”); 

and finally putting it all together in a simple try catch to get our app running:

RendererParams myRendererParams = new RendererParams(m_mapxtremeURL,mimeType);
vMapJ.setStartupMapDefinition(new com.mapinfo.beans.vmapj.MapDefParams(fmdc, filename));
vMapJ.setSize(new Dimension(550,550));
catch(Exception e)

JavaApp pulling map from MapXtreme
JavaApp pulling map from MapXtreme

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s