kopia lustrzana https://github.com/OpenDroneMap/WebODM
Synched opacity sliders, minor refactoring
rodzic
99a279e0f1
commit
0fec2c468c
|
@ -49,6 +49,12 @@ class Map extends React.Component {
|
||||||
this.autolayers = null;
|
this.autolayers = null;
|
||||||
|
|
||||||
this.loadImageryLayers = this.loadImageryLayers.bind(this);
|
this.loadImageryLayers = this.loadImageryLayers.bind(this);
|
||||||
|
this.updatePopupFor = this.updatePopupFor.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePopupFor(layer){
|
||||||
|
const popup = layer.getPopup();
|
||||||
|
$('#layerOpacity', popup.getContent()).val(layer.options.opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadImageryLayers(forceAddLayers = false){
|
loadImageryLayers(forceAddLayers = false){
|
||||||
|
@ -118,11 +124,8 @@ class Map extends React.Component {
|
||||||
|
|
||||||
popup.innerHTML = `<div class="title">
|
popup.innerHTML = `<div class="title">
|
||||||
${info.name}
|
${info.name}
|
||||||
<div className="opacity-slider">
|
|
||||||
Opacity: <input id="layerOpacity" type="range" step="1" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="popup-opacity-slider">Opacity: <input id="layerOpacity" type="range" value="${layer.options.opacity}" min="0" max="1" step="0.01" /></div>
|
||||||
<div>Bounds: [${layer.options.bounds.toBBoxString().split(",").join(", ")}]</div>
|
<div>Bounds: [${layer.options.bounds.toBBoxString().split(",").join(", ")}]</div>
|
||||||
<ul class="asset-links">
|
<ul class="asset-links">
|
||||||
${assets.map(asset => {
|
${assets.map(asset => {
|
||||||
|
@ -139,8 +142,8 @@ class Map extends React.Component {
|
||||||
|
|
||||||
layer.bindPopup(popup);
|
layer.bindPopup(popup);
|
||||||
|
|
||||||
$('#layerOpacity', popup).on('change', function() {
|
$('#layerOpacity', popup).on('change input', function() {
|
||||||
layer.setOpacity($('#layerOpacity').val() / 100);
|
layer.setOpacity($('#layerOpacity', popup).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
this.imageryLayers.push(layer);
|
this.imageryLayers.push(layer);
|
||||||
|
@ -227,6 +230,7 @@ class Map extends React.Component {
|
||||||
// Find first tile layer at the selected coordinates
|
// Find first tile layer at the selected coordinates
|
||||||
for (let layer of this.imageryLayers){
|
for (let layer of this.imageryLayers){
|
||||||
if (layer._map && layer.options.bounds.contains(e.latlng)){
|
if (layer._map && layer.options.bounds.contains(e.latlng)){
|
||||||
|
this.updatePopupFor(layer);
|
||||||
layer.openPopup();
|
layer.openPopup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -238,6 +242,7 @@ class Map extends React.Component {
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
this.imageryLayers.forEach(imageryLayer => {
|
this.imageryLayers.forEach(imageryLayer => {
|
||||||
imageryLayer.setOpacity(this.props.opacity / 100);
|
imageryLayer.setOpacity(this.props.opacity / 100);
|
||||||
|
this.updatePopupFor(imageryLayer);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (prevProps.tiles !== this.props.tiles){
|
if (prevProps.tiles !== this.props.tiles){
|
||||||
|
|
|
@ -17,4 +17,8 @@
|
||||||
.leaflet-control-measure.leaflet-control{
|
.leaflet-control-measure.leaflet-control{
|
||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-opacity-slider{
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue