Features and Geometries
GeoMap
supports the following features:
MarkerFeature
Marker feature represents a marker element with predefined PointGeometry. It is displayed with marker icon in a map component.
The following example demonstrates how to create and place a marker on a map:
@ViewComponent
private GeoMap geoMap;
@Subscribe
public void onInit(final InitEvent event) {
VectorLayer vectorLayer = geoMap.getLayer("vector");
VectorSource vectorSource = vectorLayer.getSource();
addMarker(vectorSource);
}
private void addMarker(VectorSource vectorSource) {
MarkerFeature feature = new MarkerFeature(GeometryUtils.createPoint(40, 40));
vectorSource.addFeature(feature);
}
PointFeature
Point feature represents a point with predefined PointGeometry. It is displayed as a point with default style. For more details see Feature documentation.
The following example demonstrates how to create and place a point on a map:
@ViewComponent
private GeoMap geoMap;
@Subscribe
public void onInit(final InitEvent event) {
VectorLayer vectorLayer = geoMap.getLayer("vector");
VectorSource vectorSource = vectorLayer.getSource();
addPoint(vectorSource);
}
protected void addPoint(VectorSource source) {
Point point = GeometryUtils.createPoint(13.046446, 47.797916);
source.addFeature(new PointFeature(point));
}
LineStringFeature
LineStringFeature
represents a linear feature on a map, typically drawn as a polyline connecting multiple points. The polyline feature comes with a predefined LineStringGeometry. For more details see Feature documentation.
The following example demonstrates how to create and place a polyline on a map:
@ViewComponent
private GeoMap geoMap;
private final GeometryFactory geometries = GeometryUtils.getGeometryFactory();
@Autowired
private Notifications notifications;
@Subscribe
public void onInit(final InitEvent event) {
VectorLayer vectorLayer = geoMap.getLayer("vector");
VectorSource vectorSource = vectorLayer.getSource();
addLineString(vectorSource);
}
private void addLineString(VectorSource vectorSource) {
LineString lineString = geometries.createLineString(new Coordinate[]{
new Coordinate(13, 20),
new Coordinate(13, 32),
new Coordinate(25, 17)});
LineStringFeature feature = new LineStringFeature(lineString);
vectorSource.addFeature(feature);
}
PolygonFeature
PolygonFeature
represents a closed geometric shape on a map that defines an area or region. This feature is used to display and work with polygons, which are defined by a collection of interconnected points forming a closed loop. The polygon feature comes with a predefined PolygonGeometry. For more details see Feature documentation.
The following example demonstrates how to create and place a polygon on a map:
@ViewComponent
private GeoMap geoMap;
private final GeometryFactory geometries = GeometryUtils.getGeometryFactory();
@Autowired
private Notifications notifications;
@Subscribe
public void onInit(final InitEvent event) {
VectorLayer vectorLayer = geoMap.getLayer("vector");
VectorSource vectorSource = vectorLayer.getSource();
addPolygon(vectorSource);
}
private void addPolygon(VectorSource vectorSource) {
LinearRing shell = geometries.createLinearRing(new Coordinate[]{
new Coordinate(1.2457020544488762, 42.476628901048684),
new Coordinate(-0.054875980233204155, 52.77260344863316),
new Coordinate(29.858418817454655, 46.105591288830624),
new Coordinate(1.2457020544488762, 42.476628901048684),
});
PolygonFeature feature = new PolygonFeature(geometries.createPolygon(shell));
vectorSource.addFeature(feature);
}
PointGeometry
PointGeometry
is an object that contains org.locationtech.jts.geom.Point
object from the JTS library.
LineStringGeometry
LineStringGeometry
is an object that contains org.locationtech.jts.geom.LineString
object from the JTS library.
PolygonGeometry
PolygonGeometry
is an object that contains org.locationtech.jts.geom.Polygon
object from the JTS library.