Commit 255d3200 authored by Matija Obreza's avatar Matija Obreza
Browse files

Heatmap for Genesys data providers

parent fcf1e123
......@@ -43,10 +43,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@Controller
@Scope("request")
@RequestMapping("/org")
......
......@@ -23,6 +23,7 @@ import org.genesys2.server.model.genesys.Taxonomy;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.TaxonomyService;
import org.genesys2.spring.ResourceNotFoundException;
......@@ -58,6 +59,9 @@ public class WiewsController extends BaseController {
@Autowired
private ContentService contentService;
@Autowired
private GeoService geoService;
@RequestMapping("/")
public String view(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("pagedData", instituteService.list(new PageRequest(page - 1, 50, new Sort("code"))));
......@@ -71,6 +75,13 @@ public class WiewsController extends BaseController {
return "/wiews/index";
}
@RequestMapping("/active/map")
public String viewGenesysMap(ModelMap model) {
Page<FaoInstitute> institutes = instituteService.listActive(new PageRequest(0, 1000));
model.addAttribute("jsonInstitutes", geoService.toJson(institutes.getContent()).toString());
return "/wiews/map";
}
@RequestMapping("/{wiewsCode}")
public String view(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode) {
_logger.debug("Viewing country " + wiewsCode);
......@@ -99,7 +110,7 @@ public class WiewsController extends BaseController {
view(model, wiewsCode);
return "/wiews/edit";
}
@PreAuthorize("hasRole('ADMINISTRATOR')")
@RequestMapping("/{wiewsCode}/update")
public String update(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, @RequestParam("blurp") String blurp) {
......
......@@ -13,6 +13,7 @@
<c:if test="${activeOnly eq true}">
<div class="page-header">
<a href="<c:url value="/wiews/active/map" />"><spring:message code="maps.view-map" /></a>
<a href="<c:url value="/wiews/" />"><spring:message code="faoInstitutes.viewAll" /></a>
</div>
</c:if>
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="faoInstitutes.page.list.title" /></title>
</head>
<body>
<h1>
<spring:message code="faoInstitutes.page.list.title" />
</h1>
<div class="page-header">
<a href="<c:url value="/wiews/active" />"><spring:message code="faoInstitutes.viewActiveOnly" /></a>
</div>
<c:if test="${jsonInstitutes ne null}">
<div class="row" style="">
<div class="col-sm-12">
<div id="map" class="gis-map gis-map-square"><spring:message code="maps.loading-map" /></div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
GoogleMaps.map("${pageContext.response.locale.language}", $("#map"), {
maxZoom: 4,
center: new GoogleMaps.LatLng(0, 0)
}, function(el, map) {
var jsonInstitutes=${jsonInstitutes};
var heatmapData=[];
jsonInstitutes.forEach(function(inst) {
heatmapData.push(new google.maps.LatLng(inst.lat, inst.lng));
});
var heatmap = new google.maps.visualization.HeatmapLayer({
data: heatmapData,
//dissipating: false,
//gradient: [ "transparent", "#FF0000"],
//opacity: 1,
//radius: 3
});
heatmap.setMap(map);
map.fitBounds(GoogleMaps.boundingBox(jsonInstitutes));
});
});
</script>
</c:if>
</body>
</html>
\ No newline at end of file
......@@ -59,7 +59,7 @@ GoogleMaps = {
this.loaded = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?language=' + language + '&v=3&sensor=false&&callback=GoogleMaps.onLoad';
script.src = 'https://maps.googleapis.com/maps/api/js?language=' + language + '&v=3&sensor=false&libraries=visualization&callback=GoogleMaps.onLoad';
document.body.appendChild(script);
} else {
this.onLoad();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment