Base Map

<BaseMap>
  <Areas data={la_zip_sales} geoId=ZCTA5CE10 areaCol=zip_code value=sales valueFmt=usd/>
  <Points data={la_locations} lat=lat long=long color=#179917/>
</BaseMap>

Overview

The BaseMap component provides a flexible and extensible way to create maps with multiple layers. This component serves as the foundation for AreaMap, PointMap, and BubbleMap.

Within BaseMap, you can add layers using the following components:

  • <Areas/>
  • <Points/>
  • <Bubbles/>

Examples

See the pages for Area Map, Point Map, and Bubble Map for examples specific to those layers. The same options can be applied to the layer components within BaseMap.

Adding Multiple Layers

<BaseMap>
  <Areas 
    data={la_zip_sales}
    areaCol=zip_code
    geoJsonUrl="path/to/your/geoJSON"
    geoId=ZCTA5CE10
    value=sales
    valueFmt=usd
  />
  <Bubbles 
    data={la_locations}
    lat=lat
    long=long
    size=sales
    sizeFmt=usd
    value=sales
    valueFmt=usd
    pointName=point_name
    colorPalette={['yellow','orange','red','darkred']}
    opacity=0.5
  />
</BaseMap>

Custom Basemap

You can add a different basemap by passing in a basemap URL. You can find examples here: https://leaflet-extras.github.io/leaflet-providers/preview/

<BaseMap basemap={`https://tile.openstreetmap.org/{z}/{x}/{y}.png`} attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'>
    <Points 
        data={la_locations}
        lat=lat
        long=long
        value=sales
        valueFmt=usd
        pointName=point_name
        color=violet
        borderColor=black
        borderWidth=2
    />
</BaseMap>

Custom Tooltip

tooltipType=hover

<BaseMap>
    <Areas 
        data={la_zip_sales} 
        areaCol=zip_code
        geoJsonUrl='/geo-json/ca_california_zip_codes_geo_1.min.json'
        geoId=ZCTA5CE10
        value=sales
        valueFmt=usd
        height=250
        tooltip={[
            {id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'},
            {id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
            {id: 'zip_code', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
        ]}
    />
</BaseMap>
<BaseMap>
    <Areas 
        data={la_zip_sales} 
        areaCol=zip_code
        geoJsonUrl='/geo-json/ca_california_zip_codes_geo_1.min.json'
        geoId=ZCTA5CE10
        value=sales
        valueFmt=usd
        height=250
        tooltipType=click
        tooltip={[
            {id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'},
            {id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
            {id: 'link_col', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
        ]}
    />
</BaseMap>

Map Resources

Below are a selection of publically available GeoJSON files that may be useful for mapping. These are from the Natural Earth Data project, and hosted by GeoJSON.xyz.

Country, State, and City Locations

No Results

Base Map Options

URL template for the basemap tiles.
Options:
URL
Attribution text to display on the map (e.g., "© OpenStreetMap contributors").
Options:
text
Optional title displayed above the map.
Options:
text
Starting latitude for the map center.
Options:
latitude coordinate
Starting longitude for the map center.
Options:
longitude coordinate
Initial zoom level of the map.
Options:
number (1 to 18)
Height of the map in pixels.
Options:
pixel value
Default:
300

Layer Options

Areas

Use the <Areas/> component to add an area layer

Required
Query result, referenced using curly braces.
Options:
query name
Required

Path to source geoJSON data from - can be a URL (see Map Resources) or a file in your project.

If the file is in your static directory in the root of your project, reference it as geoJsonUrl="/your_file.geojson"

Options:
URL
Required
Column in the data that specifies the area each row belongs to.
Options:
column name
Required
Property in the GeoJSON that uniquely identifies each feature.
Options:
geoJSON property name
Column that determines the value displayed for each area (used for color scale).
Options:
column name
Format string for displaying the value.
Options:
format string

Points

Use the <Points/> component to add an area layer

Required
Query result, referenced using curly braces.
Options:
query name
Required
Column containing latitude values.
Options:
column name
Required
Column containing longitude values.
Options:
column name
Column that determines the value displayed at each point.
Options:
column name
Format string for displaying the value.
Options:
format string
Column containing the names/labels of the points - by default, this is shown as the title of the tooltip.
Options:
column name

Bubbles

Use the <Bubbles/> component to add an area layer

Required
Query result, referenced using curly braces.
Options:
query name
Required
Column containing latitude values.
Options:
column name
Required
Column containing longitude values.
Options:
column name
Required
Column that determines the size displayed for each point.
Options:
column name
Format string for displaying the size value in tooltips.
Options:
format string
Maximum size of the bubbles.
Options:
number
Default:
20
Column that determines the value displayed at each point (used for color scale).
Options:
column name
Format string for displaying the value.
Options:
format string
Column containing the names/labels of the points - by default, this is shown as the title of the tooltip.
Options:
column name
Specifies the type of pane where the bubbles will be rendered.
Options:
text
Represents the z-index value for the pane, controlling its stacking order relative to other panes (higher values are on top, e.g., z=2 is above z=1).
Options:
number

Common Layer Options

Color Scale

Array of colors used for theming the points or areas based on data.
Options:
array of colors
Minimum value to use for the color scale.
Options:
number
Default:
min of value column
Maximum value to use for the color scale.
Options:
number
Default:
max of value column

Interactivity

Input name. Can be referenced on your page with .
Options:
string

Styling

Color for the points or areas. Use when you want all points or areas to be the same color.
Options:
CSS color value
Width of the border around each point or area.
Options:
pixel value
Color of the border around each point or area.
Options:
CSS color value
Opacity of the points or areas.
Options:
number between 0 and 1

Selected State

When point or area is selected: Color for the points or areas.
Options:
CSS color value
When point or area is selected: Width of the border around each point or area.
Options:
pixel value
When point or area is selected: Color of the border around each point or area.
Options:
CSS color value
When point or area is selected: Opacity of the points or areas.
Options:
number between 0 and 1

Tooltips

Whether to show tooltips.
Options:
Default:
true
Determines whether tooltips are activated by hover or click.
Options:
Default:
hover
CSS class applied to the tooltip content. You can pass Tailwind classes into this prop to custom-style the tooltip.
Options:
CSS class
Configuration for tooltips associated with each area. See below example for format
Options:
array of objects

tooltip example:

tooltip={[
    {id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'},
    {id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
    {id: 'zip_code', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
]}

All options available in tooltip:

  • id: column ID
  • title: custom string to use as title of field
  • fmt: format to use for value
  • showColumnName: whether to show the column name. If false, only the value will be shown
  • contentType: currently can only be "link"
  • linkLabel: text to show for a link when contentType="link"
  • formatColumnTitle: whether to automatically uppercase the first letter of the title. Only applies when title not passed explicitly
  • valueClass: custom Tailwind classes to style the values
  • fieldClass: custom Tailwind classes to style the column names