SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Associative Array in JavaScript

    Hello All -

    I thought I was following the tutorial perfectly but I cannot get a var value into a function. Here is my code:

    var zoom = "";
    var state = "<&#37;= paramState %>";

    var stateArray = [];
    stateArray['United States of America'] = 3;
    stateArray['Canada'] = 3;
    stateArray['Australia'] = 3;
    stateArray['France'] = 5;
    stateArray['Italy'] = 5;
    stateArray['Russian Federation'] = 3;
    stateArray['United Kingdom of Great Britain and Northern Ireland'] = 5;
    stateArray['Argentina'] = 3;
    stateArray['Brazil'] = 3;
    stateArray['Chile'] = 4;
    stateArray['Ecuador'] = 4;
    stateArray['Mexico'] = 4;

    function displayZoomLevel(stateArray,state)

    {
    alert(stateArray[state]);
    var zoom = 3;
    if (typeof stateArray[state] == 'undefined') {
    zoom = 6;
    } else {
    zoom = stateArray[state];
    }
    }
    if (state == "") {
    zoom = 3;
    }else {
    displayZoomLevel(stateArray,state);
    }


    The value of zoom is inside the above function "displayZoomLevel". How do I get it out to place it here where zoom is in "map.LoadMap(defaultMapLoc,zoom,'r');":

    function GetMap()
    {
    map = new VEMap('myMap');
    var defaultMapLoc = GetDefaultMapLoc();
    map.SetDashboardSize(VEDashboardSize.Normal);
    map.onLoadMap = MapLoaded;

    map.LoadMap(defaultMapLoc,zoom,'r');

    map.ClearInfoBoxStyles();
    map.AttachEvent("onendpan", OnMapMoved);
    map.AttachEvent("onchangeview", OnMapMoved);
    map.AttachEvent("onmouseover", mouseoverPin);
    map.AttachEvent("onmouseout", mouseoutPin);
    getBrowser();
    }

    Thanks for any help.


    Never mind. I got it. It just took more coffee.
    Thanks for taking the time to read
    Last edited by a-rob; Dec 14, 2007 at 10:04.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •