72
72
< h3 > Edit GraphQL Query</ h3 >
73
73
< textarea id ="graphqlQuery "> </ textarea >
74
74
< button id ="updateMap "> Update Map</ button >
75
+ < button id ="loadSimpleExample "> Load Simple Example</ button >
76
+ < button id ="loadComplexExample "> Load Complex Example</ button >
75
77
</ div >
76
78
< div id ="map "> </ div >
77
79
@@ -90,19 +92,25 @@ <h3>Edit GraphQL Query</h3>
90
92
{
91
93
locations(limit: 10)
92
94
@pattern(of: "?s a coy:Country", from: "s", to: "s")
93
- @prefix(name: "", iri: "https://schema.coypu.org/global#")
94
95
@prefix(name: "rdfs", iri: "http://www.w3.org/2000/01/rdf-schema#")
95
96
@prefix(name: "geo", iri: "http://www.opengis.net/ont/geosparql#")
96
97
@prefix(name: "geof", iri: "http://www.opengis.net/def/function/geosparql/")
97
98
@prefix(name: "norse", iri: "https://w3id.org/aksw/norse#")
98
- @prefix(name: "afn", iri: "http://jena.apache.org/ARQ/function#")
99
99
@prefix(name: "coy", iri: "https://schema.coypu.org/global#")
100
100
{
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")
106
114
}
107
115
}
108
116
` ;
@@ -165,8 +173,7 @@ <h3>Edit GraphQL Query</h3>
165
173
#}
166
174
*/
167
175
168
- const initialQuery = complexQuery ;
169
-
176
+ const initialQuery = simpleQuery ;
170
177
171
178
172
179
// Initialize the Leaflet map
@@ -204,7 +211,8 @@ <h3>Edit GraphQL Query</h3>
204
211
}
205
212
206
213
// Add data to the map
207
- async function addDataToMap ( query ) {
214
+ async function addDataToMap ( ) {
215
+ const query = document . getElementById ( 'graphqlQuery' ) . value ;
208
216
const locations = await fetchData ( query ) ;
209
217
210
218
// Clear existing map layers
@@ -224,14 +232,26 @@ <h3>Edit GraphQL Query</h3>
224
232
} ) ;
225
233
}
226
234
227
- document . getElementById ( 'graphqlQuery' ) . value = complexQuery ;
235
+ document . getElementById ( 'graphqlQuery' ) . value = initialQuery ;
228
236
229
237
// Event listener for the "Update Map" button
230
238
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 ( ) ;
233
251
} ) ;
234
252
253
+
254
+
235
255
// Load the map data
236
256
addDataToMap ( initialQuery ) ;
237
257
0 commit comments