Skip to content

Commit

Permalink
fix azimuth calc when updating control position
Browse files Browse the repository at this point in the history
  • Loading branch information
domlysz committed Jul 22, 2020
1 parent a3e47ab commit 0947792
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/opp.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function OPP(providers, theme) {
self.photoMap1.attributionControl.setPrefix('');
self.photoMap2.attributionControl.setPrefix('');


//Create azimuth custom control
self.north = L.control({position: "topright"});
self.north.onAdd = function(map) {
var div = L.DomUtil.create("div", "windrose");
Expand Down Expand Up @@ -653,19 +653,26 @@ function OPP(providers, theme) {
setupSketchButton();

//update azimuth
setAzimuth();

//Fill infos panel
let template = self.activeProvider['infosPanelTemplate'];
let render = Mustache.render(template, self.selectedFeatProps);
$('#infosPanel').html(render);

}

var setAzimuth = function(){
if (!self.selectedMark){
return
}
let azimuth = self.selectedFeatProps['AZIMUTH'];
if (azimuth != undefined) {
$('.windrose').show();
$('.azimuth').css('transform', `rotate(${azimuth}deg)`);
} else {
$('.windrose').hide();
}

//Fill infos panel
let template = self.activeProvider['infosPanelTemplate'];
let render = Mustache.render(template, self.selectedFeatProps);
$('#infosPanel').html(render);

}

var markerClickHandler = function(newMarker){
Expand Down Expand Up @@ -1540,7 +1547,8 @@ function OPP(providers, theme) {
$('#photo1').css('height', '100%');
$('#photo2').css('display', 'none');
$('#widgets2').hide();
self.north.setPosition('topright');
self.north.setPosition('topright'); //because setPosition remove and then recreate the div...
setAzimuth(); //...we need to recompute the angle
updatePhotos();
synchTimeline();
}
Expand Down Expand Up @@ -1577,6 +1585,7 @@ function OPP(providers, theme) {
$('#sketchButton2').detach().insertBefore('#dropDownDate2');
$('#widgets2>*').addClass('alignRight');
self.north.setPosition('bottomright');
setAzimuth();
}
updatePhotos();
synchTimeline();
Expand All @@ -1596,6 +1605,7 @@ function OPP(providers, theme) {
$('#sketchButton2').detach().insertBefore('#dropDownDate2');
$('#widgets2>*').addClass('alignRight');
self.north.setPosition('bottomright');
setAzimuth();
}
updatePhotos();
synchTimeline();
Expand Down

0 comments on commit 0947792

Please sign in to comment.