Skip to content
Snippets Groups Projects
Commit e3656e57 authored by Rhys Evans's avatar Rhys Evans
Browse files

added individual location page per trail object

parent 3c75894b
No related branches found
No related tags found
1 merge request!30Resolve "As a user I would like to see a map of the landmarks, so that I can figure out where to go"
......@@ -16,6 +16,7 @@ import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Controller
public class PlacesController {
......@@ -28,7 +29,7 @@ public class PlacesController {
@GetMapping("/checkpoint")
@GetMapping("/checkpoints")
public ModelAndView getLocationPages(){
ModelAndView modelAndView = new ModelAndView("landmarks/locationPage.html");
List<Location> locations = locationRepo.getAllLocation();
......@@ -44,12 +45,40 @@ public class PlacesController {
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
//
// @RequestMapping(value="/location", method= RequestMethod.POST)
// public String sendHtmlFragment(Model map) {
// map.addAttribute("foo", "bar");
// return "checkpoint/checkpoint";
// }
@RequestMapping(value="/location", method= RequestMethod.POST)
public String sendHtmlFragment(Model map) {
map.addAttribute("foo", "bar");
return "checkpoint/checkpoint";
}
@GetMapping("/checkpoints/{location}")
public ModelAndView getResultBySearchKey(@PathVariable String location) {
List<Location> locations = locationRepo.getAllLocation();
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Integer> locationIDIndex = new ArrayList<Integer>();
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
int locationID = 999;
for (int i=0;i<locCoords.size();i++){
locationIDIndex.add(locCoords.get(i).getLocationID()-1);
locationCoordsWorkaround.add(locations.get(locCoords.get(i).getLocationID()-1));
System.out.println(locations.get(locCoords.get(i).getLocationID()-1).getLocationName().replace(' ', '-'));
System.out.println(location);
System.out.println((locations.get(locCoords.get(i).getLocationID() - 1).getLocationName().replace(' ', '-').trim().equals(location)));
if ( (locations.get(locCoords.get(i).getLocationID() - 1).getLocationName().replace(' ', '-').trim().equals(location)) ){
locationID=locCoords.get(i).getLocationID()-1;
}
}
ModelAndView modelAndView= new ModelAndView("fragments/locationPageFrags :: locationSection");
modelAndView.addObject("locCoord", locCoords.get(locationID));
modelAndView.addObject("location", locationCoordsWorkaround.get(locationID));
return modelAndView;
}
//
//
// //GC example
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title th:text="${location.getLocationName()}"></title>
</head>
<body>
<header th:insert="~{/fragments/Templating.html::header}"></header>
<main th:fragment="locationSection" class="locationPageFrag">
<div class="locationFragnment">
</div>
<div >
<p th:text="*{locCoord.getLocationID()}"></p>
<!-- <p th:text="${locations[indexValue.index]}"></p>-->
<H1 th:text="${location.getLocationName()}"> </H1>
<H4 th:text="${location.getLocationPlace()}"> </H4>
<p th:text="${location.getLocationDescription()}"></p>
<iframe
width="600"
height="400"
frameborder="0"
scrolling="yes"
marginheight="0"
marginwidth="0"
th:src="'https://maps.google.com/maps?q='+ ${locCoord.getLocationCoordsLat()} +','+ ${locCoord.getLocationCoordsLong()} +'&hl=en&z=20&amp;output=embed'">
</iframe>
</div>
</main>
<footer th:insert="~{/fragments/Templating.html::footer}"></footer>
</body>
</html>
\ No newline at end of file
......@@ -9,12 +9,10 @@
<main>
<div th:each="coord, indexValue:${locationCoords}">
<p th:text="*{coord.getLocationID()}"></p>
<p th:text="*{coord.getLocationCoordsLat()}"></p>
<p th:text="*{coord.getLocationCoordsLong()}"></p>
<!-- <p th:text="${locations[indexValue.index]}"></p>-->
<H1 th:text="${location[indexValue.index].getLocationName()}"> </H1>
<H4 th:text="${location[indexValue.index].getLocationPlace()}"> </H4>
<p th:text="${location[indexValue.index].getLocationDescription()}"></p>
<iframe
......@@ -26,7 +24,7 @@
marginwidth="0"
th:src="'https://maps.google.com/maps?q='+ ${coord.getLocationCoordsLat()} +','+ ${coord.getLocationCoordsLong()} +'&hl=en&z=20&amp;output=embed'">
</iframe>
<!-- <br />-->
<br />
<!-- <small>-->
<!--&lt;!&ndash; <a&ndash;&gt; //https://maps.google.com/maps?q=51.57623,-3.21910&hl=es&z=14&amp;output=embed">-->
<!-- th:href="https://maps.google.com/maps?q='+{coord.getLocationCoordsLat()}+','+*{coord.getLocationCoordsLong()}+'&hl=es;z=14&amp;output=embed"-->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment