Register  |  Login   Search
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |  Developer Community
 
LivePerson Chat

Discussion Forums

The online community for users of Map Suite GIS components

Render World Error "Invalid parameter used." + general RenderWorld comments
Last Post 08-24-2005 11:24 AM by ThinkGeo. 7 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
DannyUser is Offline
Level 1
Level 1
Posts:6

--
08-19-2005 06:44 AM
I am getting this error which is mentioned in the "Map Engine Forum"(http://spatiallyaware.com/default.aspx?tabid=30&frmView=ShowPost&PostID=933#939) but whenever I first try and run Renderworld rather than after repeat runnings. This is proving extremely infuriating and is a complete show stopper so a quick reply would be great!

The sample app seems to work okay, but if I take this code from the sample app:

Private mShapefileData As String = "D:\RenderWorldData"
Private mFullExtent As New RectangleR(-179.9, 89.9, 179.9, -89.9)

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim mRenderWorld As RenderWorldWebforms.Renderers
Map1.MapUnit = MapLengthUnits.DecimalDegrees
mRenderWorld = New RenderWorldWebforms.Renderers(mShapefileData)
mRenderWorld.LoadUSALayers(Map1.Layers, Map1.CurrentExtent)
Map1.CurrentExtent = mFullExtent
Map1.CanvasColor = Color.LightGoldenrodYellow
End If
End Sub

and put it in to my C# webpage as:

private void Page_Load(object sender, System.EventArgs e)
{
string mShapefileData = @"D:\RenderWorldData";

RectangleR mFullExtent = new RectangleR(-179.9, 89.9, 179.9, -89.9);

if (!IsPostBack)
{
RenderWorldWebforms.Renderers mRenderWorld;
Map1.MapUnit = MapLengthUnits.DecimalDegrees;
mRenderWorld = new RenderWorldWebforms.Renderers(mShapefileData);
mRenderWorld.LoadUSALayers(Map1.Layers, Map1.CurrentExtent);
Map1.CurrentExtent = mFullExtent;
Map1.CanvasColor = Color.LightGoldenrodYellow;
}

}

then reference the RenderWorldWebForms dll then I get this error:

Exception Details: System.ArgumentException: Invalid parameter used.

Stack Trace:

[ArgumentException: Invalid parameter used.]
System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
MapSuite.Webforms.Map.GetMap()
MapSuite.Webforms.Map.CreateCanvas()
MapSuite.Webforms.Map.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()


Given I have only changed the source of the RenderWorldData to D:\ instead of C:\ I can't see why this is causing such a fuss can you? This is urgent as I can make no progress as things stand and people are waiting on these maps actually working.

FYI: When I decided to reference the VB Renderworld project and watched it step through, it adds ALL of the layers without error. This error only comes up once you finish and exit the page_load sub and the web page starts coming up to finish loading.

Important:
Whilst I am posting, might I ask why the sample app we get is still bound to source control and are ONLY in VB.Net???! Have I been sent a pre-release version or something? My RenderWorldWebforms1.0.zip contains the VB projects but with files like "RenderWorldWebForms.vssscc" in there. So I have to start them up, Work Disconnected (It complains about source control naturally as I don't have access to your VSS server) and then change source control to unbind them.

Given that the Webforms evaluation version had C# examples why does RenderWorld not?

I look forward to your reply so that I can start to make some progress.
ThinkGeoUser is Offline
MVP
MVP
Posts:1591
Avatar

--
08-19-2005 01:25 PM
Thank you for the post.

What does your Map declaration look like in the HTML? We were able to take your code and have it work in C# without any problems. Our HTML for the map declaration looks like the following:



Sorry about the source control connection, when this was packaged up it must have been inadvertently left bound to source control.
DannyUser is Offline
Level 1
Level 1
Posts:6

--
08-22-2005 04:46 AM
My line is (was):

'Less than sign'cc1 id="Map1" runat="server"'Greater than sign''Less than sign'/cc1:Map'Greater than sign'

I just figured it out. I hadn't set the colors and width height in the tag, only in code. I copied your line exactly and it worked straight away. Thanks for your help.



ThinkGeoUser is Offline
MVP
MVP
Posts:1591
Avatar

--
08-22-2005 08:27 AM
>>System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
>>MapSuite.Webforms.Map.GetMap()
>>MapSuite.Webforms.Map.CreateCanvas()

This part is a dead giveaway, it was trying to create the internal bitmap and the interface only takes a height, width, and pixel format. The height and width come directly from the map control itself and they cannot be 0.

>>Whilst I am posting, might I ask why the sample app we get is still bound
>> to source control and are ONLY in VB.Net???

We are actually coming out with a C# version of Render World if that interests you and may have a version ready for pre-release. I do not think it has a sample just yet but the code itself for Render World is in C#. Let us know if you would like to try it.

>>I just figured it out. I hadn't set the colors and width height in the tag,
>>only in code. I copied your line exactly and it worked straight away.
>> Thanks for your help.

I’m glad you found the issue however after checking the code I see we have a check for this. It should check the height and width and if they are not set raise the error below. I tested this in our sample and it raises the error. I think the issue may be that this code is new and not in the version you have currently. Just to say at least this should at least raise a friendly error in the 1.8 version to be released soon.

Throw New Exception("The Height and Width attribute must be set on the map control tag.")

If you have any other questions please let us know.

Thanks
DannyUser is Offline
Level 1
Level 1
Posts:6

--
08-22-2005 10:01 AM
Hi again

Thanks for the information and I hope whatever information I hand over may be of use somewhere.

I do have an updated problem that might not be Renderworld specific. I hope you don't mind me spamming your forum like this though.

Do you support creating a map control on the fly? I am trying to move the Mapsuite map in to a web control for use on our site.

I am trying this:

MapSuite.Webforms.Map Map1;
Map1 = new MapSuite.Webforms.Map();

Map1.MapUnit = MapLengthUnits.DecimalDegrees;
Map1.BorderColor = System.Drawing.Color.Black;
Map1.BackColor=System.Drawing.Color.WhiteSmoke;
Map1.Width = new System.Web.UI.WebControls.Unit((double) 900,System.Web.UI.WebControls.UnitType.Pixel); // Added because I no longer have a aspx page to add the tag and set these dimensions
Map1.Height = new System.Web.UI.WebControls.Unit((double) 600,System.Web.UI.WebControls.UnitType.Pixel); // Added because I no longer have a aspx page to add the tag and set these dimensions

RenderWorldWebforms.Renderers rw = new RenderWorldWebforms.Renderers(@"D:\RenderWorldData");
rw.LoadUSALayers(Map1.Layers,Map1.CurrentExtent);
Map1.CurrentExtent = mFullExtent;

When I try to ".LoadUSALayers" I get an object not set error. I am sure this is because Map1.Layers is null and shouldn't be (In your example and when I put it in an aspx page it is an initialised LayersCollection).

If I pass a LayersCollection variable to .LoadUSALayers it will fill it with all 51 layers. SO I tried this and then tried assigning my variable lc (LayersCollection) to Map1.Layers, only to realise that it is a ReadOnly property.

Is there any way I can set the LayersCollection?

Is there a reason you can see why the Layers collection is not being initialised so that it can be filled?

I imagine this is all spurred by the fact that I am not adding the HTML to the aspx page and so something is not happening internally within the Map control.

Thanks again for all of your help. I am desperately close to creating something that will be very impressive on our website because of your software!

ThinkGeoUser is Offline
MVP
MVP
Posts:1591
Avatar

--
08-23-2005 02:13 PM
Thank you for your questions.

We have had other customers create a web user control around our map control. Is the code you are referencing in the container page or the user control itself? I believe in order for it to work properly you will need all you logic inside the user control.
DannyUser is Offline
Level 1
Level 1
Posts:6

--
08-24-2005 03:45 AM
All of my code is in the class file and nothing is in the page that contains the control. I am creating my control as a "Web Control Library" which is the one that isn't an .ascx and so also doesn't have a mini page type file to go with it.

The problem really does look like the Layers collection is null upon me creating the map object in code. Is there anything extra I should be doing when I create the control?

MapSuite.Webforms.Map Map1;
Map1 = new MapSuite.Webforms.Map();

Map1.MapUnit = MapLengthUnits.DecimalDegrees;
Map1.BorderColor = System.Drawing.Color.Black;
Map1.BackColor=System.Drawing.Color.WhiteSmoke;
Map1.Width = new System.Web.UI.WebControls.Unit((double) 900,System.Web.UI.WebControls.UnitType.Pixel);
Map1.Height = new System.Web.UI.WebControls.Unit((double) 600,System.Web.UI.WebControls.UnitType.Pixel);

RenderWorldWebforms.Renderers rw = new RenderWorldWebforms.Renderers(@"D:\RenderWorldData");
rw.LoadUSALayers(Map1.Layers,Map1.CurrentExtent); // Errors here

When stepping through an Quickwatching Map1.Layers I can see that it is null (nullreference exception when you Quickwatch)

If this doesn't work then I will have to resort to putting it straight on to the page.


ThinkGeoUser is Offline
MVP
MVP
Posts:1591
Avatar

--
08-24-2005 11:24 AM
I don't believe we have ever had anyone successfully implement a web control library with the map control.

On the other hand we have had several customers implement it in a user control with an ascx page, so this may be an option for you. I imagine the main difference being that a user control doesn't have to create the map control on the fly.

We have never done any internal testing to try and create the Map control on the fly to even know if it is possible or what problems might occur. We will make sure to get this issue added to our list so it can be supported it in a future version.
You are not authorized to post a reply.

Active Forums 4.1