[solved] Mapbox Plugin - how do I bind sources / featurecollections

I am using the mapbox plugin and following the heatmap example from their page here:

i have. added the dataSource like this

return [
  {
    id: "earthquakes",
    type: "geojson",
    data: {
      type: "FeatureCollection",
      features: [
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [-122.4194, 37.7749],
          },
          properties: {
            name: "Location 1",
            description: "This is the first location",
          },
        },
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [-122.4064, 37.7858],
          },
          properties: {
            name: "Location 2",
            description: "This is the second location",
          },
        },
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [-122.4192, 37.7933],
          },
          properties: {
            name: "Location 3",
            description: "This is the third location",
          },
        },
      ],
    },
  },
];

and my layers as such:

[{
    'id': 'earthquakes-heat',
    'sourcelayer': 'waterway-label',
    'type': 'heatmap',
    'source': 'earthquakes',
    'maxzoom': 9,
    'paint': {
        // Increase the heatmap weight based on frequency and property magnitude
        'heatmap-weight': [
            'interpolate',
            ['linear'],
            ['get', 'mag'],
            0,
            0,
            6,
            1
        ],
        // Increase the heatmap color weight weight by zoom level
        // heatmap-intensity is a multiplier on top of heatmap-weight
        'heatmap-intensity': [
            'interpolate',
            ['linear'],
            ['zoom'],
            0,
            1,
            9,
            3
        ],
        // Color ramp for heatmap.  Domain is 0 (low) to 1 (high).
        // Begin color ramp at 0-stop with a 0-transparancy color
        // to create a blur-like effect.
        'heatmap-color': [
            'interpolate',
            ['linear'],
            ['heatmap-density'],
            0,
            'rgba(33,102,172,0)',
            0.2,
            'rgb(103,169,207)',
            0.4,
            'rgb(209,229,240)',
            0.6,
            'rgb(253,219,199)',
            0.8,
            'rgb(239,138,98)',
            1,
            'rgb(178,24,43)'
        ],
        // Adjust the heatmap radius by zoom level
        'heatmap-radius': [
            'interpolate',
            ['linear'],
            ['zoom'],
            0,
            2,
            9,
            20
        ],
        // Transition from heatmap to circle layer by zoom level
        'heatmap-opacity': [
            'interpolate',
            ['linear'],
            ['zoom'],
            7,
            1,
            9,
            0
        ]
    }
}, {
    'id': 'earthquakes-point',
    'sourcelayer': 'waterway-label',
    'type': 'circle',
    'source': 'earthquakes',
    'minzoom': 7,
    'paint': {
        // Size circle radius by earthquake magnitude and zoom level
        'circle-radius': [
            'interpolate',
            ['linear'],
            ['zoom'],
            7,
            ['interpolate', ['linear'], ['get', 'mag'], 1, 1, 6, 4],
            16,
            ['interpolate', ['linear'], ['get', 'mag'], 1, 5, 6, 50]
        ],
        // Color circle by earthquake magnitude
        'circle-color': [
            'interpolate',
            ['linear'],
            ['get', 'mag'],
            1,
            'rgba(33,102,172,0)',
            2,
            'rgb(103,169,207)',
            3,
            'rgb(209,229,240)',
            4,
            'rgb(253,219,199)',
            5,
            'rgb(239,138,98)',
            6,
            'rgb(178,24,43)'
        ],
        'circle-stroke-color': 'white',
        'circle-stroke-width': 1,
        // Transition from heatmap to circle layer by zoom level
        'circle-opacity': [
            'interpolate',
            ['linear'],
            ['zoom'],
            7,
            0,
            8,
            1
        ]
    }
}];

these settings match what is shown in the example. while my map does appear. on the screen, none of. the datapoints appear. on the map as heat blobs or circles. @Quentin are heatmaps possible on the current version of mapjs that weweb uses. and if so are there any examples or am i doing something wrong with my code here?

i do see this in the console:
Screen Shot 2023-06-08 at 11.58.17 AM

[update]

in my source, if i change the type from featurecollection to geojson, the error goes. away but. that doesnt make. sense.

in geoJSON FeatureCollection is an acceptable type. in mapbox, the data they grab from external URL’s comes in with featurecollection as the type. so again, not sure why this doesnt work. hopefully the extra details are helpful.

@aurelie

is this possible?

[update]

i’ve updated. the source to look. like. this and am not getting an error anymore:

[ {
  "id": "a",
  "type": "geojson",
  "data": {
    "type": "FeatureCollection",
    "features": [
{ "type": "Feature", "properties": { "id": "ak16994521", "mag": 2.3, "time": 1507425650893, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -151.5129, 63.1016, 0.0 ] } },
{ "type": "Feature", "properties": { "id": "ak16994519", "mag": 1.7, "time": 1507425289659, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -150.4048, 63.1224, 105.5 ] } },
{ "type": "Feature", "properties": { "id": "ak16994517", "mag": 1.6, "time": 1507424832518, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -151.3597, 63.0781, 0.0 ] } },
{ "type": "Feature", "properties": { "id": "ci38021336", "mag": 1.42, "time": 1507423898710, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -118.497, 34.299667, 7.64 ] } },
{ "type": "Feature", "properties": { "id": "us2000b2nn", "mag": 4.2, "time": 1507422626990, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -87.6901, 12.0623, 46.41 ] } },
{ "type": "Feature", "properties": { "id": "ak16994510", "mag": 1.6, "time": 1507422449194, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -151.5053, 63.0719, 0.0 ] } },
{ "type": "Feature", "properties": { "id": "us2000b2nb", "mag": 4.6, "time": 1507420784440, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -178.4576, -20.2873, 614.26 ] } },
{ "type": "Feature", "properties": { "id": "ak16994298", "mag": 2.4, "time": 1507419370097, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -148.789, 63.1725, 7.5 ] } },
{ "type": "Feature", "properties": { "id": "nc72905861", "mag": 1.39, "time": 1507418785100, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -120.993164, 36.421833, 6.37 ] } },
{ "type": "Feature", "properties": { "id": "ci38021304", "mag": 1.11, "time": 1507418426010, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -117.0155, 33.656333, 12.37 ] } }
    ]
  }
}]

i am no longer getting anyting in the console but i. am not seeing any data. on the map. I would be happy to pay for an hour of someones time to help to get this done if anyone. has experience on this

[update]
i’ve validated the geoJSON object held at data here
Screen Shot 2023-06-08 at 3.56.12 PM
and it seems to be valid though i still see this message on the map

for the team to check. this out on your end: Editor | WeWeb

i have this set up in jsfiddle to use the same datasource object that i am using here and it executes without issue.

Hi,

I’ve copy pasted what you’re using on your jsfiddle to a fresh new mapbox element and it seems to works.

Sorry this element is not straightforward to use, as you see here I’m binding advanced options field to the whole source object.
If you want to bind the source list you can do it like below

Edit : And for the url geojson usage not working, please open a bug ticket so we can prioritize it, explore the issue and try to solve it ! https://support.weweb.io/

Hi @Alexis


I add a new Popup of the mapboxgl
but when close it, it show this
should I raise it as a bug?