.Net Web Control + Operation Aborted
I am trying to create a .Net Web Control, embedding the VE control + javascript within the control, exposing some clean properties/methods etc. so I can host from other pages.
When I run the simplest of maps, I see the map appear then I get an "operation aborted" exception from the browser.
Presumably this is caused by some VE Javascript running before the entire page hosting the control is complete or something?
Anyone have any ideas?
Hi Dave,
Yup, I'm surprised there isn't more on this out there. The key is to make sure that everything is loaded before invoking the map stuff. I use the following Javascript:
function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function')
{ window.onload = func; }
else
{ window.onload = function()
{ oldonload(); func(); }
}
}
I pass the standard "GetMap();" function as seen on the VE demo site like this:
<script>addLoadEvent(GetMap);</script>
In the same place I add other (asp.net generated) functions which do stuff to the map.
Hope that helps
Dave Felcan
Sounds similar to my solution - I essentially build my javascript functions for VE in the Web Control and then have the hosting page execute it, once it's finished loading the pafe.
I believe this is more of an AJAX issue in general so it's bound to pop up more and more now!
Phew. That solution really saved some bother!
Incase anybody else is having the same problem, I was getting 'unexpected call to method or property access' when I attempted to add a polyline to a map. Other mapping stuff was working, and the problem only surfaced on IE7, after I updated to MS Ajax Beta 1. Although my error was different to what is mentioned above, I was pretty sure it was timing related.
I was using the MS Ajax 'onLoad' function to start all the map related stuff going (see the MS Ajax and VE4 thread), but for some reason, this seems to behave differently under beta2, as it should fire after MS ajax is loaded and the page is ready. I guess in B2 MS Ajax may load before the page is ready, or it's a bug.
So for future reference, this is how I load stuff when you use MS Ajax and script to play with the map:
addLoadEvent(MapLoad);
function
addLoadEvent(func) {
var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; }
else { window.onload =
function() { oldonload(); func(); }
}
}
function
MapLoad(){
map =
new VEMap('myMap'); //callback when it loads
map.onLoadMap = OnMapLoad();
map.LoadMap(
new VELatLong(54.40, -0.85), 9 ,'r', false); }
//map has loaded - so we can play with it
function
OnMapLoad(){
//do code which poll the web service to get stuff to draw - could be any other code
Thanks guy!