Skip to content

Commit b0902f8

Browse files
committed
return coords fn added
1 parent e316f66 commit b0902f8

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

controllers/garage.controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ const rendergaragebyloc=async(req,res)=>
130130
.send();
131131
var geometry = geoData.body.features[0].geometry;
132132
geometry.place_name=req.body.location;
133-
res.render("garages/foundgarage",{ body: req.body,by:"Location",geometry:geometry,maptoken: mapBoxToken})
133+
var coords=await garageService.ReturnCoords();
134+
res.render("garages/foundgarage",{ body: req.body,by:"Location",geometry:geometry,maptoken: mapBoxToken,coords:coords})
134135
}
135136
}
136137

services/garage.service.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,23 @@ const DeleteGarage = async (id) => {
3535
}
3636
await Garage.findByIdAndDelete(id);
3737
};
38+
39+
const ReturnCoords=async()=>
40+
{
41+
const garages=await AllGarages();
42+
var coords=[];
43+
for(let garage of garages)
44+
{
45+
coords.push(garage.geometry);
46+
}
47+
return coords;
48+
}
49+
50+
3851
module.exports = {
3952
AddGarage,
4053
FindGarage,
4154
AllGarages,
4255
DeleteGarage,
56+
ReturnCoords
4357
};

views/garages/foundgarage.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<center><h1>Found Garages by <%=by%> near you</h1></center><br>
1515
<div id='map' style="width: auto; height: 350px;"></div>
1616
</div>
17+
<%=coords%>
1718
</body>
1819
</html>
1920
<style>

0 commit comments

Comments
 (0)