Map widget

The Map widget enables the display of location markers and overlays, providing a dynamic visual representation of geographic data.

Test in Kitchen Sink (opens in a new tab)

Basic Usage

Map requires a dimension to render. Most parent widget will provide a constraint so Map can stretch to fit. When the parent doesn't provide a size, e.g. Column on the vertical axis, you must provide the dimension on that axis. Below we use a FlexColumn which will consume all available vertical space, and in turn gives Map the complete screen height.

View:
  onLoad:
    invokeAPI:
      name: getVenue
 
  body:
    FlexColumn:
      children:
        - Map:
            styles:
              # zoom to fit all markers
              autoZoom: true
              # position the toolbar
              toolbarAlignment: centerLeft
            markers:
              data: ${getVenue.body.location}
              name: location
              location: ${location.lat} ${location.lng}
 
API:
  getVenue:
    uri: https://dummyjson.com/users/1
    method: GET
    onResponse: |-
      // modifying the response to add latitute and longitude
      response.body = {
        "location": [{
          "lat": 37.82159,
          "lng": -121.99996
        }]
      };
 

Using custom markers

Ensemble provides three different ways of customizing markers. You can use any Ensemble icons, use images via URLs or local asset, or define a custom widget to render as a marker.

Using Ensemble icons (Native only)

Ensemble provides Material, FontAwesome, and Remix icons out of the box, and you can use these icons as markers. This is supported on Native platform only (Web is not currently supported). The marker's size can be adjusted using the combination of icon's size, iconPadding (the circular shape around the icon), and padding (the space between the inner circular shape and the pin itself).

View:
  onLoad:
    invokeAPI:
      name: getVenue
 
  body:
    Map:
      styles:
        autoZoom: true
        autoZoomPadding: 100
      markers:
        data: ${getVenue.body.location} 
        name: location
        location: ${location.lat} ${location.lng}
        marker:
          icon:
            name: home_5_line
            library: remix
        selectedMarker:
          icon:
            name: building_2_line
            library: remix
            backgroundColor: blue
                  
 
API:
  getVenue:
    uri: https://dummyjson.com/users/1
    method: GET
    onResponse: |-
      
      response.body = {
        "location": [{
          "lat": 37.82159,
          "lng": -121.99996
        }, {
          "lat": 37.773972,
          "lng": -122.431297
        }]
      };
 
Screenshot

Using Images

You can use images as markers by providing a URL or local asset. To further fine-tune the marker dimension, use resizedWidth or resizedHeight, but avoid using both to maintain the aspect ratio.

Map:
  styles:
    autoZoom: true
    autoZoomPadding: 100
  markers:
    data: ${getVenue.body.location}
    name: location
    location: ${location.lat} ${location.lng}
    marker:
      image:
        source: <URL or local asset>
        resizedWidth: 40

Using custom widget (Native only)

You can use a custom widget to render as a marker. This will only supported on Native platform.

View:
  onLoad:
    invokeAPI:
      name: getVenue
 
  body:
    Map:
      styles:
        autoZoom: true
        autoZoomPadding: 100
      markers:
        data: ${getVenue.body.items} 
        name: item
        location: ${item.lat} ${item.lng}
        marker:
          widget:
            Text:
              text: ${item.city}
              styles:
                padding: 5 10
                borderColor: blue
                backgroundColor: white
                borderRadius: 100
                textStyle:
                  color: black
                  
 
API:
  getVenue:
    uri: https://dummyjson.com/users/1
    method: GET
    onResponse: |-
 
      response.body = {
        "items": [{
          "lat": 37.82159,
          "lng": -121.99996,
          "city": "Danville"
        }, {
          "lat": 37.773972,
          "lng": -122.431297,
          "city": "San Francisco"
 
        }]
      };
Screenshot

Properties

PropertyTypeDescription
stylesobjectSee properties
onCameraMoveactionExecute an Action when the map's bound has changed. The bound data is available using event.data.bounds.<southwest/northeast>.<lat/lng>.
onMapCreatedactionExecute an Action when the map's initial state has been rendered. Note that this may not mean the location and markers (if any) are available yet.
markersobjectSee properties

styles

PropertyTypeDescription
expandedbooleanIf the parent is a Row or Column, this flag will stretch this widget in the appropriate direction. (e.g stretch horizontally for parent of type Row)
markerWidthintegerThe width of each marker. (default 60)
markerHeightintegerThe height of each marker. (default 30)
elevationintegerThe z-coordinate at which to place this material relative to its parent. A non-zero value will show a shadow, with its size relative to the elevation value. Minimum value: 0, Maximum value: 24
elevationShadowColorinteger or stringThe shadow color for the elevation, which can be represented in different formats. It can be specified as a number, a predefined color name, or a hexadecimal value starting with '0x'. transparent black blue white red grey teal amber pink purple yellow green brown cyan indigo lime orange
elevationBorderRadiusstring or integerThe border radius of the widget.This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
alignmentstringThe alignment of the widget relative to its parent. topLeft, topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, bottomRight.
stackPositionTopintegerThe distance of the child's top edge from the top of the stack. This is applicable only for Stack's children.
stackPositionBottomintegerThe distance that the child's bottom edge from the bottom of the stack. This is applicable only for Stack's children.
stackPositionLeftintegerThe distance that the child's left edge from the left of the stack. This is applicable only for Stack's children.
stackPositionRightintegerThe distance that the child's right edge from the right of the stack. This is applicable only for Stack's children.
visibilityTransitionDurationintegerSpecify the duration in seconds when a widget animates between visible and not visible state. Note that setting this value will cause the widget to still occupy the UI space even when it is not visible.
visiblebooleanToggle a widget visibility on/off. Note that an invisible widget will not occupy UI space, unless the visibilityTransitionDuration is specified.
captureWebPointerbooleanApplicable for Web only. When overlaying widgets on top of certain HTML container (e.g. Maps), the mouse click is captured by the HTML container, causing issue interacting with the widget. Use this to capture and maintain the mouse pointer on your widget.
widthintegerThe width property determines the horizontal size of an element, allowing control over its width dimension within the layout.
heightintegerThe height property determines the vertical size of an element, allowing control over its height dimension within the layout.
autoZoombooleanAutomatically zoom the maps to show all the markers (and optionally the current location). Default True.
autoZoomPaddingintegerAdjusts the padding around map elements automatically, ensuring a visually balanced and optimized display within the Maps widget.
locationEnabledbooleanEnables the use of location services, allowing the Maps widget to access and display the user's current location on the map.
includeCurrentLocationInAutoZoombooleanAdjusts the automatic zoom level of the map to include the user's current location within the visible area of the Maps widget.
showToolbarbooleanShow the Map toolbar that contains some convenience controls. You can also turn each individual controls on or off.
showMapTypesButtonbooleanToggle between the different map types. (default true)
showLocationButtonbooleanShow the button that animates to the user's location. (default true)
showZoomButtonsbooleanApplicable on Web only. Show the zoom in/out controls on the map. (default true on Web)
rotateEnabledbooleanEnables the ability to rotate the map view within the Maps widget, allowing users to change the orientation for a customized viewing experience.
scrollEnabledbooleanAllows users to scroll and pan the map within the Maps widget, providing interactive navigation and exploration of the map content.
tiltEnabledbooleanEnables users to adjust the tilt or perspective of the map view for a dynamic and immersive experience.
zoomEnabledbooleanEnables users to zoom in and out on the map within the Maps widget for closer or wider views.
toolbarMargininteger/ stringThe margin around the toolbar. (default 10 on all sides)
toolbarAlignmentstringHow to align the toolbar within the map. (default bottom right). If both positioning (top/bottom/left/right) and alignment are used, positions will be applied first, then alignment within the available constraint. topLeft, topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, bottomRight.
toolbarTopintegerOffset the toolbar from the top edge of the map
toolbarBottomintegerOffset the toolbar from the bottom edge of the map
toolbarLeftintegerOffset the toolbar from the left edge of the map
toolbarRightintegerOffset the toolbar from the right edge of the map
mapTypeStringAllows users to select different map types normal, satellite, terrain, hybrid
initialCameraPositionObjectRepresents the initial camera position on the map. see properties
markerOverlayMaxWidthIntegerSpecifies the maximum width of the marker overlay
markerOverlayMaxHeightIntegerSets the maximum height of the marker overlay
scrollableMarkerOverlayBooleanDetermines if swiping left/right within the overlay will navigate to next/previous marker
dismissibleMarkerOverlayBooleanEnables swiping down to close the overlay
autoSelectBooleanAutomatically selects a marker when the markers are updated

markers

PropertyTypeDescription
dataStringBinds the marker list to the data
nameStringGives a name to the marker
locationobjectSpecifies the geographic coordinates (latitude and longitude) for the Maps widget to display a specific location. see properties
latNumberLatitude coordinate of the marker
lngNumberLongitude coordinate of the marker
markerobjectsee properties
sourcestringThe marker's image asset (URL or local asset)
selectedMarkerobjectsee properties
sourcestringThe marker's image asset when selected (URL or local asset)
overlayWidgetWidgetThe widget to render as an overlay over the maps. Use this to convey more detail info for each marker.
onMarkerTapactionAction to execute when tapping on the marker
onMarkersUpdatedactionAction to execute when the markers have been updated and rendered
markers.location
PropertyTypeDescription
latNumberThe latitude of the marker
lngNumberThe longitude of the marker
markers.marker
PropertyTypeDescription
sourcestringThe marker's image asset. This can come from URL or from local asset.
markers.selectedMarker
PropertyTypeDescription
sourcestringThe marker's image asset when selected. This can come from URL or from local asset.
styles.initialCameraPosition
PropertyTypeDescription
latNumberLatitude coordinate
lngNumberLongitude coordinate
zoomIntegerZoom level