Refresh featureLayers automatically on extent change

599
5
07-10-2013 04:48 AM
RyanWhiley
New Contributor
Hello,

I'm currently experiencing some trouble with my zoom functions.  Whenever I zoom or enter a search on my application, the extent changes to the proper location, but the map just remains blurry and nothing can be seen.  I have tried all the solutions from this" rel="nofollow" target="_blank">http://forums.arcgis.com/threads/48229-Is-there-a-way-to-refres... thread but none of them worked.  I attached a featureLayer.refresh() to my centerAndZoom but that did not work either.  I have also added the below code to my proxy according to the last post on this" rel="nofollow" target="_blank">http://forums.arcgis.com/threads/54774-Disable-Caching-on-Featu... thread
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
But that did not work either.  So I am just not really sure how to go about fixing this.  It appears that there have been a few people who have managed to solve this issue but I have not been able to solve it with their solutions.  Any assistance anyone can give me would be greatly appreciated.

Thanks!
Ryan
0 Kudos
5 Replies
DianaBenedict
Occasional Contributor III
Ryan

Sometimes I will see this behavior when there is an error in my code. Do you currently have code running when the map extent changes? I would do the following to try to track down the issue:

1) comment out any code that you have in any callbacks to extent change
2) use Chrome or IE 9 to view the developer tools (ctrl-shift-I for chrome and F12 for IE9)
3) In the dev tools window, look at the console for any errors/exceptions thrown

Once you have confirmed that you do not have any exections being thrown then you can start uncommenting sections of your code to see where the issue is. Note that there is a property for esri.layers.ArcGISDynamicMapServiceLayer called disableClientCaching .. you can set that to true.

Good luck
0 Kudos
RyanWhiley
New Contributor
Hi Diana,

Thanks for the reply.  I currently have no code running when the extent changes.  And I used to the console to look for errors/exceptions and several showed up.  They were all quite similar though. 
Resource interpreted as Script but transferred with MIME type text/plain:
 "http://curacaogis.com/ArcGIS/rest/services/Ryan/Ryan_Service/FeatureServer/�?�jsonp_dojoIoScript_Primary_Roads11_1_1943285668547_56_20221._jsonpCallback".    
 serverapi.arcgisonline.com/:34
  The link appears to just be a query, and all the errors that it returned were like that just with different queries.  I googled the error and most people were saying that you would need access to the target server to change the content type from text/plain to Javascript.  I could have access to the target server but I do not feel like that is the case because the zoom worked fine a while ago.  But then I began adding more capabilities to the application and it stopped working. 


I have made some progress where when I enter the search, the program zooms to the location but then it just takes a long time to load.  When I pan around everything loads just fine, it is just when I change the zoom that it is very slow to load.  So I was thinking that it might possibly be loading all the tiles at a certain zoom level which is why it takes a while to load when zoom changes, but not when it pans.  I'm not sure if this is the case though, or how I would go about fixing it if it was.  If you could help point me in the right direction I'd really appreciate it.


Thank you!
Ryan
0 Kudos
DianaBenedict
Occasional Contributor III
Ryan

At one point I also got some weird behavior when I did not have the correct header information in my HTML here is an example of my header information. Make sure that the meta tags look right and also check out the script tags and ensure that it all looks correct as well.

[HTML]
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,8,9,10" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> 
    <title>Add your Title here!</title>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css"/>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox/grid/resources/Grid.css"/>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox/grid/resources/ClaroGrid.css"/> 
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox/layout/resources/FloatingPane.css"/>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox/layout/resources/ResizeHandle.css"/>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css" />
    <link rel="stylesheet" href="css/defaultStyle.css"/>

    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5"></script>  
    <script type="text/javascript">
      //add your JS code or include whatever code you run to initialize your map
    </script>
</head>

..all the HTML body stuff goes down below
[/HTML]
0 Kudos
RyanWhiley
New Contributor
Diana,


I just went through and made sure everything in my header is fixed but I am still getting the same errors in the console.  I'm not very proficient in JS, but I still feel like it has something to do with loading the graphics when I zoom.  Because whenever I pan the tiles load all right, I only have an issue when I zoom.  So I'm not really sure if this is a common problem or not, but if you have any idea of ways I could look further into that I'd be really grateful.


Thank you!
Ryan
0 Kudos
DianaBenedict
Occasional Contributor III
What kind of layers do you have loaded in your map?
- ArcGISDynamicMapServiceLayer
- ArcGISTiledMapServiceLayer
- FeatureLayer

What Spatial Reference are you setting?

Are you using an ESRI basemap?

If you are using FeatureLayer what mode are you  using?
If you are using OnDemand then what is your scale dependency?
Note that OnDemand will attempt to retrieve ALL of the graphics/features in your map display till it hits the magic 1K features .. some browsers will sit and spin for a while until it has retrieved all the graphics. This can also be very server and client intensive if you do not have a scale threshold set on your feature layers.

If you are using cached tiles then do the spatial reference match the map spatial reference
if you have more than 1 cached tile then do the LODS match?

These are just some questions that come to mind in order to evaluate your issues.
0 Kudos