Hi,
I started using geotools today, so I am pretty new to this impressive
library. I am using a JMapPane to display raster data I got from a WMS
(geoserver). The layer is displayed properly, BUT: As soon as I create the
JMapPane-object, it's opening its own frame displaying the loaded layer
inside. 0o Looking at the documentation I found out that JMapPane is a
subclass of a "normal" JPanel, how can it open it's own frame? :X
I want the JMapPane to be displayed inside my mainframe, which is a normal
JFrame.
Another question: How can I use the controls for Zooming and Panning I read
about in some posts and parts of the documentation) At the moment, it looks
like a static image beeing simply displayed. Some source is following, maybe
it helps to find a way out of the magic frame-creation :)
URL myURL = new
URL("http://localhost:8080/geoserver/wms");
WebMapServer wms = new WebMapServer(myURL);
GetMapRequest mapRequest = wms.createGetMapRequest();
mapRequest.addLayer(currentLayer);
mapRequest.setFormat("image/png");
mapRequest.setDimensions(600, 600);
mapRequest.setBBox(currentLayer.getLatLonBoundingBox());
BufferedImage image =
ImageIO.read(wms.issueRequest(mapRequest).getInputStream());
GeneralEnvelope envelope = new
GeneralEnvelope(currentLayer.getLatLonBoundingBox());
GridCoverageFactory factory = new
GridCoverageFactory();
GridCoverage2D gc = factory.create("GridCoverage",
image, envelope);
gc.show();
MapContext mc = new DefaultMapContext();
StyleBuilder sb = new StyleBuilder();
org.geotools.styling.Style style =
sb.createStyle(sb.createRasterSymbolizer());
StreamingRenderer renderer = new StreamingRenderer();
HashMap hints = new HashMap();
hints.put("memoryPreloadingEnabled", Boolean.TRUE);
renderer.setRendererHints(hints);
mc.addLayer(gc, style);
JMapPane mp = new JMapPane(null, true, renderer, mc);
// this points to this class that is a subclass of
JFrame
// the JMapPane is even "displayed" (own frame) without
this line 0o
this.getContentPane().add(mp);
--
View this message in context:
http://www.nabble.com/Strange-JMapPane-behaviour-tf3736310.html#a10458412
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users