Select to view content in your preferred language

Is there a way to refresh the graphics on the map?

4447
8
Jump to solution
01-20-2012 09:53 AM
MikeOnzay
Regular Contributor
I have a feature layer that might display a feature that is comprised of 4 (sub-)features. I want to be able to show just one of those graphics by clicking on some text. Actually, I can do that but the map only displays that other feature if I change the extent. Is there another way to refresh the screen by not changing the extent?
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor II
Layers (including feature layers and graphics layers) and individual graphics have show() and hide() methods. If you want to control individual graphics, you can use show() or hide() on the graphic.

View solution in original post

0 Kudos
8 Replies
derekswingley1
Frequent Contributor II
Layers (including feature layers and graphics layers) and individual graphics have show() and hide() methods. If you want to control individual graphics, you can use show() or hide() on the graphic.
0 Kudos
DougCollins
Occasional Contributor
I have one background street layer and one feature layer with points in it, and after doing a map.centerAndZoom() to one of the points the points either don't show up or they are so large that it blurs the screen.  I tried the "hide()" and "show()" methods but they do not help at all.  The only way to get everything in focus is to move the map a bit to refresh the extent, as the previous poster suggested.

So is there another way to refresh a feature layer that will work?

Charlie
0 Kudos
JosephHarris1
New Contributor
I have one background street layer and one feature layer with points in it, and after doing a map.centerAndZoom() to one of the points the points either don't show up or they are so large that it blurs the screen.  I tried the "hide()" and "show()" methods but they do not help at all.  The only way to get everything in focus is to move the map a bit to refresh the extent, as the previous poster suggested.

So is there another way to refresh a feature layer that will work?

Charlie



Did you ever find resolution to this ?? I am having this exact same problem.

Moving the map a bit gives me the functionality that I need, but I want to simulate that func by the use of a "refresh" button on the screen. Please help Esri support.

Thanks.
0 Kudos
Jay_Gregory
Regular Contributor
If you are using a featurelayer, it supports refresh() and redraw() methods.  refresh() requeries the server, while redraw() just gets redraws the data from cache.  I don't see these methods documented in the API, but there were there before, and I've been using them for a while...

Jay
0 Kudos
JosephHarris1
New Contributor
If you are using a featurelayer, it supports refresh() and redraw() methods.  refresh() requeries the server, while redraw() just gets redraws the data from cache.  I don't see these methods documented in the API, but there were there before, and I've been using them for a while...

Jay



hmmm, refresh() doesn't seem to do anything.

map.refresh();

Or am I using the incorrect syntax ?
0 Kudos
Jay_Gregory
Regular Contributor
It's featureLayer.refresh() not map.refresh(). Does that work for you?

hmmm, refresh() doesn't seem to do anything.

map.refresh();

Or am I using the incorrect syntax ?
0 Kudos
DimitarKolev
New Contributor II
featureLayer.refresh() worked for me, but if a feature is deleted or symbology changed the IE9 browser does not update/redraw the layer. I guess it reads from its cash insdead of making request to the server.
The solution for me was to modify the request with preventCache = true;
I saw the solution in another post and tweek it to work with ArcGIS 10.1 and JavaScript 3.3 API 

 
function init() {
            //modify the request with a preventCache option before it is sent to the server
            // so the feature layer is not cached in the browser
            esri.setRequestPreCallback(function (ioArgs) {
                try {
                    if (ioArgs.url.indexOf("FeatureServer") > -1 &&
                    ioArgs.content.returnGeometry == true) {
                        ioArgs.preventCache = true;
                    }
                    return ioArgs;

                } catch (e) {
                    console.log(e.toString());
                    return ioArgs;
                }
               
            });
   
   //... initialize map here ...

}
0 Kudos
Mindaugas_ižas
New Contributor
I had this problem for a very long time, but it looks that managed to find the solutions.
It is only if you use proxy page.
Just add
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
to your proxy.jsp and all the requests will not be cached.
I am using JSAPI 2.8 and server 10.0

Hope this helps
0 Kudos