Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

GetMap(spec) Exception..Pokect Application

This is a discussion on GetMap(spec) Exception..Pokect Application within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm using the method findNearbySpec and I proved this method in a pocket application. I found many places but there ...

  1. #1
    luisfdo is offline Junior Member White Belt
    Join Date
    May 2005
    Posts
    8

    GetMap(spec) Exception..Pokect Application

    I'm using the method findNearbySpec and I proved this method in a pocket application. I found many places but there is an error that i can quit.

    SystemNullReferenceException //when I try to use GetMap

    Code:
    MapImage[] mapImgs;
    mapImgs = render.GetMap(spec);
    Bitmap bMap = new Bitmap(new System.IO.MemoryStream(mapImgs[0].MimeData.Bits));
    pictureMapPoint.Image=bMap;
    I prove the same code in a windowsApplication a and that wroks fine. I view the the map.

    I prove the find method findAddressSpec and the GetMap in the pocket, I don't have any Exception, and I see the map

    Does anyone one the problem??

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: GetMap(spec) Exception..Pokect Application

    Hi,

    Eahter render or spec is probably null. Can you not check with debugger ?

  3. #3
    luisfdo is offline Junior Member White Belt
    Join Date
    May 2005
    Posts
    8

    Hi, Wilfried

    Noup, they are not null, neither spec, nor render

    and the problem is that the same code is working fine in a windowsApplication (not in the pocketApplication)


  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    please show the code you use in GetMap(). probalbly the problem is in there.

  5. #5
    luisfdo is offline Junior Member White Belt
    Join Date
    May 2005
    Posts
    8

    Hi, look..

    Code:
    MapView[] views = new MapView[1];
    ViewByScale viewByScale = new ViewByScale();
    viewByScale.CenterPoint = llCenter;
    views[0] = viewByScale;
    MapSpecification spec = new MapSpecification();
    
    spec.DataSourceName="MapPoint.NA";
    spec.Views=views;
    spec.Options=options;
    spec.Pushpins=myPushPins;
    
    render = new RenderServiceSoap();
    render.Credentials = new System.Net.NetworkCredential(User,Pass);
    render.PreAuthenticate=true;
    
    MapImage[] mapImgs;
    mapImgs = render.GetMap(spec);
    Bitmap bMap = new Bitmap(new System.IO.MemoryStream(mapImgs[0].MimeData.Bits));
    						
    pictureMapPoint.Image=bMap;
    The problem is in this line
    Bitmap bMap = new Bitmap(new System.IO.MemoryStream(mapImgs[0].MimeData.Bits));

    Thank you.. I already send you the code by mail.

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    If you have a null exception in the bitmap line, then I assume render.GetMap(spec); did not return an array, so you have always to do a check if it is uncertain what the function return. in this case something like this you should code:

    Code:
                if (mapImgs != null && mapImgs.Length > 0)
                    Bitmap bMap = new Bitmap(new System.IO.MemoryStream(mapImgs[0].MimeData.Bits));
    I got your mail but I cannot compile it as it contains many things I dont have. sorry.

  7. #7
    mcmcom is offline Junior Member White Belt
    Join Date
    Jan 2006
    Posts
    2
    I am having the exact same problem and i will provide more information. I ported the RouteMap.cs asp.net sample from the quickstarts in the MapPoint SDK. Everything works find and it uses the web service and returns route information (i can print the list of directions between two points). What happens is the RenderMap() call does in fact return a MapImage[] object (in my case always with one item in the array).
    This one item contains everything needed to render the map With the exception of ANY MIME DATA OR a URL (depending on the return type i have selected). I have ran this as well on a desktop and it works, it just seems that the RenderMap function will not return either a Url or an actual image.

    I am new to this but am fairly experienced with C# programming and am totally lost. I keep going over my code trying to find some issue with the MapSpecification object im passing, but nothign is wrong.

    Here is some information about the object im passing and the object im getting:

    please not this is a small portion of the code, the route has already been calculated and the map address is assigned prior to this.

    Code:
    	//Set up the map options
    					MapOptions myMapOptions = new MapOptions();
    					myMapOptions.ReturnType = MapReturnType.ReturnImage; 
    					myMapOptions.Format = new ImageFormat();
    					myMapOptions.Format.Height = 500;
    					myMapOptions.Format.Width = 500;
    
    					//Set up the specification object
    					ViewByBoundingRectangle[] myMapViews = new ViewByBoundingRectangle[1];
    					myMapViews[0] = myRoute.Itinerary.View.ByBoundingRectangle;
    
    					MapSpecification mapSpec = new MapSpecification();
    					mapSpec.Views = myMapViews;
    					mapSpec.Options = myMapOptions;
    					mapSpec.DataSourceName = "MapPoint.NA";
    					mapSpec.Pushpins = myPushPins;
    					mapSpec.Route = myRoute;
    That sets up the options and specification object

    Here is the only Item in the Map Array that is returned, as you can see there is 3 hotspots, but no MimeData (as there should be because the return type is image):

    Any Ideas?!?!?
    thanks


    System.Object {mcMapper.net.mappoint.MapImage} System.Object
    + HotAreas {Length=3}

    - [0] {mcMapper.net.mappoint.HotArea} mcMapper.net.mappoint.HotArea
    System.Object {mcMapper.net.mappoint.HotArea} System.Object
    IconRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    LabelRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    PinID null string
    - [1] {mcMapper.net.mappoint.HotArea} mcMapper.net.mappoint.HotArea
    System.Object {mcMapper.net.mappoint.HotArea} System.Object
    IconRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    LabelRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    PinID null string
    - [2] {mcMapper.net.mappoint.HotArea} mcMapper.net.mappoint.HotArea
    System.Object {mcMapper.net.mappoint.HotArea} System.Object
    IconRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    LabelRectangle <undefined value> mcMapper.net.mappoint.PixelRectangle
    PinID null string


    mcMapper.net.mappoint.HotArea[]
    MimeData <undefined value> mcMapper.net.mappoint.MimeData
    Url null string
    View <undefined value> mcMapper.net.mappoint.MapViewRepresentations

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I cannot find MapOptions or MapSpecification. Where can I find it ? Is this Mappoint or something from the pocket application ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. OutOfMemory Exception
    By Gianmaria in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-24-2006, 01:26 PM
  2. Regarding COM exception at the end of execution...
    By Anonymous in forum MP2K Magazine Articles
    Replies: 0
    Last Post: 05-12-2005, 01:23 PM
  3. Recordset exception. What am I doing wrong?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 01-25-2005, 03:26 PM
  4. AddPushPin() throws exception in VC++
    By radboudp in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-20-2005, 07:49 PM
  5. GetMap time
    By sbedin in forum Bing Maps and MapPoint Web Service
    Replies: 1
    Last Post: 01-12-2005, 11:41 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96