Select to view content in your preferred language

use url to jump to an exten in 1.3 viewer?

1045
5
04-26-2011 12:17 AM
DanielLewis
Emerging Contributor
Is it possible (or can a modification be made) to have the 1.3 viewer jump/display a desired extent (and also enable disable specific layers) from a given url (so a person could e-mail a link to another person)?

example:  https://webviewer.com/flex/index.html?x=1111111&y=2222222&layer1=1&layer2=0

Thanks,

Wayne
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   Here is a link to some info on what you are looking to do. You will have to extend any examples of what you find to met your specific needs.

http://forums.esri.com/Thread.asp?c=158&f=2421&t=266031&mc=10.
0 Kudos
DanielLewis
Emerging Contributor
Daniel,

   Here is a link to some info on what you are looking to do. You will have to extend any examples of what you find to met your specific needs.

http://forums.esri.com/Thread.asp?c=158&f=2421&t=266031&mc=10.


Thank you, that's a great help.
0 Kudos
DanielLewis
Emerging Contributor
Robert,

Thanks again. 

I'm now trying to create a widget that shows the URL (with extent) for the user to easily copy (into e-mail, for example).  I have the widget written, but it only shows the extent for the first time it's opened.  It doesn't update as the user moves around the map.  How do I get it to update?

<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
//
// Display the extent URL for the user
//
////////////////////////////////////////////////////////////////////////////////
-->

<BaseWidget xmlns    ="com.esri.solutions.flexviewer.*" 
      xmlns:mx   ="http://www.adobe.com/2006/mxml"
      x     ="600" 
      y     ="220" 
      widgetConfigLoaded ="init()">
     
 <mx:Script>
  
  <![CDATA[
  
   import mx.controls.Alert;
   
   import com.esri.ags.Map;
   
   private function init():void
   {
    
    txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
   }
   
  ]]>
 </mx:Script>
  
 <WidgetTemplate>
  <mx:Canvas id="viewStack" width="100%" height="100%" horizontalScrollPolicy="off">
   <mx:VBox width="100%" paddingTop="15">
    <mx:Text id="txtTitle" styleName="AboutTitle" text="URL for copying" width="100%" />
    <mx:Text id="txtSubtitle" styleName="AboutSubtitle" text="You can highlight and right-click (or CTRL-C) to copy the URL:" width="100%" />
    <mx:Text id="txtVersion" styleName="AboutVersion" text="" width="100%" />

   </mx:VBox>
  </mx:Canvas>
 </WidgetTemplate>
 
</BaseWidget>
0 Kudos
CedricDespierre_Corporon1
Emerging Contributor
Hello 🙂
Use this event:
map.addEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo); > this will call the repositionInfo function each time you move/zoom on the map.

Your code will look something like that:
private function init():void
   {
map.addEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo);
txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
   }


private function repositionInfo(event:Event):void { 
    txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
}


good luck!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Daniel,

   Cedric's code for adding an event listener for the extent change is exactly what you need. The only thing I would do is also remove the event listener when it is not needed as shown below, no need to continue to listen for the extent when the widget is closed or minimized (you have to always consider code performance/optimization). Also there is no real need for a config xml for this simple widget so eliminate the widgetConfigLoaded and use creationComplete.

<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
//
// Display the extent URL for the user
//
////////////////////////////////////////////////////////////////////////////////
-->

<BaseWidget xmlns    ="com.esri.solutions.flexviewer.*" 
      xmlns:mx   ="http://www.adobe.com/2006/mxml"
      x     ="600" 
      y     ="220" 
      creationComplete ="init()">
     
 <mx:Script>
  
  <![CDATA[
  
   import com.esri.ags.events.ExtentEvent;
   
   import com.esri.ags.Map;
   
   private function init():void
   {
    map.addEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo);
    txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
   }
   
   private function widgetOpenedHandler(event:Event):void
   {
    map.removeEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo);
    map.addEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo);
    txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
   }
   
   private function repositionInfo(event:Event):void
   { 
    txtVersion.text = "https://server.com/flex/index.html?EXT=" + String(map.extent.xmin) + "," + String(map.extent.ymin) + "," + String(map.extent.xmax) + "," + String(map.extent.ymax);
   }
   
   private function widgetClosedHandler(event:Event):void
   {
    map.removeEventListener(ExtentEvent.EXTENT_CHANGE, repositionInfo);
   }
   
  ]]>
 </mx:Script>
  
 <WidgetTemplate widgetOpened="widgetOpenedHandler(event)" widgetClosed="widgetClosedHandler(event)"
  widgetMinimized="widgetClosedHandler(event)">
  <mx:Canvas id="viewStack" width="100%" height="100%" horizontalScrollPolicy="off">
   <mx:VBox width="100%" paddingTop="15">
    <mx:Text id="txtTitle" styleName="AboutTitle" text="URL for copying" width="100%" />
    <mx:Text id="txtSubtitle" styleName="AboutSubtitle" text="You can highlight and right-click (or CTRL-C) to copy the URL:" width="100%" />
    <mx:Text id="txtVersion" styleName="AboutVersion" text="" width="100%" />
   </mx:VBox>
  </mx:Canvas>
 </WidgetTemplate>
</BaseWidget>
0 Kudos