From d793ab7ef3c8f929395d8ca282fb0e897d7e0c42 Mon Sep 17 00:00:00 2001 From: JustineFricou Date: Thu, 25 Apr 2024 17:17:48 +0200 Subject: [PATCH] Automating the geojson generation in the view --- geotrek/core/static/core/multipath.js | 4 ++-- geotrek/core/views.py | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/geotrek/core/static/core/multipath.js b/geotrek/core/static/core/multipath.js index 46afac820e..e778c8979b 100644 --- a/geotrek/core/static/core/multipath.js +++ b/geotrek/core/static/core/multipath.js @@ -533,10 +533,10 @@ L.Handler.MultiPath = L.Handler.extend({ var test_computed_path = { 'computed_paths': computed_paths, - 'geojson': data.geojson, + 'geojson': data, } - console.log("geojson", data.geojson/* , "trek", data.trek */) + console.log("geojson", data/* , "trek", data.trek */) // var mainmap = window.maps[0] // mainmap.addLayers diff --git a/geotrek/core/views.py b/geotrek/core/views.py index 1540b5621d..f3fd09f0f8 100644 --- a/geotrek/core/views.py +++ b/geotrek/core/views.py @@ -825,13 +825,5 @@ def post(self, request): merged_line_string = self.merge_line_strings(line_strings) merged_line_string.transform(settings.API_SRID) - # TODO: use GEOSGeometry.geojson (LineString?) - geojson = merged_line_string.geojson - print(geojson, type(geojson)) - - return JsonResponse({ - 'geojson': { - 'type': 'LineString', - 'coordinates': merged_line_string.coords, - }, - }) + geojson = json.loads(merged_line_string.geojson) + return JsonResponse(geojson)