Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeRange on a FeatureLayer doesn't works. #1148

Closed
geocot opened this issue Apr 4, 2019 · 4 comments
Closed

setTimeRange on a FeatureLayer doesn't works. #1148

geocot opened this issue Apr 4, 2019 · 4 comments

Comments

@geocot
Copy link

geocot commented Apr 4, 2019

  • Browser and version: Chrome 73.0.3683.86 and Firefox 66.0.2 (64 bits)

  • Version of Leaflet (L.version):

Latest

  • Version of esri Leaflet (L.esri.VERSION):

master

Steps to reproduce the error:

I'm using the from and to in the featurelayer option and everything work fine. But I'm trying to use the method setTimeRange with the same date that I used for the options and it doesn't work. I got thise error " FeatureManager.js:365 Uncaught TypeError: Cannot read property 'between' of undefined"

I was expecting: To filter my data by using the time range.

Annotation 2019-04-03 201604

@geocot
Copy link
Author

geocot commented Apr 4, 2019

Hi again, I found the "problem". I need to use the "timeField" option when i'm using the method setTimeRange. But when the from and to are used as an options, you don't need to use "timeField" option. If this can help someone.

@jgravois
Copy link
Contributor

jgravois commented Apr 4, 2019

nice debugging!

this happens because calling setTimeRange() requires that we invoke logic internally to filter features that have already been queried from the service and displayed previously to ensure that they are within the new time range.

when you set the constructor option, we only ever fetch features that match the time filter, so we don't need to know the name of the field that stores the information.

all that said, if anyone is keen to make this easier on the next guy or gal in @geocot's shoes, they could insert a console.warn in the block below to let them know that its only possible to manipulate a time filter if a timeField is provided in the constructor.

} else if (this.options.timeField) {
this._timeIndex = new BinarySearchIndex();
}

@patrickarlt
Copy link
Contributor

Since @gavinr added a warning I'm closing this.

@gavinr
Copy link
Contributor

gavinr commented Jul 12, 2019

Thanks for the cleanup @patrickarlt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants