Click to See Complete Forum and Search --> : Function - need to understand why it is not working


violet
05-01-2003, 01:50 PM
I am new to javascript and am having problems understanding my function and how everything works together. I have read many tutorials to cure my confusion but I'm not getting it - I need help with this specific problem. Any suggestions? They are greatly appreciated.


Page with my function:

Title.cfm


<SCRIPT LANGUAGE="JavaScript">
function getMap()
{
if (navigator.appName == "Netscape")
return parent.mapframe.document.map;
else
return parent.mapframe.map;
}

function myfunction()
{
var map = getMap();
//Get the easting, northing, id and UTM zone from the form
x = (121212);
y = (121212);

// Convert MCS to lat/lon
var latLonPt = map.mcsToLonLat(x, y);

// pull out lat/lon vals
lon = latLonPt.getX();
lat = latLonPt.getY();

alert(lon);


}

myfunction();
</SCRIPT>


The rest of my pages:

example.cfm

<FRAMESET ROWS="20%,*">
<FRAME SRC="title.cfm" SCROLLING=no>
<FRAME SRC="map.cfm" NAME="mapframe" SCROLLING=no>
</FRAMESET>





map.cfm


<BODY>

<OBJECT ID="map" WIDTH="100%" HEIGHT="100%"
CLASSID="CLSID:62789780-B744-11D0-986B-00609731A21D"
CODEBASE="ftp://adeskftp.aut*****.com/webpub/mapguide/ver6/mgaxctrl.cab#Version=6,0,2,2" >
<PARAM NAME="URL" value="http://localhost/cfdocs/Langley/invasive/InvasiveSpecies.mwf">
<PARAM NAME="Lat" value="0">
<PARAM NAME="Lon" value="0">
<PARAM NAME="MapScale" value="0">
<PARAM NAME="MapWidth" value="0">
<PARAM NAME="Units" value="M">
<PARAM NAME="ToolBar" value="On">
<PARAM NAME="StatusBar" value="On">
<PARAM NAME="LayersViewWidth" value="150">
<PARAM NAME="URLListState" value="0">
<PARAM NAME="AutoLinkDelay" value="20">
<embed SRC="http://localhost/cfdocs/Langley/invasive/InvasiveSpecies.mwf"
ALIGN="baseline" BORDER="0" WIDTH="100%" HEIGHT="100%"
NAME="map" TYPE="application/x-mwf">
</OBJECT>

Help!

violet
05-01-2003, 06:46 PM
Sorry Dave,

My problem - the function is not working, nothing happens, no values are converted.

violet
05-02-2003, 12:56 PM
map.mcsToLonLat

Syntax
MGPoint mcsToLonLat(double x, double y)

Description
Converts the specified Mapping Coordinate System (MCS) coordinate pair to lat/lon coordinates.

The MCS for the map file is set by the map author. For more information on Mapping Coordinate Systems, refer to the Aut***** MapGuide User's Guide.

Parameters
x - MCS X coordinate to convert. y - MCS Y coordinate to convert.

Returns
MGPoint - Coordinate in longitude/latitude units.

Error Codes
none

Example
This example is designed to work with the Tutorial.mwf file that is included with Aut***** MapGuide Author. It converts a set of lat/lon points to MCS, and then uses mcsToLonLat() to convert them back again:

{
var map = getMap();

// Get lat/lon and convert to MCS
var xyPt = map.lonLatToMcs(map.getLon(), map.getLat());

// pull out X and Y values and display in dialog
x = xyPt.getX();
y = xyPt.getY();
alert( "MCS X: " + x + "\nMCS Y:" + y );

// Convert MCS to lat/lon
var latLonPt = map.mcsToLonLat(x, y);

// pull out lat/lon vals and display in dialog
lon = latLonPt.getX();
lat = latLonPt.getY();
alert( "Lat: " + lat + "\nLon: " + lon );
}

violet
05-02-2003, 06:12 PM
mmm not really,

It is set in internet options or

Right-click on My Computer 2. Select Properties 3. Click on Advanced
4. Choose Error Reporting

I don't have an 'advanced tap' under 'properties' (??)

I am using windows NT

violet
05-05-2003, 12:52 PM
OK thanks Dave,

I see my error messages now

I am trying to find my problem by starting with a little bit of code and adding to it to see where the errors are.

The object is 'map' is undefined and I'm not sure why.

Here is the code I have been using:

(I am trying to access the bottom frame from the top frame)


function getMap()
{
if (navigator.appName == "Netscape")
return parent.bottom.document.map;
else
return parent.bottom.map;
}

function placePoint()
{
var map = getMap();

alert(map);
}
placePoint();


My html page contains 2 frames:


<FRAMESET ROWS="20%,*">
<FRAME SRC="top.cfm" NAME="top" SCROLLING=no>
<FRAME SRC="map.cfm" NAME="bottom" SCROLLING=no MARGINHEIGHT=0 MARGINWIDTH=0>>
</FRAMESET>

"bottom" contains the map object



????

violet
05-09-2003, 11:04 AM
Thanks Dave, I figured it out

I found using alert boxes after each statement to show me what was actually happening really helped me understand my code

Thanks again for your time