Select to view content in your preferred language

Magnifying glass widget for FlexViewer 2.1

1587
9
12-22-2010 07:10 PM
AbhaySingh
Emerging Contributor
Greetings,

Did anyone had any luck with following widget in FlexViewer 2.1/2.2?

http://resources.esri.com/arcgisserver/apis/flex/index.cfm?fa=codeGalleryDetails&scriptID=16360

I was able to make appropriate changes for 2.1 api but the zoom in magnifying glass does not work at all. Any help is appreciated.
Thanks.
Tags (2)
0 Kudos
9 Replies
ReneRubalcava
Esri Frequent Contributor
I don't have a widget, but I did make a Magnify component for my projects that could pretty easily be turned into a widget.

This is the Skinnable Component
https://gist.github.com/753059

This is the TitleWindow with some methods to pass the MagnifyWindow when you move it around the screen.
https://gist.github.com/753061

It basically accepts your main map as the source map to know the current location of the window on the screen. You add a "Detailed" layer, in my case I use some high resolution imagery we have in-house. You can then add "Operational" layers to view on top of your "Detailed" layer.
All layers have to be Dynamic so that you can zoom in as far as you want.

I'll clean it up and add it to my FlexMapTools library at some point, but pretty busy this time of year.

Hope that helps.
0 Kudos
AbhaySingh
Emerging Contributor
Thanks a lot Rene...that definitely helps!
0 Kudos
MichaelHaggerty
Emerging Contributor
I was able to get this widget working by tweaking which events are passed to the dynamic layer's addEventListener method.  It seems that dynamic layers no longer fire the Event.COMPLETE event, but rather a combination of LayerEvent.LOAD and LayerEvent.UPDATE_END.

Here is how I modified this widget to get it working:

1) I changed all Event.COMPLETE events to LayerEvent.LOAD
2) I added an additional addEventListener method call to capture the LayerEvent.UPDATE_END events in the config method.

Here is a snippet from the config method:

for each(var oLayer:Layer in oMap.layers)
{
 if (oLayer is ArcGISDynamicMapServiceLayer){
  var dyn:ArcGISDynamicMapServiceLayer = oLayer as ArcGISDynamicMapServiceLayer;
  var cLayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(dyn.url);
  cLayer.id = dyn.id;
  cLayer.addEventListener(LayerEvent.LOAD,onLoadDone);
  cLayer.addEventListener(LayerEvent.UPDATE_END,onLoadDone);
  map.addLayer(cLayer);
 } else if (oLayer is ArcGISTiledMapServiceLayer) {
  var tLayer:ArcGISTiledMapServiceLayer = oLayer as ArcGISTiledMapServiceLayer;
  var cLayer2:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(tLayer.url);
  cLayer2.id = tLayer.id;
  cLayer2.imageFormat = "jpg";
  cLayer2.addEventListener(LayerEvent.LOAD,onLoadDone);
  cLayer2.addEventListener(LayerEvent.UPDATE_END,onLoadDone);
  map.addLayer(cLayer2);
 } else if (oLayer is GraphicsLayer) {
  /* var gLayer:GraphicsLayer = deepClone(oLayer) as GraphicsLayer;
  map.addLayer(gLayer); */
 }
}
0 Kudos
AbhaySingh
Emerging Contributor
Thanks a lot Michael .. appreciate the time you took to make the widget work and the explanation and code snippet you provided. Much appreciated....I've just started ArcGIS programming with Flex and I can use all help this community can provide...

Good day.
0 Kudos
AbhaySingh
Emerging Contributor
Hi Michael,

Would you mind attaching the source code of modified widget? I am still getting some exceptions after modifying the code.

Thanks.
Abhay
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Abhay,

   I produced this widget a long time ago as really a proof of concept. It is more of a "All show" and potentially have some memory consumption issues. As the developer I hate to say that you probably don't want to use this on your site for daily use.
0 Kudos
AbhaySingh
Emerging Contributor
Thanks for clarification Robert. I suppose I will use Rene's solution in that case...

Regards
Abhay
0 Kudos
jyotsnajoshi
New Contributor
Hi Michael,

I am currently working on flex Viewer and developing a magnifying galss widget for my application. i was going through the code snippet which you have provided int his thread. could you explain me how you modified this widget and made it workig for your case.
I am new to flex environment.

Thanks for the help in advance.

Regards
jj_178
0 Kudos
MichaelHaggerty
Emerging Contributor
@jj_178 -- I would recommend following Robert's advice above and using Rene's code.  I too have found the magnify widget to be a bit unstable.

@Abhay -- Have you turned Rene's code into a widget that you could share?
0 Kudos