newbie question here..
I’m trying to return the LAT LNG values from the array.
I have the following three functions:
function City(ridge)
{
var city= {
ABC:"Bethel, AK",
ABR:"Aberdeen, SD",
ABX:"Albuquerque, NM"};
return city[ridge];
}
and
function BBox(ridge,product)
{
var yx= {
NOR:
{
ABC:[64.835517,56.735755,-157.448578,-166.284681]
,
ABR:[48.270508,42.631241, -95.331912,-101.483839]
,
ABX:[37.565036,32.726169,-104.179217,-109.457981]}};
var xy=yx[product][ridge];
return {x0:xy[2],x1:xy[3],y0:xy[0],y1:xy[1]};
}
and
function initialize()
{
var ridge = 'ABC';
var product ='NOR';
var getCityInfoFromRidgeName = City(ridge);
var boundries=BBox(ridge,product);
alert(getCityInfoFromRidgeName);
alert(boundries);
}
the alert for City returns “Bethel, AK” as expected..
but
the alert for BBox returns “objec Object” instead of the LAT LNG information as hoped.
I’m probably in over my head, but how can I return the LAT LNG from the BBox to a var?
Den
boundries is an object holding the x and y coords. you can get at the coords with this code:
for future reference, objects in javascript can be created like this:
and then parts of an object can be accessed with a dot – like this:
you can learn more about javascript objects here:
http://net.tutsplus.com/tutorials/javascript-ajax/the-basics-of-object-oriented-javascript/