Hi have an app where I am parsing the url and getting the variable to search on (
http://atlantis/arcgis/testcode/test...?premise=44001) 44001 being the unique ID. I have the warning that Data binding will not be able to detect assignments to "PremiseToFind" which is the variable I am using.
How do I dynamically search?
Thanks,
Mike
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
backgroundColor="0xEEEEEE"
pageTitle="Query, then zoom to results">
<!--
Description:
This sample demonstrates how to use the QueryTask to search for features
in a specific layer in a map service based upon a string value. If the
query returns a result, use Map.CenterAt to set focus on that point.
-->
<s:layout>
<s:VerticalLayout gap="0"/>
</s:layout>
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import com.esri.ags.geometry.Extent;
import com.esri.ags.geometry.MapPoint;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
//import spark.globalization.StringTools;
//dynamically get xy here
public var PremiseToFind:String = "044786"
private function getURLParameters():Object
{
var result:URLVariables = new URLVariables();
try
{
if (ExternalInterface.available)
{
// Use JavaScript to get the search string from the current browser location.
// Use substring() to remove leading '?'.
// See
http://livedocs.adobe.com/flex/3/lan...Interface.html
var urlstring:String = ExternalInterface.call("function(){ return document.location.href.toString();}");
if (urlstring && urlstring.length > 0)
{
var words:Array = urlstring.split("?premise=");
//words = urlstring.split("?premise=");
PremiseToFind=words[1]
myGraphicsLayer.clear();
// Alert.show("query is " + queryPoint);
queryTask.execute(queryPoint, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length == 0)
{
Alert.show("No Premises found. Please try again.");
}
else
{
map.scale = 15000;
map.centerAt(featureSet.features[0].geometry as MapPoint);
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString());
}
}
}
else
{
Alert.show("interface not accessable");
}
}
catch (error:Error)
{
Alert.show(error.toString());
}
return PremiseToFind;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Symbol for Query Result as Point -->
<esri:SimpleMarkerSymbol id="sfs" alpha="36" color="Black"/>
<!-- Layer with Premises -->
<esri:QueryTask id="queryTask" url="http://atlantis:6080/arcgis/rest/services/SearchTest/MapServer/0"/>
<esri:Query id="queryPoint"
outSpatialReference="{map.spatialReference}"
returnGeometry="true"
text="{PremiseToFind}">
</esri:Query>
</fx:Declarations>
<esri:Map id="map"
load="getURLParameters()">
<esri:extent>
<esri:Extent xmin="-7048106 " ymin="5803116 " xmax="-6932610 " ymax="5861590" >
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer url="http://atlantis:6080/arcgis/rest/services/SearchTest/MapServer"/>
<esri:GraphicsLayer id="myGraphicsLayer"
graphicProvider="{queryTask.executeLastResult.features}"
symbol="{sfs}"/>
</esri:Map>
</s:Application>