Select to view content in your preferred language

Navigating by address bar

764
4
09-27-2010 03:28 AM
LisaStevens
Emerging Contributor
Hi there,

Possibly a stupid questions but I wondered if there was a way to open up flexviewer at a particular lat/long using the address bar? i.e. I have a database that I'd like the user to click on a hyperlink which opens up at the correct address.

Is this possible?

Thanks!
Tags (2)
0 Kudos
4 Replies
JoshCalhoun1
Emerging Contributor
Do you mean you want your users to click on a record in a datagrid?
0 Kudos
LisaStevens
Emerging Contributor
I would like a field in our access database to contain a hyperlink that has co-ordinates in which in turn opens up a new webpage to the flexveiwer
0 Kudos
Drew
by
Frequent Contributor
I would like a field in our access database to contain a hyperlink that has co-ordinates in which in turn opens up a new webpage to the flexveiwer

There are a lot of examples on how to do this on both Google and in the ESRI forums.
I would do some digging around and see what you can find, it�??s very easy to do.

Google results:
http://www.google.ca/search?hl=&q=flex+url+parameters&sourceid=navclient-ff&rlz=1B3GGGL_enUS357US357...

Simple Demo On passing URL parameters in Flex:
http://www.abdulqabiz.com/files/test/QueryStringSample.html?myName=Abdul&myHomeTown=Bangalore

Demos Source:
http://www.abdulqabiz.com/blog/archives/2006/03/06/how-to-get-url-query-string-variables-within-flex...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   Here is some code to do this in FlexViewer 2.1 Just replace the existing function in MapManager.mxml with this one.

//map load complete
            private function mapLoadComplete(event:MapEvent):void
            {
    try
    {
     if (ExternalInterface.available)
     {
      var result:URLVariables = new URLVariables();
      var urlSubstring:String = ExternalInterface.call("window.location.search.substring", 1);    
      if (urlSubstring && urlSubstring.length > 0 && urlSubstring != "debug=true")
      {
       result.decode(urlSubstring);
       // Parse URL
       var xExt:String;
       var xUrlParam:String;
       var yLat:String;
       var xLon:String;
       var mScale:String;
       if (result["EXT"])
        xExt = result.EXT;
       
       if (result["LAT"])
        yLat = result.LAT;
       if (result["LON"])
        xLon = result.LON;
       if (result["SCALE"])
        mScale = result.SCALE;
       
       if(!yLat == "" && !xLon == "")
       {
        var spatRef:SpatialReference = new SpatialReference(4326);
        var cPoint:MapPoint = new MapPoint(parseFloat(xLon), parseFloat(yLat),spatRef);
        if(!mScale==""){
         map.scale = parseInt(mScale);
        }else{
         map.scale = 20000;
        }
        if (map.spatialReference.wkid != 4326)
        {
         map.cursorManager.setBusyCursor();
         var geomServ:GeometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
         geomServ.addEventListener(GeometryServiceEvent.PROJECT_COMPLETE,pResult);
         geomServ.addEventListener(FaultEvent.FAULT,pFault);
         geomServ.project([cPoint],map.spatialReference);
         function pResult(event:GeometryServiceEvent):void{
          var pt:MapPoint = (event.result as Array)[0]as MapPoint;
          map.centerAt(pt);
          map.cursorManager.removeBusyCursor();
         }
         function pFault(err:Object):void{
          map.cursorManager.removeBusyCursor();
         }
        } else{
         map.centerAt(cPoint);
        }
       }
       
       if (!xExt == ""){
        var extArray:Array = xExt.split(",");
        var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3]),map.spatialReference);
        map.extent = extent;
       }
      }
     }
    }
    catch (error:Error){}
            }


And add these imports to the MapManager.mxml too.
import com.esri.ags.events.GeometryServiceEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.tasks.GeometryService;
import com.esri.ags.geometry.Geometry;


And feed it a url like this
?LON=-111.88376501599998&LAT=40.75807050000003&SCALE=10000
0 Kudos