1

I've been playing around with the GeoTools libraries, but I can only show shape files and no custom layers. Requirements are that it must use the SWTMapPane and not via the static SWTMapFrame.showFrame(). I'm looking for sample code that just creates features, say points, give it a style and show it on the pane.

Load shape file:

File openFile = new File(XXX);
if (openFile != null && openFile.exists()) {
    FileDataStore store = FileDataStoreFinder.getDataStore(openFile);
    SimpleFeatureSource s  =  store.getFeatureSource();
    Style style = Utils.createStyle(openFile, s);
    FeatureLayer featureLayer = new FeatureLayer(s, style);
    mapContent.addLayer(featureLayer);
    getMapPane().reset();
    getMapPane().redraw();
}

Now I want to add a custom layer containing features with a style, and then adding it to the mappane. Sample code I found always seem to contain deprecated code or JMapPane code.

  • Welcome to GIS SE! Would you be able to edit your Question to add details like your code to show shapefiles, and where you have already looked for sample code, please? – PolyGeo Jun 4 '14 at 21:39
  • creating the features and style is abstracted away from the mapPane code so any of the existing examples you've found will work. See docs.geotools.org/stable/userguide/tutorial/feature/… – Ian Turton Jun 5 '14 at 7:32
1

Found my problem: I was relying on pieces of code to create a style, but I got hold of a complete style description which worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.