Another Enhanced TOC/Legend Widget

3141
37
03-28-2011 01:05 AM
ZillaPlace
New Contributor
Hi guys,

I don't like an idea of separating TOC and legend. Maybe I am an old-fashion guy, but I like to have a widget where I could see icons and names, turn on/off layers, tell whether or not a layer is in its display scale range. And it has to handle sublayers because I have a lot of layers with subtypes. It would be cool if I could click a layer and see the layer properties. It doesn't have to show all of them, but just some major pieces. You know, something like the TOC in ArcMap.

And some of my friends are still using 9.3.1 and others have gone to 10. The widget should work for all of them, although I wouldn't mind telling them that it runs faster and more smoothly with 10. The widget should load the legend for a meshup of services hosted on either 10 or 9.3.1.

If you were like me, take a look at this widget. You may like it. It's a beta version developed on FlexViewer 2.2.
Tags (2)
0 Kudos
37 Replies
ErwanCaradec
New Contributor II
Hello zilla,
thanks for the last update.

But, now i've got an error popup when the property button in front of a service is clicked (the buttons in front of groups or layers are ok)
error : Null object reference at :
Legend2.Handlers:DynamicMapDetailHandler/buildMapDespt()
DynamicMapDetailHandler.as at line 71

and i still have the problem whith the checkbox of groups an layers until the checkbox of the service is not checked/unchecked

Erwan
0 Kudos
NathanEnge
Esri Contributor
I'm experiencing an error with a map service that is published as both a feature service and a mapservice when I hit the properties button:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at widgets.Legend2.Handlers::DynamicMapDetailHandler/buildMapDespt()
at widgets.Legend2.Handlers::DynamicMapDetailHandler/buildDetailForm()
at widgets.Legend2.Handlers::DynamicMapDetailHandler/result()
at com.esri.ags.tasks::DetailsTask/handleDetails()
at Function/http://adobe.com/AS3/2006/builtin::call()
at com.esri.ags.tasks::BaseTask/handleResult()
at MethodInfo-1684()
at mx.rpc::Responder/result()
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at DirectHTTPMessageResponder/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

I have the feature service layers excluded in the xml so that only dynamic map services will show up.
All other map services that are not published as feature service will show the properties. any ideas
0 Kudos
ZillaPlace
New Contributor
Hello zilla,
thanks for the last update.

But, now i've got an error popup when the property button in front of a service is clicked (the buttons in front of groups or layers are ok)
error : Null object reference at :
Legend2.Handlers:DynamicMapDetailHandler/buildMapDespt()
DynamicMapDetailHandler.as at line 71

and i still have the problem whith the checkbox of groups an layers until the checkbox of the service is not checked/unchecked

Erwan


Hi Erwan,

The updated code with the 4-15-2011 revision checks the null object reference rather than throw an error. However, I still couldn't get esri sample services and my test ones to produce any null value in either layer or service properties, as your service did. Is it possible for me to test the widget on your services?

As for your question on checkboxes, you need to turn on a service checkbox in order to see any layer from that map service. Turning off a service checkbox will turn off all layers.

  • The service checkbox controls whether the output image from that service will display or not.

  • The layer checkbox controls whether the map service will include that layer in the output image.

Does it make sense to you?
0 Kudos
ZillaPlace
New Contributor
I'm experiencing an error with a map service that is published as both a feature service and a mapservice when I hit the properties button:

I have the feature service layers excluded in the xml so that only dynamic map services will show up.
All other map services that are not published as feature service will show the properties. any ideas


You ran into the same error as Erwen. The updated code with the 4-15-2011 revision checks the null object reference rather than throw an error. However, I still couldn't get esri sample services and my test ones to produce any null value in either layer or service properties, as your service did. Is it possible for me to test the widget on your services?  

I don't understand your second point. Do you want to show the feature service with other regular map services? Can you elaborate it?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Zilla,

   I notice that you do not handle layers that are FeatureLayer and I thought I would share how I deal with them. Maybe you can use this in your code.

else if (layer is FeatureLayer)
    {
     var FeatServId:Number = Number.NaN;
     var msName:String = FeatureLayer(layer).url.replace("FeatureServer","MapServer");
     var x:String = msName.substring(msName.length - 9);
     if(msName.substring(msName.length - 9) != "MapServer")
     {
      httpServ.url = msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json";
      FeatServId = parseInt(msName.substring(msName.lastIndexOf("/")+ 1));
     }else{
      httpServ.url = msName + "/legend?f=json";
     }
     httpServ.resultFormat = "text";
     lname = FeatureLayer(layer).id;
     httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,FeatServId)});
     httpServ.send();
    }
0 Kudos
AlexZhuk
Occasional Contributor III
Zilla,

Thanks for the great widget. It's exactly what I need. I now can get rid of this stupid standard MapSwitcherWidget. I only have one issue with it; I hope it's minor. Your widget works well for me when I'm on a big screen. When I try to test drive my application on a laptop, the bottom of your widget is below the bottom of the browser and there is NO WAY to resize it. Overall the size of the widget's panel looks a little too large to me. Is there a way to make the size user-configurable?

We here appreciate your help!

Alex Zhuk,
San Francisco, CA
0 Kudos
ErwanCaradec
New Contributor II
Plaizilla,
sorry my services are not reachable from the public internet.

* for the null object reference, i tried to compile it myself with the source code that was included in the zip file (they are not anymore included now ?) and then didn't have the error, i tried with the last compiled one and still have the error. Any idea ?
* for the toggle problem, at the initialization, when a group layer is uncheched, in debug mode i saw that the trace of visible layers was updated correctly but not the layers visibility on the map. Then i uncheck and check again the service, and after when the group is toggled it is ok.

Erwan
0 Kudos
EmilyLaMunyon
Occasional Contributor
Hi Plaizilla,
Great widget! I am having some issues getting it to work with my map though. I am using a 9.3 server and my rest service is public, however I am getting an error that reads:
Error: Unable to generate legends: EndpointAddress - URL is not a valid URL ://www.gis.slco.org/wwwrest/services/ public/Weeds/MapServer/

Do you have any insight?

Thanks, Emily.
0 Kudos
DeniseMoore
New Contributor
Hi Emily,

If your URL is printed exactly as you have it in your code, I think you have an extra space before public
HTH,
D
0 Kudos
EmilyLaMunyon
Occasional Contributor
Thanks Denise. After looking at the post, I noticed the space. It is not in my REST url, just a typo in the post. I appreciate your response!
0 Kudos