Google Maps API Javascript Problem

Discussion in 'Javascript' started by SyPhy, May 17, 2008.

  1. SyPhy

    SyPhy Guest

    Hi all,

    First post to this group and I hope I can get some help. I have been
    stuck on this all day....

    I am using the Google Maps API to plot markers grouped into categories
    via checkboxes. Some categories of markers are to load when the page
    loads, which are contained in a single XML file, other categories are
    to load after the user toggles the checkbox associated with a group of
    markers on.

    Please see this link for clarification:

    http://fddc.987mb.com/index1.htm

    Some categories are being read from "location.xml", which loads when
    the page loads (http://fddc.987mb.com/location.xml), specifically
    these: APDs & DSIs, Independent Living, Airports, Stadiums, and Social
    Security. All other categories are to load "on demand" after the user
    specifically toggles its checkbox on. For instance, "Targets" is to be
    read from "targets.xml", located here: http://fddc.987mb.com/targets.xml

    I can't figure out how to do this to save my life. I am assuming that
    what I need
    is a JS function that sends the signal to load various XML files based
    on which checkbox is clicked. If anybody could help me figure out how
    to do this it would be greatly appreciated. Thank
    you!!!!!!!!!!!!!!!!!!!!!
     
    SyPhy, May 17, 2008
    #1
    1. Advertisements

  2. This might give you some idea:

    var loadedXML = {
    location: true,
    targets: false
    };

    function showHideMarkers(type, bShow)
    {
    if (bShow)
    {
    // show markers
    }
    else
    {
    // hide markers
    }
    }

    function handleClick(checkbox)
    {
    var type = checkbox.value;

    if (checkbox.checked)
    {
    if (!loadedXML[type])
    {
    GDownloadUrl(type + ".xml",
    function(data) {
    loadedXML[type] = true;
    createSetMarkers(data);
    showHideMarkers(type, true);
    });
    }
    else
    {
    showHideMarkers(type, true);
    }
    }
    else
    {
    showHideMarkers(type, false);
    }
    }

    <input type="checkbox" name="markers" value="targets"
    onclick="handleClick(this)">
    You're welcome. BTW: Your keyboard appears to be broken.


    PointedEars
     
    Thomas 'PointedEars' Lahn, May 17, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.