cmv/cmv-app — pull request #210 by jebu75 (2014-09-16 03:22:41+00:00)
Title: Proposal: Info template manager

I'm throwing this out there as food for thought as I wasn't sure of a better method for sharing code across multiple files. This is an attempt to handle some of the concerns I had during today's discussions and I hope @tmcgee isn't offended by me invading something he was working on.

With this approach, enabling disabling infoTemplates is separated into a separate module and called by publishing to either:
'mapInfoTemplates/enable'
'mapInfoTemplates/disable'

Additionally, enabling/disabling infoTemplates on the map is moved to a separate concern from managing the map click mode. I really like @tmcgee's topic publish/subscribe approach for managing click mode but I was having a hard time getting my head around the overlapping concern of also turning infoTemplates on/off. This approach separates the two concerns.

This new module, InfoTemplateManager, is setup as a property of the Controller during the startup method. 'Plugins' is probably not the best place to put it but I wasn't sure where it should go. It isn't a dijit so putting it there did not seem appropriate.

To maintain compatibility with API versions prior to 3.10, the InfoTemplateManager will attempt to enable/disable infoTemplates by using the setInfoWindowOnClick method if it exists. If not, it will use @tmcgee's approach of storing infoTemplate/infoTemplates objects for each layer in the map. I tweaked slightly to look for either an infoTemplate object or an infoTemplates object.

I updated the viewer config file to include two publicly accessible layers, both with infoTemplates defined directly on the layer and not thru the Indentify config. One is a feature layer and one is a dnyamic layer. They are both from the same map service so it's best to test one or the other off while testing. I also updated the initial extent so that these layers were visible without having to zoom in or find east lansing.