Cannot add data point via new map layer

Hi,

I’ve been trying to add multiple data points as labels on a map layer. I’m using this tomtom tutorial as a guide.

I’m trying one data point at first, writing it directly into the application.

const geoJSON = {
    "type": "Point",
    "geometry": {
        "type": "Circle",
        "coordinates": [
            [-73.94928, 40.71114],
        ]                
    }
};

tomtomMap.on('load', () => {
    tomtomMap.addLayer({
        'id': 'overlay',
        'type': 'circle', 
        'source': {
            'type': 'geojson',
            'data': {
                'type': geoJSON["type"],
                'geometry': geoJSON["geometry"],
            }
        },
        'layout': {},
        'paint': {
            'circle-color': '#db356c',
        }         
    });
}) 

However, I am seeing nothing and no error.

If I do a polygon fill, it works

But as a single POINT, it doesn’t. Please advise.

Do you want to have just a simple pixel drawn? Or a marker?

1 Like

It would be great to have a marker.

So this example should help you:

1 Like

Thank you very much for this. I will try it out right now and let you know the results.
For Tom Tom’s reference, when I tried running the above code again, there was an error message of ‘Uncaught TypeError: Cannot read property ‘0’ of undefined’. The error was being caught by
mapbox-gl.js.

Hi,
Using this code, I am still unable to display the circles. I can show the markers however.
There are no errors.

I tried the Point again.
Instead of [‘data’][‘type’] = ‘Point’,
I used [‘data’][‘type’] = ‘Feature’.

Under [‘geometry’][‘type’], I used ‘Point’ instead of ‘Circle’.

It is now working