Select to view content in your preferred language

Getting AGSDynamicMapServiceLayer to refresh programmatically

811
2
12-14-2012 05:46 AM
ChristopherDillard
Deactivated User
I have an ArcGIS Server (10.1 SP1) REST map service whose underlying data (in ArcSDE) is changing constantly.  And I have an AGSDynamicMapServiceLayer that renders that map service in my app.  (It's running in iOS 6.)

I want to periodically (e.g. every 60 seconds) refresh the map to see the latest data.  However, I can't seem to do it without panning or zooming.

I've tried invoking dataChanged on the layer, i.e.:
AGSDynamicMapServiceLayer* layer = ...;
[layer dataChanged];

...but it has no effect.  I've tried invoking clear on the layer's view, i.e.:
AGSMapView* mapView = ...;
UIView<AGSLayerView>* layerView = [mapView.mapLayerViews objectForKey:layer.name];
[layerView clear];

...but that has no effect either (other than causing that layer to flash quickly, but reappear exactly as it was).

Is there some way to force a refresh from the server?

Is it perhaps a caching issue at the operating system level, since the URL of the exported image is the same?
0 Kudos
2 Replies
PhilippFauser
Emerging Contributor
Have you tried to remove the layer and then add it again to the mapview? Maybe that works.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Try this and let me know if it does not work...

//remove all url cache
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[layer dataChanged];

Regards,
Nimesh
0 Kudos