Skip to content

Custom Map Viz #2

@ChakshuGautam

Description

@ChakshuGautam

A React Component for Rendering Interactive Maps

Requirements

  1. Map focussed on a particular region (view bounds)
  2. Markers
    • Dynamic showing and deleting of markers based on external input
    • Show a marker in the center of the region
    • Clustering based on proximity
    • Icon Color
    • CSS on click
  3. Rerender the map on data change.
  4. Showing a legend
  5. Bounding a map with a GeoJSON. Showing a static color outside the GeoJSON.

Solution

In general, all map solutions have 3 aspects to them

  1. Map Tiles - for example OpenstreetMap, Mapbox, Google, Apple, etc.
  2. Map Library - for example Leaflet. Some solutions include 1 and 2 combined - Mapbox and Google.
  3. Map Config - a domain-driven config that acts as an input to the Map Library. It includes settings, markets, and geo boundaries that allow for the rendering of the map based on user inputs.

The solution proposes OpenstreetMap for the tiles, a react wrapper for leaflet as the map library, and the config below to render the maps. But could be replaced with other alternatives without any changes to other blocks. The thinking behind creating another layer of abstraction over and above the existing one (in react-leaflet) is to write a minimal spec that includes only the relevant APIs. This follows the principle of form follows function.

Any inputs based on the filters are assumed to be part of the preprocessing. This helps decouple the map capabilities from the data sources. It is upon the user of this react component to provide the data in the form of the input config shown below.

Input config

{
  "legend": {
    "display": true,
    "position": "bottom",
    "labels": [
      {
        "boxWidth": 20,
        "fontSize": 10,
        "fontColor": "#000",
        "fontFamily": "sans-serif",
        "fontStyle": "bold",
        "padding": 10,
        "label": "Legend"
      }
    ]
  },
  "bounds": {
    "byGeoJson": [],
    "byBbox": []
  },
  "markers": {
    "shouldClusterMarkers": true,
    "postions": [
      {
        "icon": "",
        "color": "",
        "tooltipCSS": "",
        "tooltip": "",
        "position": [
          20.4,
          94.1
        ]
      }
    ]
  },
  "overlays": [
    {
      "color": "#ff0000",
      "opacity": 0.5,
      "geoJson": []
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions