Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
predihood
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duchateau Fabien
predihood
Commits
8aed8538
Commit
8aed8538
authored
4 years ago
by
Nelly Barret
Browse files
Options
Downloads
Patches
Plain Diff
[M] fixed select in popup
parent
b1268478
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
predihood/static/js/carto.js
+13
-40
13 additions, 40 deletions
predihood/static/js/carto.js
with
13 additions
and
40 deletions
predihood/static/js/carto.js
+
13
−
40
View file @
8aed8538
...
...
@@ -14,6 +14,7 @@ let baseLayers = null; // array of basic layers
let
overlayLayers
=
null
;
// array of overlaying layers
let
osmLayer
=
null
;
// openstreetmap basic layer
let
irisLayer
=
null
;
// layer of displayed IRIS
let
previously_selected_algorithm
=
null
;
/**
...
...
@@ -76,26 +77,27 @@ function resetHighlightAll() {
function
displayPopup
(
e
)
{
alert
(
"
ici
"
)
var
layer
=
e
.
target
;
var
code_iris
=
layer
.
feature
.
properties
.
CODE_IRIS
var
algorithm
=
$
(
"
#selectAlgorithmTooltip option:selected
"
).
val
();
console
.
log
(
algorithm
);
let
selected_algorithm
=
$
(
"
#selectAlgorithmTooltip option:selected
"
).
val
();
let
predictions
=
undefined
;
if
(
algorithm
!==
"
undefined
"
&&
algorithm
!==
undefined
)
{
predictions
=
predict
(
code_iris
,
algorithm
)
if
(
selected_
algorithm
!==
"
undefined
"
&&
selected_
algorithm
!==
undefined
)
{
predictions
=
predict
(
code_iris
,
selected_
algorithm
)
console
.
log
(
predictions
)
}
let
divInformation
=
$
(
"
<div>
"
);
divInformation
.
append
(
"
CODE IRIS :
"
+
layer
.
feature
.
properties
.
CODE_IRIS
).
append
(
$
(
"
<br>
"
))
.
append
(
"
IRIS :
"
+
layer
.
feature
.
properties
.
NOM_IRIS
).
append
(
$
(
"
<br>
"
))
.
append
(
"
COMMUNE :
"
+
layer
.
feature
.
properties
.
NOM_COM
).
append
(
$
(
"
<br>
"
))
.
append
(
$
(
"
<a>
"
)
.
prop
(
"
href
"
,
"
details-iris.html?code_iris='
"
+
layer
.
feature
.
properties
.
CODE_IRIS
+
"
'
"
))
.
prop
(
"
target
"
,
"
_blank
"
)
.
val
(
"
Plus de détails
"
)
let
moreInfosLink
=
$
(
"
<a>
"
);
moreInfosLink
.
prop
(
"
href
"
,
"
details-iris.html?code_iris=
"
+
layer
.
feature
.
properties
.
CODE_IRIS
)
.
prop
(
"
target
"
,
"
_blank
"
)
.
text
(
"
Plus de détails
"
)
.
append
(
$
(
"
<br>
"
));
divInformation
.
append
(
moreInfosLink
);
let
selectAlgorithm
=
$
(
"
<select>
"
)
selectAlgorithm
...
...
@@ -105,50 +107,21 @@ function displayPopup(e) {
for
(
let
algorithm
of
classifiers
)
{
selectAlgorithm
.
append
(
$
(
"
<option>
"
).
prop
(
"
value
"
,
algorithm
).
text
(
algorithm
));
}
if
(
algorithm
!==
"
undefined
"
&&
algorithm
!==
undefined
)
{
selectAlgorithm
.
val
(
algorithm
);
// select the algorithm inside the list
}
previously_selected_algorithm
=
selected_algorithm
;
let
divPredictions
=
$
(
"
<div>
"
).
prop
(
"
id
"
,
"
divPredictions
"
)
if
(
predictions
!==
undefined
)
{
for
(
let
key
in
predictions
)
{
divPredictions
.
append
(
key
+
'
:
'
+
predictions
[
key
][
"
most_frequent
"
]
+
"
(
"
+
predictions
[
key
][
"
count_frequent
"
]
+
"
/7)
"
).
append
(
$
(
'
<br>
'
));
}
}
// let divPredictions = updatePopup(e)
let
messageTooltip
=
divInformation
[
0
].
outerHTML
+
selectAlgorithm
[
0
].
outerHTML
+
divPredictions
[
0
].
outerHTML
;
console
.
log
(
messageTooltip
)
layer
.
bindPopup
(
messageTooltip
)
layer
.
bringToFront
();
layer
.
openPopup
();
$
(
"
#selectAlgorithmTooltip
"
).
val
(
previously_selected_algorithm
);
// must be after binding the popup to be effective
$
(
"
#selectAlgorithmTooltip
"
).
on
(
"
click
"
,
function
()
{
displayPopup
(
e
)})
// update popup (env variables) when click on an algorithm
// $("#selectAlgorithmTooltip").change(function() {
// var layer = e.target;
// var code_iris = layer.feature.properties.CODE_IRIS
// var algorithm = $("#selectAlgorithmTooltip option:selected").text();
// console.log(algorithm)
// let predictions = predict(code_iris, algorithm)
//
// // let messageTooltip = '<div>CODE IRIS : ' + code_iris + '<br/>'
// // messageTooltip += 'IRIS : ' + layer.feature.properties.NOM_IRIS + '<br/>'
// // messageTooltip += 'COMMUNE : ' + layer.feature.properties.NOM_COM + '<br/>'
// // messageTooltip += '<a href="details-iris.html?code_iris='+layer.feature.properties.CODE_IRIS + '" target="_blank">Plus de détails</a></div></br>';
// // var select_algorithm = $("<select>").prop("id", "selectAlgorithmTooltip");
// // select_algorithm.append($("<option>").val("undefined").text("---"));
// // for(let algorithm of classifiers) {
// // select_algorithm.append($("<option>").val(algorithm).text(algorithm))
// // }
// // messageTooltip += select_algorithm[0].outerHTML
// // messageTooltip += "<br/>"
// for(let key in predictions) { $("#divPredictions").append( key+': ' + predictions[key] + '<br/>' )}
// messageTooltip += $("#divPredictions")[0].outerHTML;
// layer._popup.setContent('something else')
// layer.closePopup();
// layer.bringToFront();
// layer.openPopup();
// })
}
function
updatePopup
(
predictions
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment