Adding custom geojson to Geomap

This is working for me using nodejs/express.js for a rest api

app.get("/provinces", (req, res) => {
  let raw = fs.readFileSync(
    "/public/maps/limits_IT_provinces.geojson"
  );
  let geojson = JSON.parse(raw);
  let properties = geojson.features.map((p) => p.properties);

  return res.send(properties);
});

app.get("/provinces/:prov_istat_code_num", (req, res) => {
  let geojson = fs.readFileSync(
    "/public/maps/limits_IT_provinces.geojson"
  );
  let featureCollection = JSON.parse(geojson);
  let prov_istat_code_num = req.params.prov_istat_code_num
  let feature = featureCollection.features.filter(function (feature) {
    return feature.properties.prov_istat_code_num === parseInt(prov_istat_code_num);
  });

  province = {};
  province.type = "FeatureCollection";
  province.bbox = [
    6.62662136853768, 35.493691935511417, 18.52038159909892, 47.091783746462159,
  ];
  province.features = feature;

  return res.send(province);
});

using another geomap plugin: GitHub - orchestracities/map-panel: This plugin extends Grafana Geomap panel with several functionalities: Support for GeoJSON shapes, Support for icons, Support for pop up visualizations of data from a specific point, Multiple layers for the different queries.

1 Like