>From: [EMAIL PROTECTED]
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: MI-L Mapxtreme Java (Layers....?)
>Date: Thu, 1 Feb 2001 10:09:37 -0000
>
>Hi Listers,
>
> I am at the end of my wits trying to figure out whats wrong with the
>following code
> All I am trying to do is display a layer (in red color) and put an
>image (star1.gif) in its center.
> but I cant see the layer itself. And I get no errors.
> Can anyone advise me what wrong am I doing ?
>
>Thanx in advance
>Sachin
I'll try to help as much as I can here.
>
> MapJ myMap;
> String MapXServletURL =
>"http://localhost:8080/mapxtreme/servlet/com.mapinfo.mapxtreme.MapXtremeServ
>let";
>
> public void service(HttpServletRequest req, HttpServletResponse res)
>{
>
> HttpSession session = req.getSession(true);
>
> try {
> myMap = new MapJ();
>
> myMap.setDeviceBounds(new DoubleRect(-400, -300,
>200, 150));
Make sure that you know the difference between setDeviceBounds and
setBounds. setDeviceBounds is typically called with arguments
(0,0,width,height), with width and height set to the pixel size of your
output image. More info on pages 125 and 129 in the handbook.
> myMap.setCenter(myMap.transformScreenToNumeric(new
>DoublePoint(-100, -75)));
Again, adjust these numbers so that they translate to actual screen
coordinates which are not negative.
Also, do a setDistanceUnits call and a setZoom call before you do the
setCenter call. This is an undocumented bug that I just recently found out
about.
>
> AnnotationDataProviderHelper DPHelper = new
>AnnotationDataProviderHelper();
> AnnotationTableDescHelper TabDesc = new
>AnnotationTableDescHelper("LA");
>
> LocalDataProviderRef MXDPRef = new
>LocalDataProviderRef(DPHelper);
>
> Layer cardiffLayer =
>myMap.getLayers().insert(MXDPRef, TabDesc, 0, "LA");
> cardiffLayer.setSelectable(true);
>
> FeatureFactory ff = myMap.getFeatureFactory();
> Rendition rend = new Rendition();
>
> rend = new Rendition();
> rend.setValue(Rendition.FILL, java.awt.Color.red);
> rend.setValue(Rendition.FILL_OPACITY, new
>Float(0.40));
> double pnts[] = {-400, -300, 200, 150};
> cardiffLayer.addFeature(ff.createRegion(pnts, rend,
>null, null));
>
> rend = new Rendition();
> rend.setValue(Rendition.SYMBOL_MODE,
>Rendition.SymbolMode.IMAGE);
> rend.setValue(Rendition.SYMBOL_URL,
>"file:///c:/Program Files/mapinfo/data/star1.gif");
> DoublePoint dp = new DoublePoint(-100, -75);
> cardiffLayer.addFeature(ff.createPoint(dp, rend,
>null, null));
>
> MapXtremeImageRenderer renderer = new
>MapXtremeImageRenderer(MapXServletURL);
> myMap.render(renderer);
> res.setContentType("image/gif");
> renderer.toStream(res.getOutputStream());
> renderer.dispose();
> } catch (Exception e) {
> System.out.println("Exception occured");
> e.printStackTrace();
> }
Okay, a few notes on the render block above
make a ServletOutputStream and assign res.getOutputStream() to it.
do the call to renderer.toStream() with the ServletOutputStream object you
just created.
After you dispose of the renderer, close the servletoutputstream inside of
its own try block.
>
> }// end of method service
>
>
>
Hopefully you can get it working.
-Justin Akehurst
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.