RE: [OpenMap Users] How to integrate openmap into a web applicati on

From: Keith Alphonso <>
Date: Thu, 14 Oct 2004 13:46:10 -0500

The following is code snippets that we use to create a servlet for
generating maps using OpenMap. Creating a servlet gives us a lot more
control as we can manipulate properties, etc. as part of our servlet logic.
The servlet doGet gets the map as an image and streams it out: Notice it
also handles a save parameter which causes the download dialog to occur.
  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
      //Get the map as a JPEG image
      imageArray = OMUtil.getMapAsJPEG(session, m);
      //send it
      //If asked to save, set content-disposition to save to file
      if (request.getParameter("save") != null
      && request.getParameter("save").equals("yes"))
        response.setHeader("content-disposition", "attachment;
      response.addHeader("cache-control", "no-cache");
      ServletOutputStream outStream = response.getOutputStream();
      outStream.write(imageArray, 0 , imageArray.length);
The following code generates the image from a set of properties. We use our
own internal map object and convert that into openmap properties. We also
have code (setupLayers) to manipulate layers by sending our internal map
object into the layer for additional processing.
  public static byte [] getMapAsJPEG(HttpSession session, Map map) throws
     //Get the map properties
     Properties props = getMapProperties(map);
     //Can only display if we have properties
     if (props != null)
       //Hack (we want to only display startUpLayers, so copy to layers
       Properties tprops = new Properties(props);
       tprops.put("openmap.layers", props.get("openmap.startUpLayers"));
        //Create the image server
        ImageServer imageServer = new ImageServer(tprops);
        com.bbn.openmap.Layer[] layers = imageServer.getLayers();
        setupLayers(layers, session, map);
        //Generate the image
        com.bbn.openmap.image.SunJPEGFormatter formatter = new
        byte [] imageBytes = imageServer.createImage(getMapProjection(map,
        return imageBytes;
      return null;

-----Original Message-----
From: Nagiel, Shahak (Mission Systems) []
Sent: Thursday, October 14, 2004 1:09 PM
To: Kim Nguyen;
Subject: RE: [OpenMap Users] How to integrate openmap into a web application

We did this using the SimpleHttpImageServer class, which we had a startup
servlet instantiate. Subsequent requests from the UI are translated into a
query string passed to the Server, which spits back an image that's returned
by our servlet. Our specs allowed users to create search areas of interest
and plot other graphics (such as military symbology) on top of the returned
maps, which we handle with OMGraphicList. It took some effort at first to
understand how all the pieces fit together, and developing the framework for
basic map interaction (zoom, pan, layer visibility, etc.), but once done it
works pretty well, and is fast. Let me know if you'd like some code
Good luck.

-----Original Message-----
From: []On
Behalf Of Kim Nguyen
Sent: Thursday, October 14, 2004 1:16 PM
Subject: [OpenMap Users] How to integrate openmap into a web application

I am writing a web application and I want to include openmap in one of
pages. I am not sure where to start, could I have some hints on this?

Kim Nguyen
NASA - Goddard Space Flight Center
Code 588
Building 23, Room W409
(301) 286-3315
 (301) 286-1768 Fax

[To unsubscribe to this list send an email to ""
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Oct 14 2004 - 14:46:04 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT