Clear Instructions to add map services to Flexviewer 2.0 Please

1743
32
07-31-2010 04:06 AM
IanHamilton
New Contributor
I have been trolling the web for a definitive answer to this problem. I have had like many other starting to use Flexviewer run into the rediculous problem of it not doing what I assume many people want it to do. i.e add you own tiled base map map service to the viewer. Like others I have been unable to do this. I have managed to get a dynamic service to overlay Queensland Australia but no amount of trying the many partial solutions I have found on the forum and web in general have worked. I have ebven meed anlt to get a dynamic service in as the only layer but it does not zoom pan etc. The grey screen of death appears without fail.

Is it the proxy or isn't it?
Do I really have to recompile the viewer to get it to work?
What proxy files could I set up to get it to work?
Where are the instructions to do this?

Please, there is someone out there who knows how to fix this, please let the rest of  in on the secret.
The power of Flexviewer is that you supposedly don't have to be a guru to get tit to work.
But even mortals need the instruction book.

Using the latest flex on XP and IIS


Thanks

Ian
Tags (2)
0 Kudos
32 Replies
RobertScheitlin__GISP
MVP Emeritus
Ian,

  I will attempt to cover the basics and pitfalls of adding map services to the viewer.

Working with tiled (cached) map services, there are many things to consider.

1. All tiled map services have to be in the same projection (WKID) to function together.
2. All Tiled map services have to have the same EXACT cached LODs (Levels of display)

so if you are using one of esri's basemaps that is in WKID 4326 like http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer and you want to use a cached map service of your our with it, than it has to be in the same WKID (4326 aka: GCS_WGS_1984) and have the same tiled schema (LODs)

The reason that they have to have the same WKID is that ArcGIS Server serves up tiles of the map image already produced at a certain scale and thus will not attempt to re-project the image to meet the maps WKID. A Dynamic map service on the other hand, the image is produced on demand and the data is re-projected to the maps WKID and then the image is produced for the requested extent and return to the client.

The LODs having to be identical is due to the fact that once the first map service is added to the map, it sets the available LODs (levels of display) and if a request is made for a scale that is not in the LOD array then the map will use the closest match to that scale requested and show those tiles. What that means is if your map is cached at different LODs and it is not the first map service added to the map than it will never get displayed because it does not contain any tiles in the requested LOD.

So on to the basics of adding a map service to your Flexviewer 2.0 site. Map services are added by add a mapservice element to the config.xml file that you are currently using for your site. You can have multiple config.xml files as demonstrated in the Flexviewer (i.e. config-all.xml, config.xml, config-classic, etc).  The structure of the mapservice element is simple.

label: the name that you want to give the mapservice. This appears in the TOC and is used a the layers ID when calling the layer in actionscript.

type: This is where you specify the map service type (i.e. tiled, dynamic, feature, bing, image). If you do not specify one of these types or misspell one of them that you will be alerted with a message when you run your app.

alpha: 1 being completely visible or opaque, .5 being 50% transparent, etc.

url: This is the fully qualified url of the map service and will end with things like MapServer, FeatureServer.

visible: pretty self explanatory.

autoRefresh: interval at which the mapservice should be refreshed. Value expressed in seconds as this number is multiplied by 1000 for milliseconds.

group: for the classic controller only. This specifies which menu the mapservice will appear in if it is a basemap.

useamf: currently only used for type="feature" to specify if actionscript message format will be used to fast server client communication.

token: For secure services

mode: For type="feature" values are:
    MODE_ON_DEMAND - features are fetched from the server as they are needed.
    MODE_SNAPSHOT - features are fetched from the server based on DefinitionExpression and/or TimeDefinition. When either definition change, the layer updates itself by querying features back from the server. Once the features are fetched to the client, their "visibility" on the map is based on the time and spatial extents of the map. So for example, for a time animation, you can request all features from server, then adjust time extent on Map to only show some of them.

    MODE_SELECTION - only selected features are available on the client side. Usually used in combination with an underlying map service showing the features that can be selected.

icon: For the classic controller only. The icon that will be used in the menu for this basemaplayer.

visiblelayers: A comma delimited list of layer id number that will be visible for this layer (i.e. 0,3,5).

style: Currently only applies to Bing maps. Values are "road", "aerial" or "aerialWithLabels".

key: Currently only applies to Bing maps. See http://www.bingmapsportal.com

culture: Currently only applies to Bing maps. Consult Microsoft documentation about the culture property, including a list of supported cultures.

Hope this clears some things up for you.
0 Kudos
HaroldBostic
Occasional Contributor II
Robert

Where did you get the attribute definitions from?  The developer's guide?  Or from the online docs.  I'm trying to see how far I can get before customizing, but documentation leaves much to be desired.  If I have never worked with the fv 1.3 then this process would be much more difficult.

Like I want to know if there is an WMS base map type or how to switch between config files.  Please point me in the right direction.

Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Harold,

    In the current Beta there is no WMS map service support. To change config files there is two different ways, the quick and easy way and the url way.

The quick and easy way is in the ViewerContainer.mxml change line 50 DEFAULT_WIDGET_CONTAINER_WIDGET:String = "x";

As far as where I found the attributes I followed the code and used Flex's autocomplete to determine property values.
0 Kudos
HaroldBostic
Occasional Contributor II
As always, thanks for the respone, does the url way involve reading in a query string, if it is anything more complicated than that, I'll start another thread.

Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Harold,

   I forgot to explain the url method.

for your development machine:

1. Open the FlexViewers Project properties (right click FlexViewer in the package explorer window and choose properties).

2. Switch to the Rub/Debug Settings page

3. Select the launch configuration in the window (mine is index (2)) and click the edit button

4. Down in the url or path to launch uncheck Use default and add your config parameter there.

5. Apply/Ok that dialog and you are good to go

In your deployment machine you just add this to your url though the hyperlink to get to your site

?config=config.xml
0 Kudos
IanHamilton
New Contributor
Thanks very much Robert, as you say several variables and it seems they all have to be correct.

In my case it started working all of a sudden so I must have stumbled on the solution.

Very nice instructions which I'll have on my wall from now on.

Ian
0 Kudos
StephenLead
Regular Contributor III
Robert,

Thanks very much for posting those instructions.

Steve
0 Kudos
jameshawks
New Contributor III
Thanks Robert! I'm a little disappointed in the esri instructions which currently just say 'add your data in'. That's a little vague.

So question about the confix xml files. Which ones need to get the url to my service? Just config.xml or also config-all.xml, config.xml, config-classic, etc ?

Jim Hawks
NOAA
Office of Coast Survey
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jim,

   By default the config.xml is the one that is used so you would want to modify that one or you could change the default by modifying the VeiwerContainer.mxml DEFAULT_CONFIG_FILE on line 49
0 Kudos