Skip to content

Map

Embeds an interactive street map, centred on a position or fitted to a set of markers. A marker click can run an action.

Map.builder()
.position("39.5696005,2.6501603") // latitude,longitude
.zoom("14")
.build()
PropertyTypeDefaultDescription
idString"map"Component id
positionString—Geographic coordinates as "latitude,longitude". Without it, the map fits its markers
zoomString—Zoom level (typically "1" to "20")
markersList<MapMarker>emptyThe points to show
markerActionIdString—Action a marker click runs, with the marker id in parameters._markerId
tileUrlStringOpenStreetMapTile URL template (Leaflet style: {s}, {z}, {x}, {y}) — see Tile provider
attributionStringOpenStreetMap’sCredit shown on the map for the tiles (text or HTML)
styleString—Inline CSS — use to set height
cssClassesString—CSS class names
Map.builder()
.id("properties")
.markers(List.of(
MapMarker.builder()
.id("PMI01").latitude(39.5715).longitude(2.6490)
.label("Palma Centre").description("22 of 180 rooms free")
.color("#508223")
.build(),
MapMarker.builder()
.id("PMI03").latitude(39.5580).longitude(2.6735)
.label("Portixol").color("#c74634")
.build()))
.markerActionId("openProperty")
.style("height: 34rem;")
.build()
public Object openProperty(HttpRequest rq) {
var id = rq.runActionRq().parameters().get("_markerId");
// …return a Drawer, a Message, navigate…
}

A marker shows as a pin in its color (any CSS colour; a red pin when unset), with its label beside it and its description on hover.

What the map shows first:

GivenThe map shows
positionThat point at zoom (the markers are drawn too)
no position, one markerThat marker, at zoom or close up (15)
no position, several markersAll of them, fitted
neitherThe world

The view needs a method named after markerActionId (public, or marked @Action), which is what advertises it to the client. See actions referenced by components.

RendererHow it draws the map
VaadinOpenLayers with OpenStreetMap tiles (or the tileUrl provider)
RedwoodLeaflet, loaded from cdnjs, with OpenStreetMap tiles (or the tileUrl provider). JET has no street map component (oj-thematic-map draws GeoJSON geography, not tiles)
React Native, IntelliJA list of the markers, each opening the point on openstreetmap.org. Neither renderer ships a native map SDK

By default the map draws OpenStreetMap’s public tiles, which are not meant for heavy production traffic. A deployment with real load should point each map at its own or a contracted tile provider:

Map.builder()
.position("39.57, 2.65")
.zoom("12")
.tileUrl("https://{s}.tiles.example.com/{z}/{x}/{y}.png")
.attribution("© Example Tiles, © OpenStreetMap contributors")
.build()

tileUrl is a Leaflet-style template: {z}/{x}/{y} are the tile coordinates and {s} an optional subdomain (the Vaadin renderer translates it to OpenLayers’ {a-c}). attribution is shown in the map’s corner; when tileUrl is set and attribution is not, no credit is shown — most providers require one. React Native and IntelliJ ignore both (they show the markers as a list).

The .NET (Map, MapMarker, with TileUrl/Attribution) and Python (fluent.Map, MapMarker, with tile_url/attribution) backends emit the same wire.

Map.builder()
.position("51.5074,-0.1278") // London
.zoom("12")
.style("height: 400px; width: 100%;")
.build()
ZoomRoughly shows
3Continent
8Region / county
12City
15Neighbourhood
18Street level