Updated location to start from selected when edit.

This commit is contained in:
Naida Vatric
2019-12-20 01:02:57 +01:00
parent 55319a54e9
commit cc78e5acd5
2 changed files with 83 additions and 51 deletions

View File

@@ -4,10 +4,11 @@ const getLocation = async (req, res) => {
const title = "Odaberite lokaciju";
const nextStep = req.query.nextStep || "/";
//Check if location data already exists
//Check if location data already exists (active request)
//If it does then get location is called through edit field query
//and map should show already selected location not initial map
let selectedLatLngBounds = 0;
let selectedLatLngBounds = {};
let boundsSelected = false;
const searchRequest = await currentSearchRequest(req);
@@ -18,13 +19,21 @@ const getLocation = async (req, res) => {
const selectedArea = searchRequest.areaToSearch;
const sw = selectedArea.coordinates[0][3];
const ne = selectedArea.coordinates[0][1];
if (sw[0] && ne[0]) {
selectedLatLngBounds = [sw, ne];
selectedLatLngBounds = {
swLat: sw[1],
swLng: sw[0],
neLat: ne[1],
neLng: ne[0]
};
boundsSelected = true;
}
res.render("location", {
nextStep,
title,
boundsSelected,
selectedLatLngBounds
});
};