Commit 24a3b528 authored by Emmanuel René Huchim Puc's avatar Emmanuel René Huchim Puc

Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev

parents f4f466c6 9e8ef6f7
......@@ -45,7 +45,7 @@ $(document).ready(function () {
var input = document.getElementById('ajax-input');
var dataList = document.getElementById('polygon-list');
$('#ajax-input').on('input', function(e) {
$('#ajax-input').on('keyup', function(e) {
var value = $(this).val();
if (value === '') return;
......@@ -61,7 +61,7 @@ $(document).ready(function () {
},
dataType: 'json',
success: function(data) {
// console.log("DATA: ", data);
// console.log("DATA: ", data.polygonList);
// data.forEach(function(polygon) {
// console.log(polygon);
// // Create a new <option> element
......@@ -72,7 +72,8 @@ $(document).ready(function () {
// dataList.appendChild(option);
// });
$('#ajax-input').autocomplete({
source: data.list
source: data.polygonList,
minLength: 3
});
}
});
......
......@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.shortcuts import render
from catalog.forms import ASFSearchForm
from catalog.models import Polygon
from django.http import HttpResponse, JsonResponse
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from django.urls import reverse
from django.views.generic.base import View
from django.template import loader
......@@ -49,52 +49,6 @@ def productList(request):
return render(request,'productList.html',{}) #"catalog":json[0]})
# #-------------------------------------------------------------------------------
# class SearchSubmitView(View):
# template = 'map.html'
# # template = 'search_submit.html'
# state_parser = {'31': "Yucatán"}
#
# def post(self, request):
# template = loader.get_template(self.template)
# searchValue = request.POST.get('value', '')
#
# ## A simple query for Polygon objects whose name is 'searchValue'
# polygonList = Polygon.objects.filter(name=searchValue)
#
# # data = []
# list = []
# if len(polygonList) > 0:
# for polygon in polygonList:
# polygonInfo = json.loads(polygon.json_info)
#
# # data.append({
# # 'city' : polygon.name,
# # 'state' : self.state_parser[polygonInfo['properties']['CVE_ENT']],
# # 'geojson': polygon.json_info
# # })
# list.append({
# 'city': polygonInfo['properties']['NOMGEO'],
# 'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygonInfo
# })
#
# # context = {
# # 'searchValue': searchValue,
# # 'data': json.dumps(data, ensure_ascii=True)
# # }
#
# data = {
# 'polList': list
# }
#
# # rendered_template = template.render(context, request)
# print("DATA:", data)
# # return HttpResponse(rendered_template, content_type='application/json')
# # return HttpResponse(json.dumps(data, ensure_ascii=True), content_type='application/json')
# return JsonResponse(data)
#-------------------------------------------------------------------------------
class SearchSubmitView(View):
template = 'map.html'
......@@ -108,7 +62,8 @@ class SearchSubmitView(View):
## A simple query for Polygon objects whose name is 'searchValue'
polygonList = Polygon.objects.filter(name=searchValue)
data = []
# data = []
list = []
if len(polygonList) > 0:
for polygon in polygonList:
polygonInfo = json.loads(polygon.json_info)
......@@ -118,21 +73,66 @@ class SearchSubmitView(View):
# 'state' : self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygon.json_info
# })
data.append({
list.append({
'city': polygonInfo['properties']['NOMGEO'],
'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
'geojson': polygonInfo
})
context = {
'searchValue': searchValue,
'data': data
# context = {
# 'searchValue': searchValue,
# 'data': json.dumps(data, ensure_ascii=True)
# }
data = {
'polygonList': list
}
# rendered_template = template.render(context, request)
print("DATA:", data)
return render(request, self.template, context)
# return HttpResponse(rendered_template, content_type='application/json')
# return HttpResponse(json.dumps(data, ensure_ascii=True), content_type='application/json')
return JsonResponse(data)
#-------------------------------------------------------------------------------
# class SearchSubmitView(View):
# template = 'map.html'
# # template = 'search_submit.html'
# state_parser = {'31': "Yucatán"}
#
# def post(self, request):
# template = loader.get_template(self.template)
# searchValue = request.POST.get('value', '')
#
# ## A simple query for Polygon objects whose name is 'searchValue'
# polygonList = Polygon.objects.filter(name=searchValue)
#
# data = []
# if len(polygonList) > 0:
# for polygon in polygonList:
# polygonInfo = json.loads(polygon.json_info)
#
# # data.append({
# # 'city' : polygon.name,
# # 'state' : self.state_parser[polygonInfo['properties']['CVE_ENT']],
# # 'geojson': polygon.json_info
# # })
# data.append({
# 'city': polygonInfo['properties']['NOMGEO'],
# 'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygonInfo
# })
#
# context = {
# 'searchValue': searchValue,
# 'data': data
# }
#
# # rendered_template = template.render(context, request)
# print("DATA:", data)
# # return render(request, self.template, context)
# return HttpResponseRedirect(reverse(map), json.dumps(data, ensure_ascii=True), content_type='application/json')
#-------------------------------------------------------------------------------
......
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