Commit 1ec08d39 authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

method for drawing polygon in map

parent af11e720
......@@ -56,4 +56,5 @@ li.pol {
border-bottom: 1px solid #333333;
border-left: 1px solid #CCCCCC;
margin: 3px;
cursor: pointer;
}
\ No newline at end of file
......@@ -41,6 +41,7 @@
// value: value
// });
var OPT_LIST_IS_HIDDEN = true;
var polygonList;
var makeRequest = function (value) {
var pol_element = document.getElementById('polygon-list');
......@@ -55,13 +56,14 @@ var makeRequest = function (value) {
dataType: 'json',
success: function(data) {
console.log("DATA: ", data.polygonList);
polygonList = data.polygonList;
while (pol_element.firstChild) {
pol_element.removeChild(pol_element.firstChild);
}
data.polygonList.forEach(function (polygon) {
$('#polygon-list').append('<a href="#"><li class="pol">' + polygon.city + ", " + polygon.state + '</li></a>');
$('#polygon-list').append('<li onclick="drawPolygon(this)" id="'+ polygon.id +'" class="pol">' + polygon.city + ", " + polygon.state + '</li>');
});
if (OPT_LIST_IS_HIDDEN) {
......@@ -72,6 +74,13 @@ var makeRequest = function (value) {
});
};
function drawPolygon(element) {
polygonList.forEach(function (pol) {
if (pol.id === element.id) {
console.log(pol);
}
})
}
$('#ajax-input').focus(function () {
console.log('in');
......@@ -83,13 +92,12 @@ $('#ajax-input').focus(function () {
}
}).blur(function () {
if (!OPT_LIST_IS_HIDDEN && $(this).val() != '') {
$('#option-list').hide();
// $('#option-list').hide();
// var pol_element = document.getElementById('polygon-list');
// while (pol_element.firstChild) {
// pol_element.removeChild(pol_element.firstChild);
// }
//
OPT_LIST_IS_HIDDEN = true;
}
});
......
......@@ -90,6 +90,7 @@ class SearchSubmitView(View):
# 'geojson': polygon.json_info
# })
list.append({
'id': str(polygon.id),
'city': polygonInfo['properties']['NOMGEO'],
'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
'geojson': polygonInfo
......
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