Sign in to follow this  
soconne

[web] Asp .net and client callbacks not working correctly

Recommended Posts

I am trying to implement client callback in ASP.NET. I've been using the following tutorial as a reference: http://msdn2.microsoft.com/en-us/library/ms178210.aspx I got it working just fine. But here's my problem. My RaiseCallbackEvent function looks like this:
[source lang="C#]

public void RaiseCallbackEvent(String eventArgument)
{
      returnValue = GetNewMapUrl(eventArgument);
}

Now inside GetNewMapUrl, if all I have it do is return "junk" or some other random string, it works perfectly and inside my website I have an alert go off that returns the string returnValue from the server. No problem here. But my GetNewMapUrl is suppose to generate a new url string from MapPoint and return it to the client. So whenever I put this code in, the callback stops working. I know that the MapPoint code takes about 3-5 seconds to execute b/c of talking to the Microsoft servers, but why would this stop my callback from working? Here is the version of GetNewMapUrl that works:
public string GetNewMapUrl(string coordinates)
{
      return "some string";
}

Here is the version that stops the callback from working.
public string GetNewMapUrl(string coordinates)
{
        // parse coordinates string to get lattitude and longitude
        string[] coords = coordinates.Split(',');
        double NELong = double.Parse(coords[0]);
        double NELat = double.Parse(coords[1]);
        double SWLong = double.Parse(coords[2]);
        double SWLat = double.Parse(coords[3]);

        // set coordinates for map
        ViewByBoundingRectangle[] myViews = new ViewByBoundingRectangle[1];
        myViews[0] = new ViewByBoundingRectangle();
        myViews[0].BoundingRectangle = new LatLongRectangle();
        myViews[0].BoundingRectangle.Northeast = new LatLong();
        myViews[0].BoundingRectangle.Southwest = new LatLong();
        myViews[0].BoundingRectangle.Northeast.Longitude = NELong;
        myViews[0].BoundingRectangle.Northeast.Latitude = NELat;
        myViews[0].BoundingRectangle.Southwest.Longitude = SWLong;
        myViews[0].BoundingRectangle.Southwest.Latitude = SWLat;

        // set map specifications
        MapSpecification mapSpec = new MapSpecification();
        mapSpec.DataSourceName = "MapPoint.NA";
        mapSpec.Views = myViews;
        mapSpec.Options = new MapOptions();
        mapSpec.Options.Style = MapStyle.Terrain;
        mapSpec.Options.Format = new ImageFormat();
        mapSpec.Options.Format.Width = 600;
        mapSpec.Options.Format.Height = 400;
        mapSpec.Options.ReturnType = MapReturnType.ReturnUrl;

        MapImage[] mapImages = render.GetMap(mapSpec);

        return mapImages[0].Url;
}

If I put a return statement right before the line: MapImage[] mapImages = render.GetMap(mapSpec); The function completes correctly and the client gets a callback. But if render.GetMap is allowed to execute it doesn't work. Also, I already know that the above code works because I execute it upon startup and have no problems at all. Anybody have any ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this