Commit fc0e7818 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 ad6c6fe2 d4bb14e5
...@@ -114,7 +114,7 @@ $("#id_polygon").on('keyup', function (e) { ...@@ -114,7 +114,7 @@ $("#id_polygon").on('keyup', function (e) {
// this function cleans list of available products // this function cleans list of available products
function erase_product_list_globe() { function erase_product_list_globe() {
prevfeature = null; prevfeature = new Map();
var pol_element = document.getElementById('product-list-globe'); var pol_element = document.getElementById('product-list-globe');
while (pol_element.firstChild) { while (pol_element.firstChild) {
pol_element.removeChild(pol_element.firstChild); pol_element.removeChild(pol_element.firstChild);
...@@ -140,21 +140,23 @@ function erase_product_list_cart() { ...@@ -140,21 +140,23 @@ function erase_product_list_cart() {
} }
var prevfeature = null; var prevfeature = new Map();
function drawApiResponse(element) { function drawApiResponse(element) {
var list_globe = document.getElementById('product-list-globe').children;
for (var i=0; i<list_globe.length; i++) {
var listElement = list_globe[i];
listElement.style.textDecoration = 'none';
}
for (var i=0; i<product_list.catalog.length; i++) { for (var i=0; i<product_list.catalog.length; i++) {
var data = product_list.catalog[i]; var data = product_list.catalog[i];
if (data.uuid === element.id.replace("-li", '')) { if (data.uuid === element.id.replace("-li", '')) {
element.style.textDecoration = 'underline';
console.log("footprint:\n", data.product.footprint); console.log("footprint:\n", data.product.footprint);
prevfeature = osmap.addfootprint(data.product.footprint, prevfeature); if (!prevfeature.has(data.uuid)){
element.style.textDecoration = 'underline';
prevfeature.set(data.uuid, osmap.addfootprint(data.product.footprint, prevfeature));
}else{
if (prevfeature.length != 0){
element.style.textDecoration = 'none';
osmap.deletefootprint(prevfeature.get(data.uuid));
prevfeature.delete(data.uuid);
}
}
} }
} }
} }
......
...@@ -121,12 +121,13 @@ OpenStreetMapsClass.prototype.addWKTPolygon = function(wkt) ...@@ -121,12 +121,13 @@ OpenStreetMapsClass.prototype.addWKTPolygon = function(wkt)
document.getElementById("id_polygon").value = wkt; document.getElementById("id_polygon").value = wkt;
} }
OpenStreetMapsClass.prototype.addfootprint = function(wkt, prevFeature) OpenStreetMapsClass.prototype.deletefootprint = function (prevFeature) {
{ if (prevFeature){
if (prevFeature) {
this.vectorLayer.getSource().removeFeature(prevFeature); this.vectorLayer.getSource().removeFeature(prevFeature);
} }
}
OpenStreetMapsClass.prototype.addfootprint = function(wkt, prevFeature){
var format = new ol.format.WKT(); var format = new ol.format.WKT();
var feature = format.readFeature(wkt, { var feature = format.readFeature(wkt, {
...@@ -136,7 +137,7 @@ OpenStreetMapsClass.prototype.addfootprint = function(wkt, prevFeature) ...@@ -136,7 +137,7 @@ OpenStreetMapsClass.prototype.addfootprint = function(wkt, prevFeature)
var style = new ol.style.Style({ var style = new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: '#dc7828', color: getRandomColor(),
width: 1 width: 1
}), }),
fill: new ol.style.Fill({ fill: new ol.style.Fill({
...@@ -263,3 +264,11 @@ OpenStreetMapsClass.prototype.iconStyle = function(url,x,y) ...@@ -263,3 +264,11 @@ OpenStreetMapsClass.prototype.iconStyle = function(url,x,y)
} }
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
\ No newline at end of file
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