|
POST
|
This is the way I've set up an application (not in the SFV framework) to read in a configuration file. The application is a framework where I'm showing the data for several different projects and the XML contains all the parameters for each project, including map service and query URLs. I pass in a parameter in the main URL for the specific project: http://ccma.nos.noaa.gov/explorer/biomapper/biomapper.html?id=JobosBay http://ccma.nos.noaa.gov/explorer/biomapper/biomapper.html?id=StJohn This is the code for the Flex application to read in the XML file
private var xmlParameters:XML;
private var xmlProjectParameters:XMLList;
private function init():void
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,init_onComplete);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,fail);
xmlLoader.load(new URLRequest("parameters.xml"));
}
private function fail(event:Event)
{
Alert.show("Fail");
}
private function init_onComplete(event:Event):void
{
var params:Object;
try
{
var loader:URLLoader = URLLoader(event.target);
xmlParameters = new XML(loader.data);
params = getURLParameters();
if (params["id"])
{
input = params.id
}
else
{
Alert.show("Parameter search failed");
return;
}
xmlProjectParameters = xmlParameters.project.(@urlinput==input);
var bm:IBrowserManager = BrowserManager.getInstance();
bm.init();
bm.setTitle(xmlProjectParameters.@id + " BIOMapper");
serverName = xmlProjectParameters.service;
projectTitle = xmlProjectParameters.projectname.@name;
if (!(xmlProjectParameters.datalayers.dive==undefined))
{
diveQueryTask.url = serverName + xmlProjectParameters.datalayers.dive.@url + "/MapServer/" + xmlProjectParameters.datalayers.dive.@layer;
etc...
}
private function getURLParameters():Object
{
var result:URLVariables = new URLVariables();
try
{
if (ExternalInterface.available)
{
var search:String = ExternalInterface.call("location.search.substring", 1);
if (search && search.length > 0)
{
result.decode(search);
}
}
}
catch (error:Error)
{
Alert.show(error.toString());
}
return result;
}
And this is the code for the XML file
<?xml version="1.0" encoding="utf-8"?>
<projects>
<project id="Jobos Bay" urlinput="JobosBay">
<projectname name ="Jobos Bay, PR" pdftitle="Jobos Bay, PR: Shallow-water Benthic Habitats" url="http://ccma.nos.noaa.gov/ecosystems/coralreef/ceap/"/>
<service>http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biomapper/Jobos_</service>
<datalayers>
<dive layer="0" url="Dynamic" site_id="Site_ID" videoname="Site_ID" assessment="Assessment" photocount="PhotoCount" symbol="Symbol" legendurl="http://ccma.nos.noaa.gov/explorer/biomapper/jobosbay/images/Dives.png" legendheight="53">
</dive>
</datalayers>
etc
</project>
<project id="St. John" urlinput="StJohn">
<projectname name="St. John, U.S. Virgin Islands" pdftitle="U.S. Virgin Islands (St. John): Shallow- and Moderate-Depth Benthic Habitats" url="http://ccma.nos.noaa.gov/ecosystems/coralreef/benthic/"/>
<service>http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biomapper/StJ_</service>
<datalayers>
<dive layer="13" url="all" site_id="SITE_ID" videoname="VIDEONAME" assessment="ASSESSMENT" photocount="PHOTOCOUNT" symbol="SYMBOL" legendurl="http://ccma.nos.noaa.gov/explorer/biomapper/stjohn/images/Dives.png" legendheight="103">
</dive>
etc.
</project>
</projects>
... View more
07-26-2011
06:15 AM
|
0
|
0
|
963
|
|
POST
|
Take a look at this blog about measuring distances in Web Mercator
... View more
07-20-2011
01:27 PM
|
0
|
0
|
3922
|
|
POST
|
Here's an example of what I have for an add-in that uses a button on a form to start drawing on the map. the tool is named DrawTool
Dim pUID As New ESRI.ArcGIS.esriSystem.UID
Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem
pUID.Value = My.ThisAddIn.IDs.DrawTool
pCommandItem = m_application.Document.CommandBars.Find(pUID, False, False)
m_application.CurrentTool = pCommandItem
... View more
07-13-2011
01:31 PM
|
0
|
0
|
3051
|
|
POST
|
You don't need to make a call to a geometry service if you are projecting lat/long to or from Web Mercator. The WebMercatorUtil class does this for you. Here's another version of Shuping's code
<?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="World Street Map" xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.SpatialReference;
import com.esri.ags.events.GeometryServiceEvent;
import com.esri.ags.events.MapEvent;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.symbols.SimpleMarkerSymbol;
import com.esri.ags.utils.WebMercatorUtil;
import mx.controls.Alert;
protected function map1_loadHandler(event:MapEvent):void
{
//project the lat and long values from 4326 to 102100
var myPoint:MapPoint = new MapPoint(-122, 73, new SpatialReference(4326));
// geometryService.project([myPoint as Geometry], new SpatialReference(102100),null);
var myGraphic:Graphic = new Graphic(WebMercatorUtil.geographicToWebMercator(myPoint), new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 22, 0x009933));
myGraphicsLayer.add(myGraphic);
map.centerAt(myGraphic.geometry as MapPoint);
}
// protected function geometryService_projectCompleteHandler(event:GeometryServiceEvent):void
// {
// var pt:MapPoint = (event.result as Array)[0]as MapPoint;
// var myGraphic:Graphic = new Graphic(pt, new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 22, 0x009933));
// myGraphicsLayer.add(myGraphic);
// map.centerAt(pt);
// }
]]>
</fx:Script>
<fx:Declarations>
<esri:GeometryService id="geometryService"
projectComplete="geometryService_projectCompleteHandler(event)"
url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
</fx:Declarations>
<esri:Map id ="map" load="map1_loadHandler(event)">
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer id="myGraphicsLayer"></esri:GraphicsLayer>
</esri:Map>
</s:Application>
... View more
07-06-2011
12:42 PM
|
0
|
0
|
2005
|
|
POST
|
Hi Jerry, Here are the files I'm using with my application.
... View more
07-05-2011
10:51 AM
|
0
|
0
|
1391
|
|
POST
|
Here's another way to do it
IGPUtilities2 gpUtils = new GPUtilitiesClass();
IFeatureClass inFeature1 = gpUtils.OpenFeatureClassFromString(@" ");//path of the 1st Input Feature Class
IFeatureClass inFeature2 = gpUtils.OpenFeatureClassFromString(@" ");//path of the 2nd Input Feature Class
IFeatureClass inFeature3 = gpUtils.OpenFeatureClassFromString(@" ");//path of the 3rd Input Feature Class
Test(inFeature1, inFeature2, inFeature3);
private void Test(IFeatureClass pf1,IFeatureClass pf2,IFeatureClass pf3)
{
try
{
ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
GP.OverwriteOutput = true;
IGPUtilities2 gpUtils = new GPUtilitiesClass();
IGpValueTableObject vt = new GpValueTableObjectClass();
vt.SetColumns(2);
object weight;
weight = 1 as object;
object obj1 = pf1;
vt.AddRow(ref obj1);
vt.SetValue(0, 1, ref weight);
object obj2 = pf2;
vt.AddRow(ref obj2);
vt.SetValue(1, 1, ref weight);
object obj3 = pf3;
vt.AddRow(ref obj3);
vt.SetValue(2, 1, ref weight);
ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
intersect.in_features = vt;
intersect.out_feature_class = @"D:\Neil'sData\Output\New1.shp";//Specify The Output path
GP.Execute(intersect, null);
MessageBox.Show("Intersection is Successfull!!!!!!");
}
catch (Exception e1)
{
MessageBox.Show("error!!!!");
}
}
... View more
06-24-2011
07:15 AM
|
0
|
0
|
2048
|
|
POST
|
In my application, I've taken the results of the Identify and pushed it into an array, then set the DataGrid's dataProvider to that array. This is part of a larger code for an application that takes the IdentifyResults from all the visible layers and puts the results from each layer into a separate tab in an InfoWindow.
identifyTask.execute(identifyParams, new AsyncResponder(resultFunction, faultFunction, clickGraphic));
function resultFunction(results:Array, clickGraphic:Graphic):void
{
if (results && results.length > 0)
{
var resultsArray:Array = [];
var newDG:DataGrid = new DataGrid;
resultsArray.push(result.feature.attributes);
newDG = new DataGrid;
newDG.dataProvider = resultsArray;
}
}
In reading your post, I was seeing DataGrid instead of DataGroup. However, the dataProvider expects an IList, which could be an ArrayCollection, ArrayList, and XMLListCollection, so you should add your graphic to an array.
... View more
06-23-2011
08:08 AM
|
0
|
0
|
691
|
|
POST
|
In my VB.NET application, I've used a scratch workspace to store the temporary files. Here's the help information about creating them.
... View more
06-23-2011
07:35 AM
|
0
|
0
|
1527
|
|
POST
|
You should be able to do this by removing the references to tab and changing newVBox.addElement(newDG); newVBox.label = oldLayer.toString(); tab.addElement(newVBox); myInfoRenderer.addElement(tab); to newVBox.addElement(newDG); newVBox.label = oldLayer.toString(); myInfoRenderer.addElement(newVBox);
... View more
06-16-2011
01:25 PM
|
0
|
0
|
1391
|
|
POST
|
Take a look at this thread to see if there's anything in there that would help you.
... View more
06-16-2011
07:42 AM
|
0
|
0
|
1580
|
|
POST
|
You can see this code in action in this application. Click a point on the map near the corner of one of the grids. Is this the type of results you're looking for?
... View more
06-16-2011
07:03 AM
|
0
|
0
|
1391
|
|
POST
|
I've noticed that if I set breakpoints but haven't made any changes to my code since last debugging it, the breakpoints won't be hit. I have to make sure the project is built (either by making a insubstantial addition or building it manually) so the breakpoints are hit.
... View more
06-15-2011
07:47 AM
|
0
|
0
|
1831
|
|
POST
|
Here's some code in one of my applications that will populate a datagrid from a map click, putting it into a tab navigator in an InfoWindow. The portion of the code that is commented out allows you to get back the results from multiple visible layers in your layer, which are put into separate tabs. The listeners that are added allow you to highlight the features on the map when you click or roll over the entries in the datagrid.
protected function MainMap_mapClickHandler(event:MapMouseEvent):void
{
var identifyParams:IdentifyParameters = new IdentifyParameters();
var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPointSymbol);
identifyParams.returnGeometry = true;
identifyParams.tolerance = 5;
identifyParams.width = MainMap.width;
identifyParams.height = MainMap.height;
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = MainMap.extent;
identifyParams.spatialReference = MainMap.spatialReference;
identifyParams.layerIds = layerLIS.visibleLayers.source; //replace this with your layerID
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
clickGraphicsLayer.clear();
MainMap.infoWindow.hide();
graphicsLayer.clear();
cursorManager.setBusyCursor();
identifyTask.url = layerLIS.url; //replace this with your layer URL
identifyTask.execute(identifyParams, new AsyncResponder(resultFunction, faultFunction, clickGraphic));
function resultFunction(results:Array, clickGraphic:Graphic):void
{
var myInfoRenderer:InfoRenderer = new InfoRenderer;
var mapPoint:MapPoint = MapPoint(clickGraphic.geometry);
var point:Point = MainMap.toScreen(mapPoint);
if (results && results.length > 0)
{
var oldLayer:Number = -1;
var resultsArray:Array = [];
var result:IdentifyResult;
var resultGraphic:Graphic;
var tab:TabNavigator = new TabNavigator();
var newVBox:VBox = new VBox;
var newVBoxDG:VBox = new VBox;
var newText:Text = new Text;
var newDG:DataGrid = new DataGrid;
var graphic:Graphic;
clickGraphicsLayer.add(clickGraphic);
result = results[0];
oldLayer = result.layerId;
resultsArray.push(result.feature.attributes);
newText = new Text;
newText.text = result.layerName;
graphic = result.feature;
graphic.alpha = 0.3;
graphicsLayer.add(graphic);
tab.width = 400;
tab.height = 230;
// for (var i:int = 1; i < results.length; i++)
// {
// result = results;
// graphic = new Graphic;
// graphic = result.feature;
// graphic.alpha = 0.3;
// graphicsLayer.add(graphic);
// if (result.layerId == oldLayer)
// {
// resultsArray.push(result.feature.attributes);
// }
// else
// {
// newDG = new DataGrid;
// newVBox = new VBox;
// newDG.dataProvider = resultsArray;
//
// newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true);
// newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0 ,true);
// newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true);
//
// newVBox.addElement(newText);
// newVBox.addElement(newDG);
// newVBox.label = oldLayer.toString();
// newVBox.label = oldLayer.toString();
// tab.addElement(newVBox);
// myInfoRenderer.addElement(tab);
//
// newText = new Text;
// newText.text = result.layerName;
// resultsArray = [];
// resultsArray.push(result.feature.attributes);
// }
// oldLayer = result.layerId;
// }
newVBox = new VBox;
newVBoxDG = new VBox;
newDG = new DataGrid;
newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true);
newVBox.addElement(newText);
newDG.dataProvider = resultsArray;
newVBox.addElement(newDG);
newVBox.label = oldLayer.toString();
tab.addElement(newVBox);
myInfoRenderer.addElement(tab);
cursorManager.removeBusyCursor();
MainMap.infoWindow.content = myInfoRenderer;
MainMap.infoWindow.label = "Results";
MainMap.infoWindow.show(MainMap.toMap(point));
MainMap.infoWindow.addEventListener(Event.CLOSE, infoWindow_Close, false, 0, true);
}
}
}
protected function newDG_ItemRollOut(event:ListEvent):void
{
graphicLayer.clear();
}
protected function newDG_ItemRollOver(event:ListEvent):void
{
var highlightedGraphic:Graphic = findGraphicByAttribute(event.itemRenderer.data);
var glowFill:SimpleFillSymbol = new SimpleFillSymbol;
var glower:AnimateFilter = new AnimateFilter(highlightedGraphic,glow);
glower.motionPaths = kf;
glower.duration = 500;
glower.play();
}
protected function faultFunction(error:Object, token:Object = null):void
{
cursorManager.removeBusyCursor();
Alert.show(error.toString());
}
protected function findGraphicByAttribute(attributes:Object):Graphic
{
for each (var graphic:Graphic in graphicsLayer.graphicProvider)
{
if (graphic.attributes == attributes)
{
return graphic;
}
}
return null;
}
... View more
06-15-2011
07:35 AM
|
0
|
0
|
1390
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 2 weeks ago | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|