mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:57: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) {
|
getEvents (ffn = i => true) {
|
||||||
return async (success, error) => {
|
return async (success, error) => {
|
||||||
const url = `/project/${this.$route.params.project}/event`;
|
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) {
|
if (data) {
|
||||||
|
|
||||||
function colour(feature) {
|
function colour(feature) {
|
||||||
@@ -344,14 +344,8 @@ export default {
|
|||||||
return "brown";
|
return "brown";
|
||||||
}
|
}
|
||||||
|
|
||||||
const features = data.filter(i => i.geometry).filter(ffn).map(i => {
|
const features = data.filter(ffn).map(feature => {
|
||||||
const feature = {
|
|
||||||
type: "Feature",
|
|
||||||
geometry: i.geometry,
|
|
||||||
properties: i
|
|
||||||
};
|
|
||||||
feature.properties.colour = colour(feature);
|
feature.properties.colour = colour(feature);
|
||||||
delete feature.properties.geometry;
|
|
||||||
return feature;
|
return feature;
|
||||||
});
|
});
|
||||||
success(features);
|
success(features);
|
||||||
@@ -488,8 +482,8 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
layers["Events (QC)"] = 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.type != "qc"), eventsOptions());
|
layers["Events (Other)"] = L.realtime(this.getEvents(i => i.properties.type != "qc"), eventsOptions());
|
||||||
|
|
||||||
layers["Events (Other)"].on('update', function (e) {
|
layers["Events (Other)"].on('update', function (e) {
|
||||||
console.log("Events (Other) update event", e);
|
console.log("Events (Other) update event", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user