Wondering if somebody could give me some insight into what could be going wrong with this and how to debug it.
I have a map that refreshes automatically every 30 seconds via an Timer, the timer calls a method on the backend that gets a vehicles overlay and then goes through each vehicle and updates the appropriate layers, 3 per vehicle. I can see that the layers are updating successfully via debugging. The method that does the updating has the following code:
private void UpdateVehicles(bool registerScript) {
Hashtable assets = (Hashtable)Session["liveMapAssets"];
Hashtable loadTimestamps = (Hashtable)Session["loadTimestamps"];
DateTime toTimestamp = DateTime.Now;
// Clear all the points from the global point layer.
LayerOverlay pointOverlay = (LayerOverlay)mapControl.CustomOverlays["points"];
((InMemoryFeatureLayer)pointOverlay.Layers["pointLayer"]).InternalFeatures.Clear();
// Now do the updating...
IEnumerator enumerator = assets.Values.GetEnumerator();
LayerOverlay overlay = (LayerOverlay)mapControl.CustomOverlays["vehicles"];
while(enumerator.MoveNext()) {
Asset asset = (Asset)enumerator.Current;
MapRenderingUtils.updateVehicle(asset, (DateTime)loadTimestamps[asset.AssetId], toTimestamp, mapControl);
}
overlay.Redraw();
if(registerScript) {
ScriptManager.RegisterStartupScript(this, this.GetType(), "UpdateVehicles", "updateVehicles()", true);
}
}
Then on the client I have this code:
[script removed]
var olMap;
document.body.onresize = pageSizeChanged;
function OnMapCreated(map) {
olMap = map;
pageSizeChanged();
}
function updateVehicles() {
var overlay = olMap.getLayer("vehicles");
overlay.redraw(true);
}
function pageSizeChanged() {
var scrollHeight = parseInt((self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)));
var pageContainer = document.getElementById("pageContainer");
var newHeight = (scrollHeight - 26) + 'px';
pageContainer.style.height = newHeight;
}
[script removed]
The update vehicles method seems to be being called because I can see them being invoked in the debugger and the layer is retrieved successfully but nothing changes on the map.
Thanks.
Curtis