|
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
|
1079
|
|
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
|
576
|
|
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
|
576
|
|
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
|
611
|
|
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
|
1070
|
|
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
|
1119
|
|
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
|
267
|
|
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
|
1027
|
|
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
|
379
|
|
POST
|
Take a look at Mansour's blog for clustering by attributes
... View more
09-01-2010
09:32 AM
|
0
|
0
|
934
|
|
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
|
1129
|
|
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
|
1129
|
|
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
|
720
|
|
POST
|
The link is in my posting above. Click on the word "blog". Here's the link to the post itself.
... View more
08-12-2010
07:43 AM
|
0
|
0
|
720
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 2 | 3 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 4 weeks ago |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|