Skip to content

Maps ​

Elody draws maps in two places:

  • mapElement on a detail page: the entity's own geometry.
  • The map view mode of a list: every entity in the list on one map, next to the list and grid view modes.

Both use OpenLayers (through vue3-openlayers) and take their data from the entity's intialValues. Neither fetches geometry by itself.

The examples give each garage two extra metadata keys:

KeyValue
gps_coordinates{ "latitude": 51.05, "longitude": 3.72 }
map_locationthe area the garage serves, as WKT in EPSG:4326: POLYGON((3.70 51.04, ...))

Map types ​

MapTypesDrawsmapElementView mode
wktMapWKT geometries: points, lines, polygonsyesyes
heatMapweighted points as a heat mapyesyes
pointsMap{latitude, longitude} points, optionally clusteredno, renders an empty boxyes

mapElement on a detail page ​

A garage's page shows the area it serves:

graphql
mapElement {
  label(input: "element-labels.service-area")
  isCollapsed(input: false)
  type(input: wktMap)
  center(input: "gps_coordinates")
  area: metaData {
    key(input: "map_location")
  }
}

The entity query must also select both keys in intialValues:

graphql
intialValues {
  gps_coordinates: keyValue(key: "gps_coordinates", source: metadata)
  map_location: keyValue(key: "map_location", source: metadata)
}
FieldEffect
label, isCollapsedHeader label (an i18n key) and starting state
typeA MapTypes value. Required: leaving it out is a GraphQL error
centerThe intialValues key holding the center, not coordinates. See below for its shape
metaDataOne aliased metaData per geometry source; its key is an intialValues key holding WKT in EPSG:4326
config[{ key, value }] pairs; see the table below. A key given twice: the last wins
geoJsonFeatureHeat map data; see Heat maps
mapFeatureMetadata, mapMetadataNot used here; mapFeatureMetadata belongs on the list fragment, see Popups. mapMetadata is never read

A wktMap element only renders once there is WKT data or a center.

The shape of center depends on the map

The center key's value must be { latitude, longitude } for a wktMap and a [lon, lat] array for a heatMap. In satellite view a wktMap puts a pin at the center; in standard view it doesn't.

Element config keys ​

KeyValue
mapViewsatellite (default, Esri World Imagery) or standard (OpenStreetMap)
mapModedefault, or heatMode: every WKT feature is coloured by the number in keyOfHeatValue (≤ 4 green, ≤ 6 orange, above red)
keyOfHeatValuethe intialValues key used by heatMode
zoom, blur, radiusheat map only
overlayWkta toggle button that draws related geometries over the map, see below

overlayWkt adds a button that fetches up to 1000 other entities and draws their WKT in orange. To show the customers' addresses around a garage:

graphql
config(input: [{
  key: "overlayWkt"
  value: {
    query: "GetCustomersWkt"
    filterQuery: "GetCustomersOfGarageFilters"
    entityType: "customer"
    wktKey: "map_location"
    label: "element-labels.show-customers"
    hideLabel: "element-labels.hide-customers"
  }
}]) {
  key
  value
}

filterQuery is a query document that returns the type's advancedFilters, built with the page's entity as parent. query returns Entities { results { id intialValues { <wktKey> } } }.

The map view mode ​

A list of garages gets a map toggle when the garage fragment allows the map view mode:

graphql
allowedViewModes {
  viewModes(input: [
    { viewMode: ViewModesList }
    {
      viewMode: ViewModesMap
      config: [
        { key: "mapType", value: pointsMap }
        { key: "mapView", value: standard }
        { key: "pointsConfig", value: { keyToExtractCoordinates: "gps_coordinates", clustering: true } }
      ]
    }
  ]) {
    ...viewModes
  }
}

The configuration is read from the first entity in the list. A list that mixes types uses whatever that entity carries.

KeyValue
mapTypeRequired. wktMap, heatMap or pointsMap
mapView, mapMode, keyOfHeatValueas on the element
pointsConfig{ keyToExtractCoordinates, clustering }: the intialValues key holding {latitude, longitude}, and whether to cluster nearby points
useFiltersPanning filters the list to the visible area. Needs a client GetGeoFilterForMap query; the base one returns nothing
bucketUntilZoomBelow this zoom level, the backend returns buckets, drawn as numbered circles. Clicking one zooms in
paginationLimitEntities fetched for the map. Default: 1000 for wktMap and pointsMap, all for heatMap. Leaving the map resets it to 20
center[lat, lon]. Otherwise the first entity's gps_coordinates
zoom, blur, radiusheat map only

For wktMap the geometry key is fixed: the view mode reads map_location. Buckets read bucket_count and bucket_location ([lon, lat]).

Popups ​

Clicking a feature on a wktMap or heatMap opens a popup with a few fields of the clicked entity and an "open in other tab" link. The fields come from a mapElement on the list fragment of the type, outside entityView:

graphql
fragment minimalGarage on Garage {
  mapElement {
    mapFeatureMetadata {
      name: metaData {
        label(input: "metadata.labels.name")
        key(input: "name")
      }
      phone: metaData {
        label(input: "metadata.labels.phone")
        key(input: "phone")
      }
    }
  }
  # ...
}

The client resolver must pass mapElement through

The type's resolver in the client needs mapElement: simpleReturn. Without it the field resolves to null and the popup stays empty, with no error.

Heat maps ​

A heatMap element draws the weighted points of its parent entity: mapElement.geoJsonFeature on the entity, or the mapElement in the first column of its entityView.

graphql
geoJsonFeature {
  value(
    id: { key: "id", source: root }
    coordinates: { key: "location", source: metadata }
    weight: { key: "visits", source: metadata, minimalValue: 5 }
  )
}

coordinates must be [lon, lat] in EPSG:4326; the resolver reprojects them. The weight is the value divided by 100, raised to minimalValue first. The source can be root, metadata or location; relations throws.

The pieces ​

FileRepoRole
src/components/entityElements/EntityElementMapViewer.vueelody-pwamapElement
src/components/library/view-modes/ViewModesMap.vueelody-pwathe map view mode
src/components/maps/WktMap.vueelody-pwaWKT map, popups, buckets
src/components/maps/HeatMap.vueelody-pwaheat map
src/components/maps/PointMap.vueelody-pwapoints and clustering
src/composables/useMaps.tselody-pwaconfig flattening, WKT parsing, heat data
src/composables/useMapCenter.tselody-pwaresolving center
src/composables/useMapOverlay.tselody-pwaoverlayWkt
baseModule/baseResolver.tselody-base-graphqlMapElement and geoJsonFeature resolvers

Powered by Elody - Open Source Semantic Data Platform