-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
make identify listen for new layer contol layer adds #648
Conversation
The restructure is good and makes sense. I'd prefer to keep the topics separate. The separate topic makes more sense to me because of the situation when there is no layerControl included in the application. Perhaps the layerControl could optionally publish the identify topic when layers are added? Curious if this is only relevant to dynamic layers? For feature layers, the layer's infoTemplate config would (or should) handle the identify. For that matter, the existence of an infoTemplates array maybe the appropriate trigger for the layerControl to publish the identify topic? Haven't studied the flow of this. Just thinking out loud to myself. |
It didn't look like the identify worked automatically on feature layers either. The layer.infoTemplate property was undefined. For the label layer example I linked, I needed to publish the topic in order for identify to work correctly. |
fd83e04
to
1d43481
Compare
Not sure what happened in the build, but its updated. |
I am not sure why the travis CI exited with this error |
thanks @DavidSpriggs at least now @roemhildtg knows what needs to be addressed. |
1356e67
to
4c2a037
Compare
@roemhildtg want to follow up regarding your comment:
When I use the DnD widget to add a csv or a kml file, the graphics on the resulting Feature Layer can be identified. This is with or without the Identify widget. That widget creates a generic infoTemplate for the feature layer. In your layer label example, there is no infoTemplate in the layerOptions when the feature layer is added to the map. Are you doing that elsewhere? |
@tmcgee, nope I wasn't doing that anywhere. I guess I hadn't looked into it enough, it looks like its as simple as adding this to the layer options?
Edit:It looks like this is the result of adding an empty info template: So the approach to use identify widget to create the infotemplate seems like a more useful method. Thoughts? |
@roemhildtg The simple template you show is the easiest way. You can also provide title, description, fieldInfos, mediaInfos, etc in the infoTemplate as the feature layer is added to the map. Bottom line is there are several ways to accomplish this and being able to mix and match multiple approaches is always good. We are not forcing any dependence on the Identify widget since a feature layer can be identified without it. One reason I thought about for considering including the feature layer's info template in identify.js is to use the new custom formatters though I don't think those work for feature layers in our current implementation. That is worth including in the discussion of #650 |
Another enhancement that comes to mind is for the Identify widget to listen to the EDIT: Hmmm. Maybe this listener is a better approach than using a topic? Thoughts? |
Here's a use case I'd like to discuss. I have a widget that creates feature layers based off of dynamic layers. I'd like to configure the identify for each layer that gets added, but I don't want to duplicate the configure-ability (is that a word?) of the identify widget so I'd rather just let the identify widget create the infotemplate. Either the |
Yes, the identify widget should use the existing infoTemplate if it exists or create a default one from the fields in the layer/sublayer. Unless I am misunderstanding, I'm not sure that any of this addresses your desire for feature layers and dynamic layers to use the same infoTemplate defined only once. Maybe that isn't what you are asking. Each feature layer would be required to have a unique layer id when added to the map and so the index into the identify widget's infoTemplates for one feature layer would not be the same as the dynamic layer or another feature layer. So whether you define the infoTemplate directly in the feature layer or in the identify.js, each one must be separate. |
Will merge this as is. A topic to explicitly add a layer is good. A listener for the |
@tmcgee This addresses my use case because I can create an info template in my identify config, with the other info templates. Its nice to have that all in one place. In addition, I don't want to duplicate the functionality that the Identify widget provides. Lets say my dynamic layer is with var assets12 = {
fieldInfos: [],
//other stuff
}
assets: {
12: assets12
},
assets_12: {
12: assets12
} and all of my identify popup info is stored in one place. |
Moved the layerinfos init code into its own function
initLayerInfos
so we can call this when the topic is published that adds new layers to the layer control.One example of using this would be in a custom layer generating widget:
I realize this is using a layerControl topic but it makes more sense to use the existing topic than register a new one just for identify widget. It seems silly to have any widget that adds a layer publish two topics (or more) if we're just adding a new layer to the app.
Perhaps we should make a more generic layer adding topic.