Need help with a dataviewjs based on a dataview using the Leaflet plug-in

What I’m trying to do

Trying to create a page in Obsidian that embeds a map based on the data in a column of my dataview, that in turn pulls inline. The dataviewjs part was created by ChatGPT; what do I need to fix in it?

**Use field:** Checkin  
**Row Layout:** Timestamp (UNIX Epoch Seconds) » Venue Name » Venue Address » Latitude,Longitude » Category

```dataview
TABLE
	date(split(Checkin,"»")[0],"X") as Timestamp,
	split(Checkin,"»")[1] as Venue,
	split(Checkin,"»")[2] as Address,
	split(Checkin,"»")[3] as Location,
	split(Checkin,"»")[4] as Category
FROM "Daily Notes"
FLATTEN Checkin
WHERE Checkin
SORT split(Checkin,"»")[0] DESC
const mapContainer = document.createElement('div');
mapContainer.id = 'map';
mapContainer.style.width = '100%';
mapContainer.style.height = '500px';
document.body.appendChild(mapContainer);

const locations = dv.table()
  .where(row => row.Checkin)
  .groupBy(row => row.Location)
  .column('Location')
  .toArray();

const map = L.map('map').setView([0, 0], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);

locations.forEach(location => {
  const [lat, lon] = location.split(',').map(coord => parseFloat(coord.trim()));
  L.marker([lat, lon]).addTo(map)
    .bindPopup(`<b>${location}</b>`);
});

I’m getting the following output:

Evaluation Error: TypeError: dv.table(...).where is not a function
    at eval (eval at <anonymous> (plugin:dataview), <anonymous>:8:4)
    at DataviewInlineApi.eval (plugin:dataview:18638:16)
    at evalInContext (plugin:dataview:18639:7)
    at asyncEvalInContext (plugin:dataview:18649:32)
    at DataviewJSRenderer.render (plugin:dataview:18670:19)
    at DataviewJSRenderer.onload (plugin:dataview:18260:14)
    at e.load (app://obsidian.md/app.js:1:1147632)
    at DataviewApi.executeJs (plugin:dataview:19198:18)
    at DataviewPlugin.dataviewjs (plugin:dataview:20068:18)
    at eval (plugin:dataview:19967:124)

I figured this out on my own:

```dataviewjs
const locations = await dv.query(`
TABLE WITHOUT ID
	split(Checkin,"»")[1] as venue,
	split(split(Checkin,"»")[3],",")[0] as latitude,
	split(split(Checkin,"»")[3],",")[1] as longitude
FROM "Daily Notes"
FLATTEN Checkin
WHERE Checkin
`);
if (locations.successful){
	var text = "```leaflet\nid: swarm-map\ndefaultZoom: 10\nmaxZoom: Infinity\n";
	for (i = 0; i < locations.value.values.length; i++){
		var location = locations.value.values[i];
		text += `marker: default, ${location[1]}, ${location[2]}, [[Places/${location[0]}]]\n`
	}
    text += "```\n"
dv.paragraph(text);
} 

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.