JavaScript API 3.0 - Problems when adding/panning layers

1281
12
Jump to solution
06-19-2012 03:36 PM
by Anonymous User
Not applicable
Hello JSAPI folks,

I have found that when I upgrade to 3.0, and account for all of the noted changes needed to make the transition from 2.x, I find that there are problems panning the map when multiple feature and or graphics layers are added .

After a fair bit of debugging, I have narrowed this down to at least one clearly repeatable scenario.  If a featureLayer is added to the map, then I create a new graphics layer with visible set to false, add this layer to a map, then make the graphics layer visible, the initially added feature layer seems to be 'forgotten' by the map when you pan.

I have attached a modified copy of one of the JavaScript API samples that are now using version 3.0 of the API.  If you open this sample in a web browser, you'll see a green dot added to a graphics layer near the centre of the map.  When you pan the map, the base layer and the graphics layer will move, but the feature layer (showing the great lakes) will remain static.

If the feature layer is added after the graphics layer is added, or if the graphics layer is visible when it is first added, this problem does not occur.

The comments in the sample HTML document should help explain what's going on.

Would this be considered a bug?
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
We updated version 3.0 of the JavaScript API last night to add a small patch to fix the panning issue and a minor problem with the BasemapGallery. So if you re-test your code today using v3.0 the problem should be resolved.

View solution in original post

0 Kudos
12 Replies
SteveDale
New Contributor
Hi,
I have similar problems.  I add 2 Feature layers (on Demand mode)- pan the map and only 1 layer is refreshed at 3.0. Switch back to 2.8 and it works.  I am hitting server 9.3.1.

I have attached sample code as well.

Steve
0 Kudos
MattLane
Occasional Contributor II
I struggled through graphics layers causing the map to pan strangely yesterday. I originally was adding two graphics layers immediately after adding other layers, and my solution was to delay creating the graphics layer until I was actually working with it.

var graphics = map.getLayer("parcel-results") || map.addLayer(new esri.layers.GraphicsLayer({ id: "parcel-results" }));
0 Kudos
SteveDale
New Contributor
Hi,

Feature layer panning works properly if you add layers that are visible on the map (not scale dependent).  If I comment out the extent in the code below, and zoom to the layers, panning will break.

Steve


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>     
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />  
 <!--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>FeatureLayer On Demand</title>     
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.css">    
 <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; }   
 </style>    
 <script type="text/javascript">djConfig = { parseOnLoad:true };</script>    
 <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0"></script>     
 <script type="text/javascript">       
dojo.require("esri.map");      
dojo.require("esri.layers.FeatureLayer");      
dojo.require("dijit.form.Button");      
dojo.require("dijit.Dialog");           
var map;      

function init() {  
 map = new esri.Map("map");  
 var extent = new esri.geometry.Extent(316500, 4837500, 317600, 4838500, new esri.SpatialReference({
   wkid: 2019
  }));
        // comment out set extent to break panning!
 map.setExtent(extent, true);           
 dojo.connect(map, "onLoad", initOperationalLayer);        
 var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://gis.toronto.ca/arcgis/rest/services/primary/cot_basemap_mtm/MapServer");        
 map.addLayer(basemap);        
}      
function initOperationalLayer(map) {                
  var featureLayer1 = new esri.layers.FeatureLayer("http://gis.toronto.ca/arcgis/rest/services/primary/cot_geospatial_mtm/MapServer/98",
   {mode: esri.layers.FeatureLayer.MODE_ONDEMAND ,displayOnPan:false});       
   featureLayer1.renderer = new esri.renderer.SimpleRenderer(new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
    new dojo.Color([255,0,0]), 1),
    new dojo.Color([255,0,0,1])));
   map.addLayer(featureLayer1);

   var featureLayer2 = new esri.layers.FeatureLayer("http://gis.toronto.ca/arcgis/rest/services/primary/cot_geospatial_mtm/MapServer/112",
    {mode: esri.layers.FeatureLayer.MODE_ONDEMAND , displayOnPan:false});        
   
   featureLayer2.renderer = new esri.renderer.SimpleRenderer(new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10,
    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
    new dojo.Color([0,255,0]), 1),
    new dojo.Color([0,255,0,1])));
   
   map.addLayer(featureLayer2);                 
}      
  
dojo.addOnLoad(init);    
</script>   
</head>   
<body class="claro">     
<div style="position:relative;width:100%;height:100%;">       
<div id="map" style="width:100%;height:100%;">        
<div style="position:absolute; left:100px; top:10px; z-Index:999;">           
</div>       
</div>    
</div>   
</body> 
</html>

0 Kudos
KellyHutchins
Esri Frequent Contributor
We updated version 3.0 of the JavaScript API last night to add a small patch to fix the panning issue and a minor problem with the BasemapGallery. So if you re-test your code today using v3.0 the problem should be resolved.
0 Kudos
SteveDale
New Contributor
Hi Kelly,
Yes.. It is fixed now.
Thanks,
Steve
0 Kudos
AdrianMarsden
Occasional Contributor III
Alas, not fixed for me.  Cleared browser cached and still Pan fails - works fine with middle button, but not primary button.

ACM
0 Kudos
by Anonymous User
Not applicable
I'm definitely not able to produce the problem any more in any of my samples.

Can you create a test case that demonstrates the problem...?
0 Kudos
AdrianMarsden
Occasional Contributor III
alas the system is internal at the moment.

Can this thread be merged with this one

http://forums.arcgis.com/threads/60121-Pan-Issues-on-Migrate-to-3.0?p=207528#post207528

As it seems like the same issue

?

ACM
0 Kudos
derekswingley1
Frequent Contributor

Can this thread be merged with this one

http://forums.arcgis.com/threads/60121-Pan-Issues-on-Migrate-to-3.0?p=207528#post207528

As it seems like the same issue


I don't think we have the ability to merge threads.

The issue that was described in this thread and the other thread you linked to has been fixed in the version of 3.0 currently hosted on our CDN. If you're still seeing a problem, it's probably best to start a new thread that includes code to reproduce the issue.
0 Kudos