GetMap(spec) Exception..Pokect Application

luisfdo
05-24-2005, 11:49 AM
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

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??

Wilfried
05-24-2005, 01:33 PM
Hi,

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

luisfdo
05-24-2005, 01:48 PM
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)

:?

Wilfried
05-24-2005, 02:42 PM
Hi,

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

luisfdo
05-24-2005, 06:07 PM
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.

Wilfried
05-25-2005, 02:33 AM
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:

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.

mcmcom
01-28-2006, 10:36 AM
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.


//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

Wilfried
01-29-2006, 10:38 AM
Hi,

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

 
Web mp2kmag.com
mapforums.com