Select to view content in your preferred language

Dynamic Map requests same image consecutively

788
2
Jump to solution
10-09-2013 04:49 AM
EdwardRozum
Occasional Contributor
Hey all,

I have been tracking an issue at initial application load. When I add my dynamic map layer, it is making the exact same image call to the server twice consecutively. This only happens on the initial load of the map, when the layer is added. After that, the map calls are made as expected, which would be one image call per pan or zoom. Has anyone experienced this? Does anyone know what could trigger another map image request, not including a pan and zoom action. I have attached a screenshot of the request happening real time in fiddler. I will past the full urls of the requests below as well. I would appreciate any assistance in tracking down what exactly is happening.

Thanks

Eddie

51 200 HTTP vzwmaptest.verizonwireless.com /ArcGIS/rest/services/VZW_MOBILE_COV/MapServer/export?dpi=96&transparent=true&format=PNG8&layers=show%3A20&bbox=-14782321.297432182%2C2739888.6794155603%2C-6436620.801145716%2C6956766.655851042&bboxSR=102100&imageSR=102100&size=853%2C431&f=image 23,971 max-age=86400   image/png firefox:6304
  
52 200 HTTP vzwmaptest.verizonwireless.com /ArcGIS/rest/services/VZW_MOBILE_COV/MapServer/export?dpi=96&transparent=true&format=PNG8&layers=show%3A20&bbox=-14782321.297432182%2C2739888.6794155594%2C-6436620.801145716%2C6956766.655851042&bboxSR=102100&imageSR=102100&size=853%2C431&f=image 23,971 max-age=86400   image/png firefox:6304
0 Kudos
1 Solution

Accepted Solutions
EdwardRozum
Occasional Contributor
Ok guys, just in case anyone else ever has this problem, here is how I solved it.

1.) I attached an onUpdaetEnd event to my cached map layer.
dojo.connect(map, "onUpdateEnd", addDynamicLayers);

2.) I created a function that checked if this was the initial application load, then added the dynamic maps on top
function addDynamicLayers() {
    if (isFirstRun) {
        map.addLayers([dynamicMapServiceLayer, poiMapServiceLayer]);
        isFirstRun = false;
    }
}

Previously I added all layers at the same time in my init function as follows.
map.addLayers([cachedMapServiceLayer, dynamicMapServiceLayer, poiMapServiceLayer]);

Because I was resizing the map after the dynamic layers were already added, it caused them to make unnecessary calls back to the server for the same image at load time. So basically I just decided to add the dynamic layers after the cached map was fully updated and drawn. This prevented them from re-requesting images.

I hope that makes sense.

Thanks

Eddie

View solution in original post

0 Kudos
2 Replies
EdwardRozum
Occasional Contributor
I have narrowed the issue down to my custom resize map function. Because I am developing for mobile, I am resizing the map div after I determine device and screen size. I then call map.resize(); map.reposition(); to resize and position the map. This is where the multiple calls occur. The question I have now is, how do I determine when these two methods are finished? I tried adding a callback function to the resize map function that contains these two function calls, but that does not work. Is there an event or callback available for these functions? If not, how do I determine when the map is finished being resized and positioned.

Thanks

Eddie
0 Kudos
EdwardRozum
Occasional Contributor
Ok guys, just in case anyone else ever has this problem, here is how I solved it.

1.) I attached an onUpdaetEnd event to my cached map layer.
dojo.connect(map, "onUpdateEnd", addDynamicLayers);

2.) I created a function that checked if this was the initial application load, then added the dynamic maps on top
function addDynamicLayers() {
    if (isFirstRun) {
        map.addLayers([dynamicMapServiceLayer, poiMapServiceLayer]);
        isFirstRun = false;
    }
}

Previously I added all layers at the same time in my init function as follows.
map.addLayers([cachedMapServiceLayer, dynamicMapServiceLayer, poiMapServiceLayer]);

Because I was resizing the map after the dynamic layers were already added, it caused them to make unnecessary calls back to the server for the same image at load time. So basically I just decided to add the dynamic layers after the cached map was fully updated and drawn. This prevented them from re-requesting images.

I hope that makes sense.

Thanks

Eddie
0 Kudos