Skip to content

Commit 64644c4

Browse files
committed
MapPlugin in README
1 parent 0dee277 commit 64644c4

File tree

3 files changed

+143
-4
lines changed

3 files changed

+143
-4
lines changed

README.md

Lines changed: 143 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ Here is how it looks like with an image column selected:
3535

3636
![](docs/images/grid-1.png)
3737

38-
The original result set was the following:
38+
The original query was the following: (_All chairmans of EU political groups, with dates of chair and image_, based on the [European Parliament Open Data Portal](https://data.europarl.europa.eu/) datasets)
3939

40-
![](docs/images/grid-4.png)
40+
![](docs/images/grid-3.png)
4141

42-
And the original query was the following: (_All chairmans of EU political groups, with dates of chair and image_, based on the [European Parliament Open Data Portal](https://data.europarl.europa.eu/) datasets)
42+
The original result set was the following - note how each person is duplicated as many times as it was a chairman of a group, with different dates:
43+
44+
![](docs/images/grid-4.png)
4345

44-
![](docs/images/grid-3.png)
4546

4647
Here is a focus on one card, note how the lines corresponding to the same entity have been merged, and how the original query structure is replicated inside the card:
4748

@@ -63,10 +64,148 @@ The Stats plugin can:
6364
![](docs/images/stats-3.png)
6465

6566

67+
### Map plugin
68+
69+
The map plugin:
70+
71+
- Reads columns with a datatype of `geo:wktLiteral`
72+
- Can display Points and Polygons. MultiPolygons are currently not supported
73+
- Displays the original query area coming from the query, if present
74+
- Displays information bubbles by reading all columns from the result set
75+
- Splits polygons into different layers according to their size, so that the user can reduce the number of polygons displayed on the map for clarity
76+
- Can warn users if some lines in the result set do not have their coordinates filled int
77+
78+
Here is an exampe:
79+
80+
![](docs/images/map-1.png)
81+
6682
### Timeline plugin
6783

6884
TODO
6985

86+
### Integration in the page
87+
88+
#### Declaration with YasGUI / YasR
89+
90+
```html
91+
<script type="text/javascript" src="./sparnatural-yasgui-plugins.js"></script>
92+
```
93+
94+
```javascript
95+
Yasr.registerPlugin("TableX",SparnaturalYasguiPlugins.TableX);
96+
Yasr.registerPlugin("Grid",SparnaturalYasguiPlugins.GridPlugin);
97+
Yasr.registerPlugin("Stats",SparnaturalYasguiPlugins.StatsPlugin);
98+
Yasr.registerPlugin("Map",SparnaturalYasguiPlugins.MapPlugin);
99+
100+
delete Yasr.plugins['table'];
101+
delete Yasr.plugins['response'];
102+
const yasr = new Yasr(document.getElementById("yasr"), {
103+
pluginOrder: ["TableX", "Grid", "Stats", "Map"],
104+
defaultPlugin: "TableX",
105+
// disable persistency
106+
persistencyExpire: 0,
107+
maxPersistentResponseSize: 0
108+
});
109+
110+
if(lang == "fr") {
111+
yasr.plugins["Grid"].config.lang = "fr";
112+
yasr.plugins["Stats"].config.lang = "fr";
113+
} else {
114+
yasr.plugins["Grid"].config.lang = "en";
115+
yasr.plugins["Stats"].config.lang = "en";
116+
}
117+
118+
yasr.plugins["TableX"].config.uriHrefAdapter = function(uri) {
119+
if(uri.startsWith("http://fr.dbpedia.org/resource/")) {
120+
return "http://fr.wikipedia.org/wiki/" + uri.substring("http://fr.dbpedia.org/resource/".length);
121+
} else {
122+
return uri;
123+
}
124+
};
125+
126+
// binds Sparnatural with the YasR plugins
127+
bindSparnaturalWithYasrPlugins(sparnatural, yasr);
128+
```
129+
130+
#### Integration with Sparnatural
131+
132+
These plugins require a specific integration with Sparnatural to work. See the [Sparnatural documentation page](https://docs.sparnatural.eu/YasGUI-plugins.html). See the file `sparnatural-bindings.js` in Sparnatural releases.
133+
134+
#### API
135+
136+
These plugins have the following methods:
137+
138+
- `notifyQuery(query)` : expects the Sparnatural query structure, to be notified of the original query structure that was executed.
139+
- `notifyConfig(specProvider)` : expects the Sparnatural configuration, to be aware of the labels and icons of the properties and classes in the config.
140+
141+
#### Configuration
142+
143+
##### TableX plugin
144+
145+
```typescript
146+
export interface PluginConfig {
147+
openIriInNewWindow: boolean;
148+
tableConfig: DataTables.Settings;
149+
includeControls: boolean;
150+
uriHrefAdapter?: (uri: string) => string;
151+
bindingSetAdapter?: (binding: Parser.Binding) => Parser.Binding;
152+
}
153+
```
154+
155+
##### Grid plugin
156+
157+
```typescript
158+
interface PluginConfig {
159+
lang: "en" | "fr";
160+
}
161+
```
162+
163+
##### Stats plugin
164+
165+
```typescript
166+
interface PluginConfig {
167+
lang: "en" | "fr";
168+
}
169+
```
170+
171+
##### Map plugin
172+
173+
```typescript
174+
interface PluginConfig {
175+
baseLayers: Array<{
176+
urlTemplate: string,
177+
options?: L.TileLayerOptions
178+
}>
179+
polylineOptions: L.PolylineOptions | null,
180+
markerOptions: L.MarkerOptions | null,
181+
geoDataType: Array<string>,
182+
polygonDefaultColor: string,
183+
polygonColors: Array<string>,
184+
searchedPolygon: {
185+
fillColor: string,
186+
weight: number,
187+
opacity: number,
188+
color: string,
189+
dashArray: string,
190+
fillOpacity: number
191+
},
192+
mapSize: {
193+
width:string,
194+
height:string
195+
}
196+
setView: {
197+
center: L.LatLngExpression,
198+
zoom?: number,
199+
options?: L.ZoomPanOptions
200+
}
201+
parsingFunction: (literalValue:string)=> Geometry,
202+
L18n: {
203+
warnFindNoCoordinate: string, // use "<count>" pattern to replace with count of results with no geo coordinates
204+
warnFindNoCoordinateBtn: string // Link label for plugin table display on warnig message
205+
}
206+
}
207+
```
208+
70209
## Developers
71210

72211
1. Clone the code

docs/images/grid-4.png

132 KB
Loading

docs/images/map-1.png

189 KB
Loading

0 commit comments

Comments
 (0)