I have the following function and need help on using it.
What I want to do:
1: users enter values into textboxes
2: values are converted (with function)
3. Need to enter values into database.
The function:
//Get the easting, northing, id and UTM zone from the form
x = document.pointType.easting.value;
y = document.pointType.northing.value;
id = document.pointType.Bed_ID.value;
// Convert MCS to lat/lon
var latLonPt = map.mcsToLonLat(x, y);
window.location="add_GPS_Point.cfm?PT_LAT=" + latLonPt.getY() + "&PT_LON=" +
latLonPt.getX() + "&UTM_EASTING=" + x + "&UTM_NORTHING=" + y + "&UTM_ZONE="
+ zone + "&ID=" + id;
Can someone please help me ? What do I need to do - what should the rest of my code look like. I have set up a form, included the above function - but haven't had any success.
I am new to javascript and have read several tutorial on functions - but an still at a lost with get the function to convert the input values.
It looks like this function uses code from an object that is define elsewhere (the map object). Did you take this code from a website or a book or...? If so you need to either get the rest of the code or figure out what the
map.mcsToLonLat(x, y);
function does and replace it with one of your own.
As regards the rest, it looks like it is expecting there to be a form with name 'pointType' containing three text fields called 'easting', 'northing' and 'Bed_ID' (I think there should be a fourth called zone as well judging by later code) that are used as the input to create the latitude and longitude.
function onDigitizedPoint(map, point)
{
var xyPt = map.lonLatToMcs(point.getX(), point.getY());
var resource = (parent.Eelgrasstop.document.Add.Feature_Type.value);
switch (resource)
{
case "Feature_Point":
var loc = "Add_Point.cfm?LAT=" + point.getY() + "&LON=" + point.getX() + "&EAST=" + xyPt.getX() + "&NORTH=" + xyPt.getY() + "&RESOURCE=" + resource;
win = window.open(loc,"AddPoint","status=no,resizable=yes,scrollbars=yes,width=750,height=280");
win.focus();
break;
default:
alert("No available at this time.");
}
How does this code work with the function?
The code was give to me by somone working on a similar project. I am trying to figure how to do what I outlined in my first post by looking at her files - but am pretty confused as how they all work together - as this in my first time using javascript.
The last one looks like the winner, though I could not tell you what it does, so it will probably be a bit hit and miss coding for it unless you can contact the provider of this object for documentation?
Bookmarks