Reading-eScience-Centre / leaflet-coverage

A Leaflet plugin for visualizing coverages
https://covjson.org/playground/
Other
9 stars 6 forks source link

Issue loading PointSeries data #14

Open webb-ben opened 3 months ago

webb-ben commented 3 months ago

I am having trouble using leaflet coverage to map covjson of a point series. I am getting the error:

Uncaught (in promise) Error: No collection layer class found for domainType=https://covjson.org/def/domainTypes#PointSeries
    at Object.S [as dataLayer] (kdTree.js:345:26)
    at cube?f=html&bbox=-105.957642,39.576056,-104.820557,40.384213&parameter-name=00010:121:25
    at Map.forEach (<anonymous>)
    at cube?f=html&bbox=-105.957642,39.576056,-104.820557,40.384213&parameter-name=00010:120:22

I see PointSeries in the list of valid constants, am am even able to get my json to work on https://covjson.org/playground/. I am not able to get it using this javascript:


var map = L.map('items-map').setView([45, -75], 5);
map.addLayer(new L.TileLayer(
    'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', {
        maxZoom: 18,
        attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia maps</a> | Map data &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
    }
));

var layers = L.control.layers(null, null, {collapsed: false}).addTo(map)
CovJSON.read(JSON.parse(),
  cov.parameters.forEach((p) => {
      var layer = C.dataLayer(cov, {parameter: p.key})
        .on('afterAdd', function () {
          C.legend(layer).addTo(map)
          map.fitBounds(layer.getBounds())
        });
      layers.addOverlay(layer, p.observedProperty.label?.en)
      map.setZoom(5)
  })

)

map.on('click', function (e) {
  new C.DraggableValuePopup({
    layers: [layer]
  }).setLatLng(e.latlng).openOn(map)
})

Example CoverageJSON:

https://gist.github.com/ksonda/532dab3c8a6b4dc41d7597842f7efa0a/

Can provide more examples if desired