replace powered by ESRI

8090
70
07-22-2010 02:01 AM
NatashaManzuiga
Regular Contributor
Hi all I perfectly replaced ESRI logo with this script:
http://forums.esri.com/thread.asp?t=287497&f=2421&c=158#912795
Now how can I replace link to esri.com/flex?

Naty
Tags (2)
0 Kudos
70 Replies
deleted-user-rQoEFM5qzbHE
Deactivated User
Here is part of the code. Unfortunately, it is too long to post the whole thing. If you need the part below the end, let me know and I can post the rest. Thanks.

<?xml version="1.0" encoding="utf-8"?>
<!--
     ////////////////////////////////////////////////////////////////////////////////
     //
     // Copyright (c) 2010 ESRI
     //
     // All rights reserved under the copyright laws of the United States.
     // You may freely redistribute and use this software, with or
     // without modification, provided you include the original copyright
     // and use restrictions.  See use restrictions in the file:
     // <install location>/License.txt
     //
     ////////////////////////////////////////////////////////////////////////////////
-->
<s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx"
                      creationComplete="init()"
                      height="100%"
                      skinClass="com.esri.viewer.skins.MapManagerSkin"
                      width="100%">
    <fx:Metadata>
        [ResourceBundle("ViewerStrings")]
    </fx:Metadata> 
 
 

    <fx:Script>
        <![CDATA[
            import com.esri.ags.Graphic;
            import com.esri.ags.Map;
            import com.esri.ags.SpatialReference;
            import com.esri.ags.TimeExtent;
            import com.esri.ags.events.DrawEvent;
            import com.esri.ags.events.ExtentEvent;
            import com.esri.ags.events.FlareEvent;
            import com.esri.ags.events.FlareMouseEvent;
            import com.esri.ags.events.GraphicEvent;
            import com.esri.ags.events.LayerEvent;
            import com.esri.ags.events.MapEvent;
            import com.esri.ags.geometry.Extent;
            import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;
            import com.esri.ags.layers.ArcGISImageServiceLayer;
            import com.esri.ags.layers.ArcGISTiledMapServiceLayer;
            import com.esri.ags.layers.FeatureLayer;
            import com.esri.ags.layers.GraphicsLayer;
            import com.esri.ags.layers.Layer;
            import com.esri.ags.layers.supportClasses.StaticLayer_m_esriLogo;
            import com.esri.ags.layers.supportClasses.StaticLayer_m_globe;
            import com.esri.ags.tools.DrawTool;
            import com.esri.ags.tools.NavigationTool;
            import com.esri.ags.virtualearth.VETiledLayer;
            import com.esri.viewer.AppEvent;
            import com.esri.viewer.BaseWidget;
            import com.esri.viewer.ConfigData;
            import com.esri.viewer.IInfowindowTemplate;
            import com.esri.viewer.ViewerContainer;
            import com.esri.viewer.components.InfoPopup;
            
            import flash.utils.setInterval;
            
            import mx.collections.ArrayCollection;
            import mx.containers.Canvas;
            import mx.controls.Alert;
            import mx.core.UIComponent;
            import mx.events.CloseEvent;
            import mx.resources.ResourceManager;
   import mx.controls.Image;
            
            import spark.components.Group;

            /* skin section */
            [SkinPart(required="false")]
            public var managerView:Group;

            [SkinPart(required="false")]
            public var map:Map;

            [Bindable]
            public var mapLeft:Number = 0;

            [Bindable]
            public var mapRight:Number = 0;

            [Bindable]
            public var mapTop:Number = 0;

            [Bindable]
            public var mapBottom:Number = 0;

            [SkinState("decorated")]
            [SkinState("resized")]
            [SinkState("normal")]

            private var configData:ConfigData;

            private var defaultstatus:String;

            //[SkinPart(required="false")]
            private var infoPopup:InfoPopup;

            private var navTool:NavigationTool;

            private var drawTool:DrawTool;

            private var drawEndFunction:Function;

            private var fullExtent:Extent;

            private var _manManagerSate:String = "resized";

            private var proxyEnabled:Boolean = false;

            private var optLayerTable:Array = new Array()
    
   //[Embed(source="assets/images/NEW_ITRE_LOGO1.png")]
   private var myLogo:Class;
   
   private function changeESRILogo(map:Map):void 
   {
    for(var i:int = 0 ; i < map.numChildren ; i++)
    {
     var component:UIComponent = map.getChildAt(i) as UIComponent;
     if(component.className == "StaticLayer")
     {
      for(var j:int = 0 ; j < component.numChildren ; j++)
      {
       var stComponent:UIComponent = component.getChildAt(j) as UIComponent;
       if(stComponent.className == "Image")
       {
        var img:Image = stComponent as Image;
        if (img.source.toString().indexOf("logo") > 0)
        {
         img.source = myLogo;
         img.addEventListener(MouseEvent.MOUSE_DOWN ,gotoMyURL,false,1000);
         return;
        }
       }
      }
     }
    }
   }
   
   private function gotoMyURL(evt:Event):void
   {
    var myURL:URLRequest = new URLRequest("http://vams.itre.ncsu.edu");
    navigateToURL(myURL);
    evt.stopPropagation();
   }
   
            //init
            private function init():void
            {
                ViewerContainer.addEventListener(AppEvent.CONFIG_LOADED,        config);
                ViewerContainer.addEventListener(AppEvent.SET_MAP_NAVIGATION,   changeNavigationbyMenu);
                ViewerContainer.addEventListener(AppEvent.BASEMAP_SWITCH,       basemapMenuClicked);
                ViewerContainer.addEventListener(AppEvent.SET_MAP_ACTION,       enableMapAction);
                ViewerContainer.addEventListener(AppEvent.SHOW_INFOWINDOW,      widgetShowInfo);
                ViewerContainer.addEventListener(AppEvent.MAP_RESIZE,           resizeMap);
                ViewerContainer.addEventListener(AppEvent.DATA_OPT_LAYERS,      sendOptlayers);
                ViewerContainer.addEventListener(AppEvent.MAP_LAYER_VISIBLE,    changeLayerVisible);
            }

            protected override function partAdded(partName:String, instance:Object):void
            {
                super.partAdded(partName, instance);
                if (instance == map)
                {
                    map.zoomSliderVisible = false;
                    map.addEventListener(MapEvent.LOAD, mapLoadComplete);      
                    
                }
            }
            
            private function setViewerVersion():void
            {
                var contextMenuText:String = ResourceManager.getInstance().getString("ViewerStrings", "contextMenuText");
                var aboutText:String = ResourceManager.getInstance().getString("ViewerStrings", "aboutText");
                var menuItem:ContextMenuItem = new ContextMenuItem(contextMenuText, true, true);
                menuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function(event:ContextMenuEvent):void
                {
                    // save normal labels
                    var buttonWidth:Number = Alert.buttonWidth;
                    var yesLabel:String = Alert.yesLabel;
                    var noLabel:String = Alert.noLabel;
                    // change labels
                    Alert.buttonWidth = 100;
                    Alert.yesLabel = ResourceManager.getInstance().getString("ViewerStrings", "aboutLearnMoreBtn");
                    Alert.noLabel = ResourceManager.getInstance().getString("ViewerStrings", "aboutCloseBtn");
                    Alert.show(aboutText, contextMenuText, Alert.YES | Alert.NO, null, function(event:CloseEvent):void
                    {
                        if (event.detail == Alert.YES)
                        {
                            navigateToURL(new URLRequest("http://resourcesdev.arcgis.com/content/web-apps"));
                        }
                    }, StaticLayer_m_esriLogo, Alert.NO);
                    // restore labels to normal
                    Alert.buttonWidth = buttonWidth;
                    Alert.yesLabel = yesLabel;
                    Alert.noLabel = noLabel;
                });
                map.contextMenu.customItems.push(menuItem);
            }
            //config
            //TODO: Factory or builder pattern need to be used for extendability
            private function config(event:AppEvent):void
            {
                configData = event.data as ConfigData;

                proxyEnabled = configData.proxy.enabled;

                ViewerContainer.dispatchEvent(new AppEvent(AppEvent.MAP_LOADED, map));
                
                var infoContainer:Canvas = new Canvas();
                infoContainer.percentWidth = 100;
                infoContainer.percentHeight = 100;
                infoContainer.horizontalScrollPolicy = "off";
                infoContainer.verticalScrollPolicy = "off";
                managerView.addElement(infoContainer);

                infoPopup = new InfoPopup();
                infoPopup.map = map;
                infoContainer.addChild(infoPopup);

                navTool = new NavigationTool();
                navTool.map = map;

                drawTool = new DrawTool();
                drawTool.map = map;
                drawTool.addEventListener(DrawEvent.DRAW_END, onDrawEnd);

                configMapAttributes();
                configBasemaps();
                
                map.zoomSliderVisible = true;
                
                configOptLayers();
                setViewerVersion();
            }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   Somehow I completely missed that you where attempting this in the new FlexViewer2.0. The code you are try to use is for the SFV 1.x.

Replace this part of the code to work with 2.0
private function changeESRILogo(map:Map):void 
            {
                for (var i:int=0; i<map.staticLayer.numChildren; i++){
                    var component:UIComponent = map.staticLayer.getChildAt(i) as UIComponent;
                    
                    if(component.className == "Image"){
                        var img:Image = component as Image;
                        if (img.source.toString().indexOf("logo") > 0){
                            img.source = myLogo;
                            img.addEventListener(MouseEvent.MOUSE_DOWN ,gotoMyURL,false,1000);
                            return;
                        }
                    }
                }
            }
0 Kudos
deleted-user-rQoEFM5qzbHE
Deactivated User
That fixed the Action Script error. Could this also be the reason I was getting an error in the "Embed" line? Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   Try another image.
0 Kudos
deleted-user-rQoEFM5qzbHE
Deactivated User
That didn't work. One of the errors is that it is a 'call to a possibly undefined method Embed'.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jeremy,

   I just noticed the error. And it is pretty strange...

private var optLayerTable:Array = new Array()


Add a semicolon behind this line and then add another empty line before you do the Embed
0 Kudos
deleted-user-rQoEFM5qzbHE
Deactivated User
That fixed it. Do you know what the problem is? I noticed earlier that there wasn't a semi-colon after that line and thought that I may have accidentally deleted. But, I looked at the original code and it wasn't there. Strange. I appreciate all your help.
0 Kudos
JoshuaCoates
Deactivated User
I guess I am having the same issues as Jeremy. Except it is not giving me any errors, it just doesnt work. I have my xml exactly as you have said and i still get "Powered by ESRI" and get linked to the ESRI webpage. Is there something that needs to be done anywehere besides in the MapManager.mxml file?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Joshua,

   Where are you calling the changeESRILogo function from?

Try adding it to

protected override function partAdded(partName:String, instance:Object):void
            {
                super.partAdded(partName, instance);
                if (instance == map)
                {
                    map.zoomSliderVisible = false;
                    map.addEventListener(MapEvent.LOAD, mapLoadComplete);      
                    changeESRILogo(map);
                }
            }
0 Kudos
JoshuaCoates
Deactivated User
I have done that. Also, should I copy and paste exactly as you have the changes earlier in the post? In other words...do spaces matter? Can u tell me how to add code boxes to insert my code to show you how mine looks?! Thanks for all your help!
0 Kudos