i am new to GIS field and i am using geotools to read/view shape files how so how can i read data about certain point in shape file without using InfoTool , for now i am capable of reading and viewing shp file and i can use InfoTool , Zoom tool ,...etc
private void openButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JFileDataStoreChooser x = new JFileDataStoreChooser("shp");
x.setAcceptAllFileFilterUsed(false);
x.setFileSelectionMode(JFileDataStoreChooser.FILES_ONLY);
int val = x.showOpenDialog(null);
if ((val == JFileDataStoreChooser.CANCEL_OPTION) || (val == JFileDataStoreChooser.ERROR_OPTION)) {
return;
}
File file = x.getSelectedFile();
if (file == null) {
return;
}
try {
store = FileDataStoreFinder.getDataStore(file);
featureSource = store.getFeatureSource();
// Create a map content and add our shapefile to it
MapContent map = null;
if (mapPane.getMapContent() == null) {
map = new MapContent();
map.setTitle("Quickstart");
} else {
map = mapPane.getMapContent();
}
Style style;
style = SLD.createSimpleStyle(featureSource.getSchema());
FeatureLayer layer = new FeatureLayer(featureSource, style);
map.addLayer(layer);
mapPane.setMapContent(map);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
and what i want to do is :
mapPane.addMouseListener(new MapMouseAdapter() {
@Override
public void onMouseClicked(MapMouseEvent ev) {
// ev.getWorldPos();
// get data from shape file if found about position
// view this data
// JOptionPane.showMessageDialog(data);
}
}
});