How to determine the geoLevelID when the geographyLevelName is set to auto mode

2877
6
08-12-2011 11:20 AM
PrashanthSukumaran
New Contributor II
Hi,

I am using the thematic mapping sample to enable selection of Standard Geographies instead of the drill down using the Standard Geographies from Tree Endpoint.  This approach is much easier for the user to select adjacent geographies visually when you see them next to each other.

The geographyLevelName is set to auto mode.  I have two questions

1) How do i determine the geoLevelID/FeatureID whenever the map is refreshed?
          i.e, I need US.States , US.CBSA as the map is refreshed.
I see that this value is passed as geoLevelID for every refresh.


2) Can we change or provide custom mapping of the geoLevel <-----> map scale ?
    My desktop screen resolution is 1680 x 1050.   I see pretty decent map on the screen.  As i move further away from the city, the Census Tracks are so big that i can see only 6(few) of them.  In such a case i'd rather see block groups.  Shouldn't the TMLayer.getBestLayer return the blockgroups  instead of the Census Tracks.
0 Kudos
6 Replies
MehakSujan
New Contributor
1) If I am understanding your question correctly, you want to be able to know the best geography layer that should be rendered with the Auto mode for the current map scale. If this is the case, you can add an event listener on your map object for an extent change, and in the associated event handler, you can get the thematic mapping layer object's bestLayer property. This is usually the same as the geographyLayer property except in the case where the thematic layer on the map hasn't updated yet.

2) If you don't like the geography level that is chosen with the Auto option based on the current map scale, you can manually set the geographyLevelName property on the thematic mapping layer to whatever geography level you want. You could add some logic in your code to check whether the map scale falls under your custom scale ranges, and then set the geographyLevelName based on that. However, keep in mind that by manually setting the geographyLevelName to a lower level of geography instead of the one chosen with the Auto option, there is a chance that there might be a peformance degradation in the app. For example, setting the geography level to Block Groups instead of the Census Tracks which is the best layer for the current scale, will cause the thematic mapping layer to take longer to retrieve all the block groups for the current map extent and render on the map.

Hope these answers help you.
0 Kudos
PrashanthSukumaran
New Contributor II
Hi Mehak,

Thanks for your reply.  I completely agree with the reply.  Since thematicmappinglayer is in complete control over the graphics being rendered, i was hoping it to make the correct decisions rather than me having the write the code.

I will write custom code to jump to a lower level if the number of graphics is less then some optimum value keeping in mind not to degrade the performance.

Can you please tell me how i can get hold of the geoLevelID of the layer that is being shown?  I need that to send as input to the CreateStandardGeographies endpoint?
0 Kudos
PrashanthSukumaran
New Contributor II
Hi Mehak,

Found It.

Debugging thematicMappingLayer.geographyLayer

(com.esri.baserver.tasks.stdgeographies::GeographyLayerInfo)#0
  generalizationLevel = 6
  geoLevelID = "US.Counties"
  idField = "ID"
  name = "Counties"
  nameField = "Name"
  scale = 9244648)

Business Analyst Server API for Flex 2.0.1 Reference does not have any reference to this class. The "See also" points to GeographyLevelInfo, which is different. Can someone please update the API reference so it is helpful for others?

Edit:  GeographyLayerInfo is not available to me while compiling. Is this an internal class???
0 Kudos
PrashanthSukumaran
New Contributor II
Anybody else has an idea how to get the geoLevelID?
0 Kudos
MehakSujan
New Contributor
You are right - GeographyLayerInfo is an internal class but you can get most of the properties from the IGeographyLayerInfo interface itself such as the layer name and generalization level. The exception is that currently with the API, you can't get the geoLevelID value directly but as mentioned you can get the layer name using the Name property.

A workaround for this is to get the geography level ID from the layer name by hard coding a one-to-one mapping between the layer name (e.g. States) and the geography level ID (e.g. US.States) using a dictionary object. Just keep in mind that there is a very slight chance that the layer name may potentially change in the future BA Server releases.

States - US.States
Counties - US.Counties
ZIP Codes - US.ZIP5
Census Tracts - US.Tracts
Block Groups - US.BlockGroups

You can also look up these names and corresponding geography level IDs through the GetStandardGeographyLevels task.

Hope this helps.
Thanks.
0 Kudos
PrashanthSukumaran
New Contributor II
Thank you.  I can harcode the mapping for now.  I hope this will be available via the api in the future release.

Best Regards
Prashanth Sukumaran
0 Kudos