|
From: Nikos <my...@ya...> - 2007-06-29 15:42:32
|
Hello, I'm trying to use a JMapPane to display some data, but I get nothing. I haven't found a jmappane example and so I'm just guessing how to use it, the code I've written is this :
PostGISConnectionDialog pgis_dialog = new PostGISConnectionDialog(this); // modal window to input postgis connection properties.
PostGISProperties pgis_properties = pgis_dialog.getProperties(); // PostGISProperties keeps hostname, port, username, etc.
try {
PostGISReader pgis_reader = new PostGISReader(pgis_properties); // PostGISReader provides easy access to the postgis database.
FeatureCollection feature_collection = pgis_reader.getFeatures();
StyleFactory style_fact = CommonFactoryFinder.getStyleFactory(null);
Style style1 = style_fact.getDefaultStyle();
CoordinateReferenceSystem crs = pgis_reader.getCoordRefSystem();
MapContext map_context = (MapContext)new DefaultMapContext(crs);
map_context.addLayer(feature_collection, style1);
GTRenderer gt_renderer = (GTRenderer)new StreamingRenderer();
map_pane = new JMapPane(gt_renderer, map_context);
jPanel1.add(map_pane, BorderLayout.CENTER);
this.validate();
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Could not access the database.", "Error",JOptionPane.ERROR_MESSAGE);
}
PostGISReader.getFeatures() and PostGISReader.getCoordRefSystem() return correct values, i have tested this. So, I must be doing something really wrong :) Any help is welcome :)
Nick Lefkaditis
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
|