POST
|
I have a function in my application similar to this oldie, but goodie from the dev blog. I simply add eventListeners for mouseOver and mouseOut on the graphics in a FeatureLayer's selectedFeatrues array. My function works great with Polyline, but when working with points, it would appear I have 2 graphic features for each MapPoint. In my logs, defaultSymbol is the target Symbol that I will save default symbology. highlight is the mouseOver event and reset is mouseOut event. Here is the log for mouseOver and mouseOut on a selected line a FeatureLayer highlight: geometry of cuurentTarget: (com.esri.ags.geometry::Polyline)#0
13:40:42.926->org.lacsd.util.LayerUtil->highlight: defaultSymbol before being set: null
13:40:42.926->org.lacsd.util.LayerUtil->highlight: current symbol of graphic: null
13:40:42.926->org.lacsd.util.LayerUtil->highlight: defaultSymbol after being set: null
13:40:42.926->org.lacsd.util.LayerUtil->highlight: current symbol of graphic after set: [object SimpleLineSymbol]
reset: geometry of cuurentTarget: (com.esri.ags.geometry::Polyline)#0
13:40:43.301->org.lacsd.util.LayerUtil->reset: defaultSymbol before being set: null
13:40:43.301->org.lacsd.util.LayerUtil->reset: current symbol of graphic: [object SimpleLineSymbol]
13:40:43.301->org.lacsd.util.LayerUtil->reset: defaultSymbol after being set: null
13:40:43.301->org.lacsd.util.LayerUtil->reset: current symbol of graphic after set: null Here is the log for exact same action on a MapPoint graphic. 13:42:53.204->org.lacsd.util.LayerUtil->highlight: geometry of cuurentTarget: MapPoint[x=-13124667.797324661,y=4029073.938918875,SpatialReference[102113]]
13:42:53.204->org.lacsd.util.LayerUtil->highlight: defaultSymbol before being set: [object Symbol]
13:42:53.204->org.lacsd.util.LayerUtil->highlight: current symbol of graphic: null
13:42:53.204->org.lacsd.util.LayerUtil->highlight: defaultSymbol after being set: null
13:42:53.204->org.lacsd.util.LayerUtil->highlight: current symbol of graphic after set: [object SimpleMarkerSymbol]
13:42:53.235->org.lacsd.util.LayerUtil->highlight: geometry of cuurentTarget: MapPoint[x=-13124667.797324661,y=4029073.938918875,SpatialReference[102113]]
13:42:53.235->org.lacsd.util.LayerUtil->highlight: defaultSymbol before being set: null
13:42:53.235->org.lacsd.util.LayerUtil->highlight: current symbol of graphic: [object SimpleMarkerSymbol]
13:42:53.235->org.lacsd.util.LayerUtil->highlight: defaultSymbol after being set: [object SimpleMarkerSymbol]
13:42:53.235->org.lacsd.util.LayerUtil->highlight: current symbol of graphic after set: [object SimpleMarkerSymbol]
13:42:53.454->org.lacsd.util.LayerUtil->reset: geometry of cuurentTarget: MapPoint[x=-13124667.797324661,y=4029073.938918875,SpatialReference[102113]]
13:42:53.454->org.lacsd.util.LayerUtil->reset: defaultSymbol before being set: [object SimpleMarkerSymbol]
13:42:53.454->org.lacsd.util.LayerUtil->reset: current symbol of graphic: [object SimpleMarkerSymbol]
13:42:53.454->org.lacsd.util.LayerUtil->reset: defaultSymbol after being set: [object SimpleMarkerSymbol]
13:42:53.454->org.lacsd.util.LayerUtil->reset: current symbol of graphic after set: [object SimpleMarkerSymbol] As you can see above, the mouseOver event fires twice. The odd part is the mouse out event only fires once. I've checked the FeatureLayer.selectedFeatures and the FeatureLayer.graphicProvider just in case, but can find no discrepency in graphic counts. Has anyone else run across a problem like this? This problem does not occur if I set the FeatureLayer.renderer manually, but I would like to see my mxd symbology before resorting to this. The problem it causes in my case is that the second mouseOver event sets the defaultSymbol to the highlighted symbol, so it never goes back to normal. I can work around this, but I'd like to know if there is something I'm missing or is this a feature somehow. Also, can anyone recreate it? Thanks. Here is my code if it makes a difference.
// add my listeners in a function
graphic.addEventListener(MouseEvent.MOUSE_OVER, highlightGraphic, false, 0, true);
graphic.addEventListener(MouseEvent.MOUSE_OUT, resetGraphic, false, 0, true);
// highlights the graphic
protected static function highlightGraphic(event:MouseEvent):void {
logger.debug("highlight: geometry of cuurentTarget: {0}", event.currentTarget.geometry);
logger.debug("highlight: defaultSymbol before being set: {0}", defaultSymbol);
logger.debug("highlight: current symbol of graphic: {0}", event.currentTarget.symbol);
// save the default symbology for the mouseOut
defaultSymbol = event.currentTarget.symbol;
// a class that pulls in preset highlight symbology based
// on geometry
event.currentTarget.symbol = highlight.getSymbol(event.currentTarget as Graphic);
logger.debug("highlight: defaultSymbol after being set: {0}", defaultSymbol);
logger.debug("highlight: current symbol of graphic after set: {0}", event.currentTarget.symbol);
}
// resets the graphic to original state
protected static function resetGraphic(event:MouseEvent):void {
logger.debug("reset: geometry of cuurentTarget: {0}", event.currentTarget.geometry);
logger.debug("reset: defaultSymbol before being set: {0}", defaultSymbol);
logger.debug("reset: current symbol of graphic: {0}", event.currentTarget.symbol);
// set the graphic symbology to original state
// using saved default symbology
event.currentTarget.symbol = defaultSymbol;
logger.debug("reset: defaultSymbol after being set: {0}", defaultSymbol);
logger.debug("reset: current symbol of graphic after set: {0}", event.currentTarget.symbol);
}
... View more
07-21-2010
01:36 PM
|
0
|
2
|
704
|
POST
|
If you want a clickable link, you'll want to set up the labelFunction of the DataGrid, which would look something like this protected function formatURL(item:Object, column:DataGridColumn):String {
column.itemRenderer = null;
if (column.dataField == "URLData" ) {
column.itemRenderer = new ClassFactory(UrlLinkButton);
return item.URLData;
}
else if (column.dataField == "Name") // set up checks for other field names
return item.Name;
else
return "ERR: No Field name defined";
} With an ItemRenderer for your field that could look like this. <?xml version="1.0" encoding="utf-8"?>
<mx:LinkButton xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
fontWeight="bold"
color="#0000FF"
label="{data.URLData}"
click="openURL()">
<fx:Script>
<![CDATA[
/**
* Function that will parse current date and given URL info into a url string to be opened in a new page.
**/
protected function openURL():void {
trace("button clicked, attempt to parse to URL");
if (data.URLData) {
// concatenate url string
var url:String = "url information" + data.URLData + "maybe more url information";
trace("send drawing url request");
navigateToURL(new URLRequest(url));
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</mx:LinkButton> This way, the URL opens only if they click in that field. Of course you could bypass the ItemRenderer and use the openURL() on an ItemClickEvent if you don't mind that the URL will open when they click the row in the DataGrid.
... View more
07-20-2010
09:16 AM
|
0
|
0
|
166
|
POST
|
Training from the source is on my list, adding the Flex 4 bible as well. Thanks. Two that I have gotten a lot of use from are Flex 4 In Action, print not available yet, but you can get the eBook, and I keep the Flex 4 Cookbook open pertty much all day.
... View more
07-20-2010
05:45 AM
|
0
|
0
|
368
|
POST
|
I'm having a little difficulty trying to make this work in a simple manner using a FeatureLayer. I'm able to use fLayer.selectFeatures() to make a selection, and features are highlighted on my map. problem I'm having now is trying to easily extract the attribute data. fLayer.selectedFeatures has all the graphics. I tried fLayer.featureCollection.featureSet.attributes, but featureCollection is null when using selectedFeatures. I'm guessing this would get populated when using fLayer.queryFeaturs() maybe? But then my selection doesn't show up. This is what I'm trying to do. fLayer.mode=FeatureLayer.MODE_SELECTION;
fLayer.selectionColor=0x7FFF00;
fLayer.outFields = [ "AssetID", "FeatureID", "Name" ];
fLayer.useAMF=true;
flayer.selectFeatures(query, "new", new AsyncResponder(onFeatureLayerResults_handler, onFault, true)));
function onFeatureLayerResults_handler(features:Array, token:Object = null):void {
// In some way set the dataprovider for a List/Datagrid to the attributes of fLayer
// I can iterate the graphics and grab their attributes, but was wondering if there
// was an easier method
} I haven't had much opportunity to use FeatureLayer up to now as I just got all Desktop/Server running ArcGIS 10, so maybe I'm approaching this the wrong way.
... View more
07-19-2010
01:51 PM
|
0
|
0
|
1979
|
POST
|
Well, that's much simpler than my initial approach 😮 In my example above, it's probably simpler making your own ScaleBar, add it to the StaticLayer, print, then remove it. Probably three extra lines of code as opposed to that massive loop I had. Dasa, if I wanted to change the size of the scalebar used outside the map, that can be done with a new Skin correct?
... View more
07-16-2010
11:25 AM
|
0
|
0
|
603
|
POST
|
You can make a new Scalebar, copy it's attributes and place it in the footer or anywhere else on your map. You'd need create a new scalebar skin, which I have not done yet, but ESRI provides the current skins with the API, which is a big help. This is because you need to scale the scalebar to the print page size and just setting the height/width doesn't work. Granted, I have not gotten this far though, so not sure. To copy the scalebar, you can do something like this.
var i:uint = 0;
var x:uint = map.staticLayer.numChildren;
for (i; i < x; i++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(i));
if (map.staticLayer.getChildAt(i) is ScaleBar) {
trace("found the scale bar!");
var s:ScaleBar = new ScaleBar();
s.map = (map.staticLayer.getChildAt(i) as ScaleBar).map;
s.lengthMetric = (map.staticLayer.getChildAt(i) as ScaleBar).lengthMetric;
s.lengthUS = (map.staticLayer.getChildAt(i) as ScaleBar).lengthUS;
s.textMetric = (map.staticLayer.getChildAt(i) as ScaleBar).textMetric;
s.textUS = (map.staticLayer.getChildAt(i) as ScaleBar).textUS;
// you can adjust the bottom/left/top/right values of the map scalebar too
s.bottom = 25;
s.left = 5;
this.addElement(s);
}
}
I copied the attributes of the scalebar, rather than copy it because if I do change the skin or figure out how to scale it, passing it would be reflected in the scalebar on the map, so make sure you copy it. That's as far as I've gotten so far. I'd love to hear some other solutions. edited, because yes, you can capture the scalebar, it's just tricky as Ricky showed above because of the size of the browser window. Ok, so I figured out how to move the scalebar before the image of the map is captured.
map.zoomSliderVisible = false;
map.addEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
var i:uint = 0;
var x:uint = map.staticLayer.numChildren;
for (i; i < x; i++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(i));
if (map.staticLayer.getChildAt(i) is ScaleBar) {
trace("found the scale bar! left =", (map.staticLayer.getChildAt(i) as ScaleBar).left);
// move it into a position that works for you
(map.staticLayer.getChildAt(i) as ScaleBar).left += 200;
}
}
function onUpdateComplete_handler(e:FlexEvent):void {
map.removeEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
mapImage.source = PrintMapUtil.trimmedMap(map, mapImage.width, mapImage.height);
var j:uint = 0;
for (j; j < x; j++) {
trace("What is this object? {0}", map.staticLayer.getChildAt(j));
if (map.staticLayer.getChildAt(j) is ScaleBar) {
// move it back, 5 is the default
(map.staticLayer.getChildAt(j) as ScaleBar).left = 5;
}
}
map.zoomSliderVisible = true;
}
That's tested and works with PrintMapUtil and API2.0.
Well, that was fun, now back to work.
... View more
07-15-2010
12:14 PM
|
0
|
0
|
603
|
POST
|
A quick look at the description of the Shapefile Overlay description says it uses some of this library http://code.google.com/p/vanrijkom-flashlibs/wiki/SHP and Mansour Raad's post here http://thunderheadxpler.blogspot.com/2008/12/shapefile-viewer.html The latest comments also state the file has been updated to include the DBF library needed to show attributes, so you may want to try downloading it again. Looks he compiled them into a nice .swc already. The source should be the same as here http://vanrijkom-flashlibs.googlecode.com/svn/trunk/org/vanrijkom/dbf/ If you check out the example Mansour provides, he also uses that DBF library from the same author to show the attribute data. Unforunately, I don't know of a way to read a .lyr file and parse it in Flex. I don't know enough about the internals of the file for that.
... View more
07-15-2010
05:59 AM
|
0
|
0
|
591
|
POST
|
Try adding the objects to map.staticLayer map.staticLayer.addElement(component) I show an example here adding lat/long coordinates http://odoe.net/blog/?p=67 The docs for Map state, "StaticLayer is useful for adding legends, logos and other items that should not be moved when the map is panned or zoomed." That should work.
... View more
07-15-2010
05:42 AM
|
0
|
0
|
180
|
POST
|
I can reproduce this, but in my case the memory is freed up after a few seconds. Turning a Dynamic Map Service visbility from false to true does add about 4MB of load to the memory. But like I said, when I monitor my app, it clears up after a few seconds. I imagine it has to do with Flash reloading the cached tiles from browser memory, but that's just a guess. Flash Garbage collection can be a bit tricky, you can never really determine when it will happen, you can't force it in a production environment. Best you can do is make sure you remove listeners and unused objects and cross your fingers. 😛
... View more
07-13-2010
01:01 PM
|
0
|
0
|
261
|
POST
|
For the FlexViewer2? I'm not a SFV user, but you could use a List with an ItemRenderer to display the RadioButton. Have the selected value of the RadioButton bind to the Layer.visible property. That would be a quick and dirty way of doing it.
... View more
07-12-2010
02:45 PM
|
0
|
0
|
243
|
POST
|
Hmm, not sure about that one. The Map Service REST would pull the geometries for you. If you are not using an MXD, you'd need to write a Web Service of some sort using ArcObjects to get accesss to those geometries. Haven't tried that specific scenario though.
... View more
07-12-2010
07:24 AM
|
0
|
0
|
458
|
POST
|
Depending on the size of the dataset you want to bring over, you could use the query tool on the REST page to get the data in JSON format and then use FeatureSet.convertFromJSON method to add to your application. http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/FeatureSet.html#convertFromJSON() I do this for some small sets of data for testing purposes. It won't be feasible for a large dataset though, just too much info to parse.
... View more
07-11-2010
06:47 AM
|
0
|
0
|
458
|
POST
|
Center and scale works well, but I use this function after determining it's a single point. You could also have it check geometry type in the function to be safe if you want.
public static function getMapPointExtent(geometry:Geometry):Extent {
if (geometry) {
var mapPoint:MapPoint = geometry as MapPoint;
return new Extent(mapPoint.x, mapPoint.y, mapPoint.x, mapPoint.y, mapPoint.spatialReference);
}
else
return new Extent();
}
... View more
07-08-2010
08:19 AM
|
0
|
0
|
489
|
POST
|
You can't connect directly SQL Server in Flex, but you can use a proxy such as HTTPService or WebService written in your server side language of choice. This link should have a good example in .NET http://codeexpander.blogspot.com/2009/10/connecting-flex-to-sql-server.html You can then send requests to this service from your Flex application for your data.
... View more
07-08-2010
08:06 AM
|
0
|
0
|
272
|
POST
|
I get the same error in IE7, FP 10,1,53,64 But not in Chrome with FP 10,0,45,2 Nice work though.
... View more
07-06-2010
01:35 PM
|
0
|
0
|
852
|
Title | Kudos | Posted |
---|---|---|
1 | 04-11-2022 10:39 AM | |
1 | 4 weeks ago | |
1 | 4 weeks ago | |
1 | 06-04-2024 01:15 PM | |
2 | 06-04-2024 08:28 AM |
Online Status |
Offline
|
Date Last Visited |
3 hours ago
|