|
POST
|
You have to separate the text parts of the query from the values derived from the controls. Try this for your whereclause string qfilter.WhereClause = "Plot_No = " & textBox1.Text & " AND Layer = '" & Convert.ToString( comboBox1.SelectedItem) & "'";
... View more
10-07-2010
05:51 AM
|
0
|
0
|
593
|
|
POST
|
I've taken the Identify Features sample and modified it so that it only shows some of the attributes of the feature that's selected.
<?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:esri="http://www.esri.com/2008/ags"
pageTitle="Identify Features on the Map">
<!--
This sample shows how to identify features with a MapClick and the Identify task.
The IdentifyParameters designate which layers are being identified.
Identify operations can potentially return a lot of information
depending on the number of layers being identified and a given tolerance.
The tolerance is the number of pixels a feature is allowed to lie away
from the clicked point in order to be counted as a result.
In this sample, when user clicks the map, an "Identify" task is executed.
When the task finishes executing, the executeCompleteHandler function loops
through the features in the IdentifyResult and adds them to the map.
-->
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.symbols.InfoSymbol;
import com.esri.ags.tasks.supportClasses.IdentifyParameters;
import com.esri.ags.tasks.supportClasses.IdentifyResult;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
import spark.components.TextArea;
[Bindable]private var lastIdentifyResultGraphic:Graphic;
private function mapClickHandler(event:MapMouseEvent):void
{
clickGraphicsLayer.clear();
var identifyParams:IdentifyParameters = new IdentifyParameters();
identifyParams.returnGeometry = true;
identifyParams.tolerance = 3;
identifyParams.width = myMap.width;
identifyParams.height = myMap.height;
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = myMap.extent;
identifyParams.spatialReference = myMap.spatialReference;
var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
clickGraphicsLayer.add(clickGraphic);
identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
}
private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
{
if (results && results.length > 0)
{
var result:IdentifyResult = results[0];
var resultGraphic:Graphic = result.feature;
var textArea:TextArea = new TextArea();
var infoWindowText:String;
var mapPoint:MapPoint = MapPoint(clickGraphic.geometry);
var point:Point = myMap.toScreen(mapPoint);
var label:String;
switch (resultGraphic.geometry.type)
{
case Geometry.MAPPOINT:
{
label = "City Layer"
infoWindowText = "City: " + resultGraphic.attributes.CITY_NAME + "\nState: " + resultGraphic.attributes.STATE_NAME;
resultGraphic.symbol = smsIdentify;
break;
}
case Geometry.POLYLINE:
{
label = "River Layer"
infoWindowText = resultGraphic.attributes.NAME;
resultGraphic.symbol = slsIdentify;
break;
}
case Geometry.POLYGON:
{
label = "State Layer"
infoWindowText = resultGraphic.attributes.STATE_NAME;
resultGraphic.symbol = sfsIdentify;
break;
}
}
lastIdentifyResultGraphic = resultGraphic;
// update clickGraphic (from mouse click to returned feature)
// clickGraphic.symbol = new InfoSymbol(); // use default renderer
// clickGraphic.attributes = resultGraphic.attributes;
textArea.text = infoWindowText;
myMap.infoWindow.content = textArea;
myMap.infoWindow.label = label;
myMap.infoWindow.show(myMap.toMap(point));
}
}
private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
{
Alert.show(String(error), "Identify Error");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Symbol for where the user clicked -->
<esri:SimpleMarkerSymbol id="clickPtSym"
color="0xFF0000"
size="12"
style="x"/>
<!-- Symbol for Identify Result as Polyline -->
<esri:SimpleLineSymbol id="slsIdentify"
width="2"
alpha="1"
color="0x00FF00"
style="solid"/>
<!-- Symbol for Identify Result as Point -->
<esri:SimpleMarkerSymbol id="smsIdentify"
color="0x00FF00"
size="15"
style="diamond"/>
<!-- Symbol for Identify Result as Polygon -->
<esri:SimpleFillSymbol id="sfsIdentify"/>
<!-- Identify Task -->
<esri:IdentifyTask id="identifyTask"
concurrency="last"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/>
</fx:Declarations>
<esri:Map id="myMap"
mapClick="mapClickHandler(event)"
openHandCursorVisible="false">
<esri:extent>
<esri:WebMercatorExtent minlon="-120" minlat="30" maxlon="-100" maxlat="50"/>
</esri:extent>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>
<esri:GraphicsLayer id="clickGraphicsLayer"/>
</esri:Map>
</s:Application>
... View more
10-05-2010
12:23 PM
|
0
|
0
|
1634
|
|
POST
|
Use the content method of the InfoWindow to put other things in there. Take a look at this sample
... View more
10-05-2010
09:06 AM
|
0
|
0
|
1634
|
|
POST
|
Ah...thanks for pointing that out. I didn't take note of the inheritance.
... View more
10-05-2010
05:09 AM
|
0
|
0
|
951
|
|
POST
|
It's too bad that now there's the extra step of creating a polygon when determining whether the extent of several unioned extents is contained within another extent.
... View more
10-04-2010
12:39 PM
|
0
|
0
|
951
|
|
POST
|
Hi Dan, I was able to replicate your problem, but then I changed the size of the BorderContainer to 550x500 and it acted normally. I even put in another input box to make the graphic even thinner and taller and it didn't make a difference.
<?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:esri="http://www.esri.com/2008/ags"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.geometry.Polygon;
import com.esri.ags.utils.GraphicUtil;
import com.esri.ags.geometry.Extent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
protected function Map_mapClickHandler(event:MapMouseEvent):void
{
//allow user to enter size of poly desired
if(tInput1.text == ""){
Alert.show("Please enter a number in the text input before clicking the map.");
}else{
var size:int = Number(tInput1.text);
var halfSize:Number = size/2;
var center:MapPoint=Map.toMapFromStage(event.stageX, event.stageY);
var botLeft:MapPoint = new MapPoint;
//new mapPoint is assigned the same coor sys as the map
botLeft.spatialReference=Map.spatialReference;
//units defined by the spatial reference
botLeft.x=center.x-halfSize;
botLeft.y=center.y-halfSize*Number(tInput2.text);
var botRight:MapPoint = new MapPoint;
botRight.spatialReference=Map.spatialReference;
botRight.x=center.x+halfSize;
botRight.y=center.y-halfSize*Number(tInput2.text);
var topRight:MapPoint = new MapPoint;
topRight.spatialReference=Map.spatialReference;
topRight.x=center.x+halfSize;
topRight.y=center.y+halfSize*Number(tInput2.text);
var topLeft:MapPoint = new MapPoint;
topLeft.spatialReference=Map.spatialReference;
topLeft.x=center.x-halfSize;
topLeft.y=center.y+halfSize*Number(tInput2.text);
var newPolygon:Polygon = new Polygon;
newPolygon.spatialReference=Map.spatialReference;
newPolygon.rings=[[botLeft, botRight, topRight, topLeft, botLeft]];
var newGraphic:Graphic = new Graphic;
newGraphic.geometry=newPolygon;
newGraphic.symbol=symbol1;
gLayer.add(newGraphic);
zoomToGraphics();
}
}
private function zoomToGraphics():void
{
var graphicProvider:ArrayCollection = ArrayCollection(gLayer.graphicProvider);
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray());
//graphicsExtent.spatialReference = Map.spatialReference;
Map.extent = graphicsExtent;
Alert.show("Map height: " + Map.extent.height + "\n gE height: " + graphicsExtent.height + "\n " +
"\n Map width: " + Map.extent.width + "\n gE width: " + graphicsExtent.width);
}
protected function clearGraphics_clickHandler(event:MouseEvent):void
{
gLayer.clear();
}
]]>
</fx:Script>
<fx:Declarations>
<esri:SimpleFillSymbol id="symbol1"
style="solid"
color="0xFF0000"
alpha="0.3">
<esri:outline>
<esri:SimpleLineSymbol style="solid" color="0x000000" width="1" />
</esri:outline>
</esri:SimpleFillSymbol>
</fx:Declarations>
<s:BorderContainer id="mainBC"
width="550" height="500"
borderVisible="true"
borderAlpha="1" borderColor="#FF0000"
borderStyle="solid" borderWeight="3">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle" paddingTop="5"/>
</s:layout>
<s:Label text="Click the map to add a graphic" fontSize="15"/>
<esri:Map id="Map" logoVisible="false" mapClick="Map_mapClickHandler(event)">
<esri:ArcGISTiledMapServiceLayer id="mapSvc" url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer id="gLayer"/>
</esri:Map>
<s:TextInput id="tInput1" text="10000"/>
<s:TextInput id="tInput2" text = "20"/>
<s:Button id="clearGraphics" label="Clear Graphics" click="clearGraphics_clickHandler(event)"/>
</s:BorderContainer>
</s:Application>
... View more
10-04-2010
11:35 AM
|
0
|
0
|
1011
|
|
POST
|
This method was in the 1.3 version of the API but isn't showing up in the 2.x version. Is there a reason it was dropped?
... View more
10-04-2010
11:33 AM
|
0
|
4
|
1445
|
|
POST
|
Here are two ways of looking at it. If you want to add the attribute for LAND_AC6 only when none of the other fields have any attributes, then use this.
Function FindLabel ( [LTSA_LOT] , [LTSA_BLOCK] , [LTSA_PA4] , [LTSA_PLAN] , [LAND_AC6] )
if ( Len ([LTSA_LOT]) <> 0) then
str = [LTSA_LOT] & " - "
end if
if ( Len ( [LTSA_BLOCK] ) <> 0) then
str = str + [LTSA_BLOCK] & " - "
end if
if ( Len ( [LTSA_PA4] ) <> 0) then
str = str + [LTSA_PA4] & " - "
end if
if ( Len( [LTSA_PLAN] ) <> 0) then
str = str + [LTSA_PLAN]
end if
if ( Len( [LAND_AC6] ) <> 0) then
str1 = [LAND_AC6]
end if
if (Len(str) > 0) then
FindLabel = str
else
FindLabel = str1
end if
End Function
If you want to add the attribute for LAND_AC6 if one or more of the other fields don't have any attributes, then this should work
Function FindLabel ( [LTSA_LOT] , [LTSA_BLOCK] , [LTSA_PA4] , [LTSA_PLAN] , [LAND_AC6] )
dim found
found = True
if ( Len ([LTSA_LOT]) <> 0) then
str = [LTSA_LOT] & " - "
else
found = False
end if
if ( Len ( [LTSA_BLOCK] ) <> 0) then
str = str + [LTSA_BLOCK] & " - "
else
found = False
end if
if ( Len ( [LTSA_PA4] ) <> 0) then
str = str + [LTSA_PA4] & " - "
else
found = False
end if
if ( Len( [LTSA_PLAN] ) <> 0) then
str = str + [LTSA_PLAN]
else
found = False
end if
if ( Len( [LAND_AC6] ) <> 0) then
str1 = [LAND_AC6]
end if
if found then
FindLabel = str
else
FindLabel = str & vbNewLine & str1
end if
End Function
... View more
09-29-2010
12:30 PM
|
0
|
0
|
1727
|
|
POST
|
I'm not using it in the Flex Viewer, but this is the projection information that's in my code for a Web Mercator service.
private var layerGraticule:SimpleGraticuleLayer = new SimpleGraticuleLayer;
layerGraticule.projection = new Mercator(new Ellipsoid(6378137,0,""),0,0,0,0, LinearUnit.METER);
... View more
09-21-2010
10:33 AM
|
0
|
0
|
429
|
|
POST
|
Try refreshing the activeview after adding the layer:
Call AddLayerFromFile(pMap, "G:\Deepak\map_mumbai_final.jpg.lyr")
pMxDoc.UpdateContents
pMxDoc.ActiveView.Refresh
... View more
09-17-2010
09:29 AM
|
0
|
0
|
1444
|
|
POST
|
Did you ever set the zoomFeature array to a new Array? Either private var zoomFeatures:Array = new Array; or zoomFeatures = new Array();
... View more
09-08-2010
06:52 AM
|
0
|
0
|
583
|
|
POST
|
Take a look at Mansour's blog for clustering by attributes
... View more
09-01-2010
09:32 AM
|
0
|
0
|
1490
|
|
POST
|
This will work instead
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="Query, then zoom to results"
styleName="plain">
<mx:Script>
<![CDATA[
import com.esri.ags.geometry.Extent;
import com.esri.ags.Graphic;
import com.esri.ags.geometry.Polygon;
import com.esri.ags.tasks.FeatureSet;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
[Bindable] private var lastIdentifyResultGraphic:Graphic;
private function doQuery():void
{
query.text = fText.text
query.where = ""
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
// clear the graphics layer
myGraphicsLayer.clear();
if (featureSet.features.length == 0)
{
Alert.show("No States found. Please try again.");
}
else
{
var unionExtent:Extent;
var myFirstGraphic:Graphic = featureSet.features[0];
unionExtent = Polygon(myFirstGraphic.geometry).extent;
for each (var myGraphic1:Graphic in featureSet.features)
{
myGraphicsLayer.add(myGraphic1);
unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent);
}
MainMap.extent = unionExtent;
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString());
}
}
private function sfDataGrid_Click():void
{
var obj:Object = sfDataGrid.selectedItem;
if (obj != null)
{
lastIdentifyResultGraphic = null;
query.where = "STATE_NAME = '" + obj["STATE_NAME"] + "'"
queryTaskZoom.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
lastIdentifyResultGraphic = featureSet.features[0];
lastIdentifyResultGraphic.symbol = sfs;
MainMap.extent = new Extent(lastIdentifyResultGraphic.geometry.extent.xmin,lastIdentifyResultGraphic.geometry.extent.ymin,lastIdentifyResultGraphic.geometry.extent.xmax,lastIdentifyResultGraphic.geometry.extent.ymax);
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString(), "Query Problem");
}
}
}
]]>
</mx:Script>
<!-- Start Declarations -->
<!-- Symbol for Query Result as Polygon -->
<esri:SimpleFillSymbol id="sfs" alpha="0.7" color="0xFF0000"/>
<!-- Layer with US States -->
<esri:QueryTask id="queryTask"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/>
<esri:QueryTask id="queryTaskZoom"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/>
<esri:Query id="query" text="{fText.text}" returnGeometry="true" outSpatialReference="{MainMap.spatialReference}">
<esri:outFields>
<mx:String>MED_AGE</mx:String>
<mx:String>POP2007</mx:String>
</esri:outFields>
</esri:Query>
<!-- End Declarations -->
<mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center">
<mx:Text text="Search for U.S. States:"/>
<mx:TextInput id="fText" enter="doQuery()" text="Ca"/>
<mx:Button label="Query" click="doQuery()"/>
</mx:HBox>
<mx:Text id="resultSummary" height="15"/>
<mx:VDividedBox height="100%" width="100%">
<esri:Map id="MainMap">
<esri:extent>
<esri:Extent xmin="-126" ymin="24" xmax="-67" ymax="50">
<esri:SpatialReference wkid="4326"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/>
<esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}" graphicProvider="{lastIdentifyResultGraphic}"/>
</esri:Map>
<mx:DataGrid id="sfDataGrid" click="sfDataGrid_Click()"
dataProvider="{queryTask.executeLastResult.attributes}"
scroll="true" width="100%" height="40%"/>
</mx:VDividedBox>
</mx:Application>
... View more
08-16-2010
06:23 AM
|
0
|
0
|
1955
|
|
POST
|
Here's the code I use, where the function is the click method of the Datagrid. If you're selecting a point, you'll have to alter the extent so it's not dimensionless.
private function sfDataGrid_Click():void
{
var obj:Object = sfDatagrid.selectedItem;
if (obj != null)
{
var polyExtent:Extent = new Extent(obj["XMIN"],obj["YMIN"],obj["XMAX"],obj["YMAX"]);
lastIdentifyResultGraphic = null;
// this section will highlight the feature selected
sfQuery.where = "Name = '" + obj["Name"] + "'"
sfPolygonQueryTask.execute(sfQuery, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
lastIdentifyResultGraphic = featureSet.features[0];
lastIdentifyResultGraphic.symbol = sfsOutline;
}
function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString(), "Query Problem");
}
MainMap.extent = polyExtent;
if (!MainMap.extent.containsExtent(polyExtent)) MainMap.level--;
}
}
... View more
08-13-2010
12:55 PM
|
0
|
0
|
1955
|
|
POST
|
I agree on that...it's very hard to differentiate the link color from the text color. At least it gets underlined when the cursor passes over it.
... View more
08-12-2010
09:53 AM
|
0
|
0
|
1144
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 1 | 4 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 10-11-2023 06:18 AM | |
| 1 | 03-23-2026 09:23 AM |
| Online Status |
Offline
|
| Date Last Visited |
15 hours ago
|