Skip to content

Commit

Permalink
Rebuild timeExtent handling in TimeSliderTocActionDefinitionFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasstein committed Feb 13, 2024
1 parent 8e4e8e2 commit 3430db0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,24 @@ export default class TimeSliderTocActionDefinitionFactory {
},

trigger(tocItem: any) {
const layer = tocItem.ref;
const layer = tocItem.ref as ExtendedLayer;
const controller = timeSliderWidgetController;
const timeSliderProperties = tocItem.ref.timeSlider;

layer.visible = true;

if (layer.timeExtent) {
timeSliderProperties.timeExtent = layer.timeExtent;
timeSliderProperties.fullTimeExtent = layer.timeInfo.fullTimeExtent;
timeSliderProperties.stops = layer.stops;
if (layer.timeExtent && !layer._initialTimeExtent) {
layer._initialTimeExtent = layer.timeExtent;
}
if (layer._lastTimeExtent) {
layer.timeExtent = layer._lastTimeExtent;
timeSliderProperties.timeExtent = layer._lastTimeExtent;
}

const timeSliderWidget = controller.getWidget(timeSliderProperties);
that.timeExtentWatcher = timeSliderWidget.watch("timeExtent", (value) => {
layer.timeExtent = value;
});
this.supressLayerDefaults(layer, timeSliderProperties, timeSliderWidget, controller);
const widget = new (EsriDijit as any)(timeSliderWidget);
const serviceProperties = {
"widgetRole": "layerTimeSliderWidget"
Expand All @@ -93,20 +94,10 @@ export default class TimeSliderTocActionDefinitionFactory {
window?.on("Hide", () => {
that.timeExtentWatcher.remove();
that.timeExtentWatcher = undefined;
layer._lastTimeExtent = layer.timeExtent;
layer.timeExtent = layer._initialTimeExtent;
});
}, that.delay);
},

supressLayerDefaults(layer: ExtendedLayer, props: InjectedReference<Record<string, any>>,
widget: any, controller: TimeSliderWidgetController) {
const timeSliderProperties = controller.getTimeSliderProperties(props);
if (props) {
layer.timeInfo.fullTimeExtent = timeSliderProperties.fullTimeExtent;
layer.stops = timeSliderProperties.stops;
} else if (widget.fullTimeExtent) {
layer.timeInfo.fullTimeExtent = widget.fullTimeExtent;
layer.stops = widget.stops;
}
}
};
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/js/types/ExtendedLayer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
/// limitations under the License.
///

export interface ExtendedLayer extends __esri.Layer {
export interface ExtendedLayer extends __esri.FeatureLayer, __esri.MapImageLayer {
timeInfo: __esri.TimeInfo,
stops: __esri.StopsByDates | __esri.StopsByCount | __esri.StopsByInterval
_initialTimeExtent: __esri.TimeExtent,
_lastTimeExtent: __esri.TimeExtent
}

0 comments on commit 3430db0

Please sign in to comment.