[mapguide-users] Couple of (potential) bugs in MapGuide 2.1 API AjaxViewer

cagray colin.gray at 1spatial.com
Thu Apr 9 06:25:38 EDT 2009


I am been developing and migrating a couple of .NET (c#) web tools to use MapGuide 2.1 based upon the BETA installer and I think I have identified a couple of bugs which did not occur in the 2.0.x version which may be worth a ticket. However I thought I would post them here first in case I am mistaken. 

First bug: the javascript function; FormatLocalizedDecimal (found in mainframe.templ) throws an error (object does not support this method) if you pass it a number which originated from a HTML form. e.g.

My html has something like (values  of hidden fields below can be set in html, js or serverside):

 	<input id="MapExtentScale" type="hidden" runat="server"/>		
	<input id="MapX" type="hidden" runat="server"/>		
	<input id="MapY" type="hidden" runat="server"/> 

Then I have a javascript function on my web page like:

// function to set the current zoom level and also the x and y center
function setExtents() {

    if (viewerFrameSet[0].mapFrame.mapInit == true) {

    	// find controls we need
    	controlExtent = document.getElementById('MapExtentScale');
    	controlX = document.getElementById('MapX');
    	controlY = document.getElementById('MapY');

    	// check they were found (if it is initial post they wont be)
    	if (controlExtent != null && controlX != null && controlY != null) {

    		extent = controlExtent.value;
    		posX = controlX.value;
    		posY = controlY.value;

    		if (posX != "" && posY != "" && extent != "") {
    		  viewerFrameSet[0].mapFrame.ZoomToView(posX, posY, extent, true);


    	}// if

    } // if

}

This throws an error on the line:

var unlocalized = numberValue.toFixed(decimalPlaces);

in the function from mainframe.templ, FormatLocalizedDecimal becuase it considers the numberValue passed a string and this breaks the jquery function, toFixed. This did not happen in 2.0 so I was wondering if this was a bug caused by some other change? A temporary workaround to fix this is to subtract 0 from the number:

    numberValue = numberValue - 0;
    var unlocalized = numberValue.toFixed(decimalPlaces);

Second bug: After adjusting a layers definition xml via a web tool and updating the session and/or library by commiting the resource, when the web page reloads the map using the same session you see the error after you try and zoom in or out:

Error: mismatched tag. Expected: </meta>.
Source File: http://dias/mapguide/mapagent/mapagent.fcgi
Line: 6, Column: 3
Source Code:
</head>

Once you click on Initial Map View it fixes itself. Again this web tool worked fine in 2.0. I submit the adjusted xml doc via code such as:

	MgByteSource byteSource = getResourceByteSource(xmlDoc);
	MgResourceIdentifier resourceID = new MgResourceIdentifier(resourceName);
	resourceService.SetResource(resourceID, byteSource.GetReader(), null);

Any thoughts on these?

As a side point; 2.1 performance with rasters and tilling is superb. Congratulations to all those involved as it has really improved MapGuide and it now acts more like Google Maps / Multimap type apps when employed in a web page.

Thanks
Colin
1Spatial


-- 
View this message in context: http://n2.nabble.com/Couple-of-%28potential%29-bugs-in-MapGuide-2.1-API-AjaxViewer-tp2610344p2610344.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list