mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:17:08 +00:00
Request map events from server as GeoJSON
This commit is contained in:
@@ -326,7 +326,7 @@ export default {
|
||||
getEvents (ffn = i => true) {
|
||||
return async (success, error) => {
|
||||
const url = `/project/${this.$route.params.project}/event`;
|
||||
const data = await this.api([url]);
|
||||
const data = await this.api([url, {headers: {"Accept": "application/geo+json"}}]);
|
||||
if (data) {
|
||||
|
||||
function colour(feature) {
|
||||
@@ -344,14 +344,8 @@ export default {
|
||||
return "brown";
|
||||
}
|
||||
|
||||
const features = data.filter(i => i.geometry).filter(ffn).map(i => {
|
||||
const feature = {
|
||||
type: "Feature",
|
||||
geometry: i.geometry,
|
||||
properties: i
|
||||
};
|
||||
const features = data.filter(ffn).map(feature => {
|
||||
feature.properties.colour = colour(feature);
|
||||
delete feature.properties.geometry;
|
||||
return feature;
|
||||
});
|
||||
success(features);
|
||||
@@ -488,8 +482,8 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
layers["Events (QC)"] = L.realtime(this.getEvents(i => i.type == "qc"), eventsOptions());
|
||||
layers["Events (Other)"] = L.realtime(this.getEvents(i => i.type != "qc"), eventsOptions());
|
||||
layers["Events (QC)"] = L.realtime(this.getEvents(i => i.properties.type == "qc"), eventsOptions());
|
||||
layers["Events (Other)"] = L.realtime(this.getEvents(i => i.properties.type != "qc"), eventsOptions());
|
||||
|
||||
layers["Events (Other)"].on('update', function (e) {
|
||||
console.log("Events (Other) update event", e);
|
||||
|
||||
Reference in New Issue
Block a user