Skip to content

Commit 32eaf40

Browse files
committed
Updated demo
1 parent 1b6cf68 commit 32eaf40

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

docs/demos/leaflet-graphql/index.html

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
<h3>Edit GraphQL Query</h3>
7373
<textarea id="graphqlQuery"></textarea>
7474
<button id="updateMap">Update Map</button>
75+
<button id="loadSimpleExample">Load Simple Example</button>
76+
<button id="loadComplexExample">Load Complex Example</button>
7577
</div>
7678
<div id="map"></div>
7779

@@ -90,19 +92,25 @@ <h3>Edit GraphQL Query</h3>
9092
{
9193
locations(limit: 10)
9294
@pattern(of: "?s a coy:Country", from: "s", to: "s")
93-
@prefix(name: "", iri: "https://schema.coypu.org/global#")
9495
@prefix(name: "rdfs", iri: "http://www.w3.org/2000/01/rdf-schema#")
9596
@prefix(name: "geo", iri: "http://www.opengis.net/ont/geosparql#")
9697
@prefix(name: "geof", iri: "http://www.opengis.net/def/function/geosparql/")
9798
@prefix(name: "norse", iri: "https://w3id.org/aksw/norse#")
98-
@prefix(name: "afn", iri: "http://jena.apache.org/ARQ/function#")
9999
@prefix(name: "coy", iri: "https://schema.coypu.org/global#")
100100
{
101-
label @one @pattern(of: "SELECT ?s ?o { ?s rdfs:label ?o . FILTER(langMatches(lang(?o), 'en')) }", from: "s", to: "o")
102-
geometry @one @pattern(of: """
103-
?s geo:hasGeometry/geo:asWKT ?x .
104-
BIND(STRDT(STR(geof:asGeoJSON(?x)), norse:json) AS ?o)
105-
""", from: "s", to: "o")
101+
label @one
102+
@pattern(of: """
103+
SELECT ?s ?o {
104+
?s rdfs:label ?o .
105+
FILTER(langMatches(lang(?o), 'en'))
106+
}
107+
""", from: "s", to: "o")
108+
109+
geometry @one
110+
@pattern(of: """
111+
?s geo:hasGeometry/geo:asWKT ?x .
112+
BIND(STRDT(STR(geof:asGeoJSON(?x)), norse:json) AS ?o)
113+
""", from: "s", to: "o")
106114
}
107115
}
108116
`;
@@ -165,8 +173,7 @@ <h3>Edit GraphQL Query</h3>
165173
#}
166174
*/
167175

168-
const initialQuery = complexQuery;
169-
176+
const initialQuery = simpleQuery;
170177

171178

172179
// Initialize the Leaflet map
@@ -204,7 +211,8 @@ <h3>Edit GraphQL Query</h3>
204211
}
205212

206213
// Add data to the map
207-
async function addDataToMap(query) {
214+
async function addDataToMap() {
215+
const query = document.getElementById('graphqlQuery').value;
208216
const locations = await fetchData(query);
209217

210218
// Clear existing map layers
@@ -224,14 +232,26 @@ <h3>Edit GraphQL Query</h3>
224232
});
225233
}
226234

227-
document.getElementById('graphqlQuery').value = complexQuery;
235+
document.getElementById('graphqlQuery').value = initialQuery;
228236

229237
// Event listener for the "Update Map" button
230238
document.getElementById('updateMap').addEventListener('click', () => {
231-
const query = document.getElementById('graphqlQuery').value;
232-
addDataToMap(query);
239+
addDataToMap();
240+
});
241+
242+
243+
document.getElementById('loadSimpleExample').addEventListener('click', () => {
244+
document.getElementById('graphqlQuery').value = simpleQuery;
245+
addDataToMap();
246+
});
247+
248+
document.getElementById('loadComplexExample').addEventListener('click', () => {
249+
document.getElementById('graphqlQuery').value = complexQuery;
250+
addDataToMap();
233251
});
234252

253+
254+
235255
// Load the map data
236256
addDataToMap(initialQuery);
237257

0 commit comments

Comments
 (0)