Select to view content in your preferred language

New featurelayer feature not showing up automatically

702
4
09-27-2012 05:54 AM
TylerWaring
Occasional Contributor II
Greetings Everyone,
I am editing a feature layer using the applyEdits and refresh methods like so:

editFeatureLayer.applyEdits([ lastDrawnGraphic ], null, null);
editFeatureLayer.refresh();

The new feature gets recorded in the database but does not show up in the map automatically. To get the new feature to show up I have to manually pan or zoom in a little.

How do I get the new feature to display automatically?

Thanks, Tyler
Tags (2)
0 Kudos
4 Replies
TylerWaring
Occasional Contributor II
Greetings Everyone,

I ended up creating a MapPoint and setting it's x and y properties equal to the slightly adjusted center of the map's extent using the following chunk of code:

var centerAt:MapPoint = new MapPoint;
centerAt.x = map.extent.center.x;
centerAt.y = map.extent.center.y -0.1;//slight adjustment

Following that, I reset the map's centerpoint to the slightly adjusted centerpoint with the following line of code.

map.centerAt(centerAt);

By readjusting the maps centerpoint my featuerLayer is forced to redraw and my new feature auto-magically appears.

While this works fine for my purposes, I can't help feeling like there is a better way.

Any suggestions will be greatly appreciated.

Thanks, Tyler
0 Kudos
IvanBespalov
Regular Contributor
Try to set FeatureLayer.disableClientCaching = true.

Also, search this forum for 'disableClientCaching':
[ATTACH=CONFIG]18062[/ATTACH]
0 Kudos
TylerWaring
Occasional Contributor II
I just checked my client caching and I already have it disabled. Hmmm...

Thanks, Tyler
0 Kudos
SarthakDatt
Occasional Contributor III
Hey Tyler,

I think you are calling layer.refresh() too soon. You can listen for the 'edits complete' event to fire on the feature layer and then call refresh()

Something like:


editFeatureLayer.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, editFeatureLayer_editsCompleteHandler);
editFeatureLayer.applyEdits([ lastDrawnGraphic ], null, null); 

private function editFeatureLayer_editsCompleteHandler(event:FeatureLayerEvent):void
{     
      // You can also check if the edit was a success
      editFeatureLayer.refresh();
}



Hope that helps.
0 Kudos