TimeSlider that Displays Range Within TimeExtent

501
6
01-13-2012 07:21 AM
AlexDeVine
New Contributor III
Hello Everyone,

I have created a time-enabled Silverlight WebApp that displays point events over a range of dates from 1520 to 1848. This app includes a time slider and the time period I would like to display on the time slider is 1774 to 1786. I was able to achieve this by modifying the TimeExtent of the map, but, as the app developed I ran into a conflict.

I have maptips pulling data from the attribute fields of the time-aware features which require that the TimeExtent is the full range of dates (from 1520 to 1848). This makes my TimeSlider use the same TimeExtent which reduces its effectiveness.

Anyone know of a way around this? Is there a way to make the TimeSlider function on a subset range within the TimeExtent?

Thank you in advance for any help.

Alex
0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
If you want to get a time slider going from year 1774 to year 1786, set the MinimumValue and MaximumValue of your time slider to these years:
  <esri:TimeSlider  MinumumValue="01/01/1774"  MaximumValue="01/01/1786" ....
0 Kudos
AlexDeVine
New Contributor III
If you want to get a time slider going from year 1774 to year 1786, set the MinimumValue and MaximumValue of your time slider to these years:
  <esri:TimeSlider  MinumumValue="01/01/1774"  MaximumValue="01/01/1786" ....


Hi Dominique. Thank you for your reply.

I have tried that. When I do that, the Maptips I mentioned do not work. The time slider does not recognize that anything outside the min and max value exists. This being the case, the maptips do not show up from 1520 to 1774 or from 1786 to 1848.

TO have both the timeslider and the maptips work, it appears that min and max value of the timesldier must encompass the whole range. This being the case, I am now trying to load multiple intervals into my time slider so that each tic represents 10 years from 1520 to 1774, 30 days from 1774 to 1786 and 1 year from 1786 to 1848.

That is, of course, this post shedded some light on what I am trying to do and you have an idea of how I can have my maptips work and display on 1774-1786 on my timeslider?

Alex
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I probably missed something, but why do you want to get maptips on graphics that the user doesn't see (because out of the current time extent) ?
0 Kudos
AlexDeVine
New Contributor III
Dominique,

Here is my latest iteration of the dev web app.

http://cvh.uga.edu/Smallpox_CVH/SilverlightApplication7TestPage.html

As the legend indicates, the gray markers are pre 1775. Most of these events have no maptip associated with them due to the time slider issue . The few that do have dates that are from 1774/01/01 to 1774/12/31 (within the bounds of the time slider min value and max value). As you can see, I am also using a flare cluster.

The rendered points are generated from a dynamicmapservice while the maptips (with invisible point markers) are generated from a featureservice of the same REST. The timextent of the service is 1520 to 1848.

Does it make sense now, or did I muddy the waters more?

Alex
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I think I eventually got it 🙂

One option is to set the Map TimeExtent by code instead of by binding. So by code you can expand the TimeExtent until 1520.

Hook up an handler to ValueChanged event of your time slider and define your handler this way:
private void MyTimeSlider_ValueChanged(object sender, TimeSlider.ValueChangedEventArgs e)
{
    var startDate = new DateTime(1520, 1, 1);
    var endDate = e.NewValue.End;
    MyMap.TimeExtent = new TimeExtent(startDate, endDate);
}


Another option is to keep a binding with a converter expanding the time extent as above (for MVVM addict).
0 Kudos
AlexDeVine
New Contributor III
I think I eventually got it 🙂

One option is to set the Map TimeExtent by code instead of by binding. So by code you can expand the TimeExtent until 1520.

Hook up an handler to ValueChanged event of your time slider and define your handler this way:
private void MyTimeSlider_ValueChanged(object sender, TimeSlider.ValueChangedEventArgs e)
{
    var startDate = new DateTime(1520, 1, 1);
    var endDate = e.NewValue.End;
    MyMap.TimeExtent = new TimeExtent(startDate, endDate);
}


Another option is to keep a binding with a converter expanding the time extent as above (for MVVM addict).


Thank you for the suggestion and the code, Dominique! I will give that a shot!

What I did as a workaround, in the interim, was open up the time slider max and min value to the full time extent and established multiple interval sets for the date ranges on the timeslider so that the TimeSpan for the intervals is 10 years for 1520-1774 (long period of low event count), 6 months for 1774-1786 (short period with very high event count) and 2 years for 1786-1848 (moderate length period with tapering event counts). It may be clumsy, but, as a novice programmer I am a bit proud of making that work. 🙂 (Code attached)

//Setting up interval for pre 1774-1786 portion of slider
            DateTime myMinDate_Pre = MyTimeSlider.MinimumValue;
            DateTime myMaxDate_Pre = DateTime.Parse("1773-12-31T00:00:00.0000000Z",
                                  CultureInfo.CurrentCulture,
                                  DateTimeStyles.AdjustToUniversal);
            TimeExtent myTimeExtent_Pre = new TimeExtent(myMinDate_Pre, myMaxDate_Pre);
            TimeSpan myTimeSpan_Pre = new TimeSpan(3650, 0, 0, 0);

            //Setting up interval for 1774-1786 portion of slider
            DateTime myMinDate_Range = DateTime.Parse("1774-01-01T00:00:00.0000000Z",
                                  CultureInfo.CurrentCulture,
                                  DateTimeStyles.AdjustToUniversal);
            DateTime myMaxDate_Range = DateTime.Parse("1786-12-31T00:00:00.0000000Z",
                                  CultureInfo.CurrentCulture,
                                  DateTimeStyles.AdjustToUniversal);
            TimeExtent myTimeExtent_Range = new TimeExtent(myMinDate_Range, myMaxDate_Range);
            TimeSpan myTimeSpan_Range = new TimeSpan(180, 0, 0, 0);

            //Setting up interval for post 1774-1786 portion of slider
            DateTime myMinDate_Post = DateTime.Parse("1787-01-01T00:00:00.0000000Z",
                                 CultureInfo.CurrentCulture,
                                 DateTimeStyles.AdjustToUniversal);
            DateTime myMaxDate_Post = DateTime.Parse("1848-12-31T00:00:00.0000000Z",
                                  CultureInfo.CurrentCulture,
                                  DateTimeStyles.AdjustToUniversal);
            TimeExtent myTimeExtent_Post = new TimeExtent(myMinDate_Post, myMaxDate_Post);
            TimeSpan myTimeSpan_Post = new TimeSpan(730, 0, 0, 0);

            //Creating Date Collection
            //Creating IEnumerables
            IEnumerable<DateTime> myIEnum_Pre = null;
            IEnumerable<DateTime> myIEnum_Range = null;
            IEnumerable<DateTime> myIEnum_Post = null;
            IEnumerable<DateTime> myIEnum_Comb = null;

            //Loading Dates into IEnumerables
            myIEnum_Pre = TimeSlider.CreateTimeStopsByTimeInterval(myTimeExtent_Pre, myTimeSpan_Pre);
            myIEnum_Range = TimeSlider.CreateTimeStopsByTimeInterval(myTimeExtent_Range, myTimeSpan_Range);
            myIEnum_Post = TimeSlider.CreateTimeStopsByTimeInterval(myTimeExtent_Post, myTimeSpan_Post);

            //Creating Lists

            List<DateTime> myIntervalList_Pre = new List<DateTime>();
            List<DateTime> myIntervalList_Range = new List<DateTime>();
            List<DateTime> myIntervalList_Post = new List<DateTime>();

            //Converting IEnumerables to Lists

            myIntervalList_Pre = myIEnum_Pre.ToList();
            myIntervalList_Range = myIEnum_Range.ToList();
            myIntervalList_Post = myIEnum_Post.ToList();

            //Combining Lists

            List<DateTime> myIntervalList_Comb = new List<DateTime>();
            myIntervalList_Comb.AddRange(myIntervalList_Pre);
            myIntervalList_Comb.AddRange(myIntervalList_Range);
            myIntervalList_Comb.AddRange(myIntervalList_Post);

            //Convering Combined List to IEnumerable

            myIEnum_Comb = myIntervalList_Comb;

            //Set intervals to show collection
            MyTimeSlider.Intervals = myIEnum_Comb;
0 Kudos