Results 1 to 1 of 1

Thread: we couldnt uncheck the box!! couldnt show the navigation too.

  1. #1
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation we couldnt uncheck the box!! couldnt show the navigation too.

    OUR HTML CODE

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Google Maps</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBRRwPhutbWBmyj82Go_H6JlE7EvFBSKFFFHFePAwvib9UM0geoA3Pgafw" type="text/javascript"></script>
      </head>
      <body onunload="GUnload()">
    
    
        <!-- you can use tables or divs for the overall layout -->
        <table border=1>
          <tr>
            <td>
               <div id="map" style="width: 850px; height: 650px"></div>
            </td><td width = 150 valign="top" style="text-decoration: underline; color: #4444ff;">
               <div id="side_bar"></div>
            </td>
          </tr>
        </table>
        Hong Kong Island: <input type="checkbox" id="hkislandbox" onclick="boxclick(this,'hkisland')" /> &nbsp;&nbsp;
        Kowloon: <input type="checkbox" id="kowloonbox" onclick="boxclick(this,'kowloon')" /> &nbsp;&nbsp;
        New Territories: <input type="checkbox" id="New Territoriesbox" onclick="boxclick(this,'new')" /><br>
        Outlying Islands: <input type="checkbox" id="outlyingbox" onclick="boxclick(this,'outlying')" /><br>
    
    
        <a href="categories.htm">Back to the tutorial page</a>
    
    
        <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> 
          However, it seems JavaScript is either disabled or not supported by your browser. 
          To view Google Maps, enable JavaScript by changing your browser options, and then 
          try again.
        </noscript>
    
    
        <script type="text/javascript">
        //<![CDATA[
    
        if (GBrowserIsCompatible()) {
          var gmarkers = [];
          var gicons = [];
          // arrays to hold variants of the info window html with get direction forms open
          var to_htmls = [];
          var from_htmls = [];
    
          gicons["Hong Kong Island"] = new GIcon(G_DEFAULT_ICON,"colour086.png");
          gicons["Kowloon"] = new GIcon(G_DEFAULT_ICON,"colour108.png");
          gicons["New Territories"] = new GIcon(G_DEFAULT_ICON,"colour125.png");
          gicons["Outlying Islands"] = new GIcon(G_DEFAULT_ICON,"colour.png");
    
          // A function to create the marker and set up the event window
          function createMarker(point,name,html,category) {
            var marker = new GMarker(point,gicons[category]);
            // === Store the category and name info as a marker properties ===
            marker.mycategory = category;                                 
            marker.myname = name;
            GEvent.addListener(marker, "click", function() {
              marker.openInfoWindowHtml(html);
            });
            gmarkers.push(marker);
            return marker;
          }
    
          // == shows all markers of a particular category, and ensures the checkbox is checked ==
          function show(category) {
            for (var i=0; i<gmarkers.length; i++) {
              if (gmarkers[i].mycategory == category) {
                gmarkers[i].show();
              }
            }
            // == check the checkbox ==
            document.getElementById(category+"box").checked = true;
          }
    
          // == hides all markers of a particular category, and ensures the checkbox is cleared ==
          function hide(category) {
            for (var i=0; i<gmarkers.length; i++) {
              if (gmarkers[i].mycategory == category) {
                gmarkers[i].hide();
              }
            }
            // == clear the checkbox ==
            document.getElementById(category+"box").checked = false;
            // == close the info window, in case its open on a marker that we just hid
            map.closeInfoWindow();
          }
    
          // == a checkbox has been clicked ==
          function boxclick(box,category) {
            if (box.checked) {
              show(category);
            } else {
              hide(category);
            }
            // == rebuild the side bar
            makeSidebar();
          }
    
          function myclick(i) {
            GEvent.trigger(gmarkers[i],"click");
          }
    
    
          // == rebuilds the sidebar to match the markers currently displayed ==
          function makeSidebar() {
            var html = "";
            for (var i=0; i<gmarkers.length; i++) {
              if (!gmarkers[i].isHidden()) {
                html += '<a href="javascript:myclick(' + i + ')">' + gmarkers[i].myname + '</a><br>';
              }
            }
            document.getElementById("side_bar").innerHTML = html;
          }
    
    
          // create the map
          var map = new GMap2(document.getElementById("map"));
          map.addControl(new GLargeMapControl());
          map.addControl(new GMapTypeControl());
          map.setCenter(new GLatLng(22.2883,114.0500), 11);
    
          // Read the data
          GDownloadUrl("marker categories.xml", function(doc) {
            var xmlDoc = GXml.parse(doc);
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
              
            for (var i = 0; i < markers.length; i++) {
              // obtain the attribues of each marker
              var lat = parseFloat(markers[i].getAttribute("lat"));
              var lng = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);
              var address = markers[i].getAttribute("address");
              var name = markers[i].getAttribute("name");
              var html = "<b>"+name+"</b><p>"+address;
              var category = markers[i].getAttribute("category");
              // create the marker
              var marker = createMarker(point,name,html,category);
              map.addOverlay(marker);
            }
    
            // == show or hide the categories initially ==
            show("Hong Kong Island");
            hide("Kowloon");
            hide("New Territories");
    	hide("Outlying Islands");
    
    
            // == create the initial sidebar ==
            makeSidebar();
          });
    
        }
    
        else {
          alert("Sorry, the Google Maps API is not compatible with this browser");
        }
        // This Javascript is based on code provided by the
        // Blackpool Community Church Javascript Team
        // http://www.commchurch.freeserve.co.uk/   
        // http://econym.googlepages.com/index.htm
    
        //]]>
        </script>
      </body>
    
    </html>
    OUR XML FILE

    Code:
    <markers>
    
     <marker lat="22.377485" lng="114.185259" html="www.yahoo.com&lt;br&gt;Hong Kong Heritage Museum" label="colour125" category="New Territories"/>
    
     <marker lat="22.373432" lng="114.184068" html="Some stuff to display in the&lt;br&gt;Che Kung Temple" label="colour125" category="New Territories"/>
    
     <marker lat="22.409666" lng="113.973748" html="Some stuff to display in the&lt;br&gt;Ching Chung Koon"  label="colour125" category="New Territories"/>
    
     <marker lat="22.444592" lng="114.007353" html="Some stuff to display in the&lt;br&gt;Ping Shan Heritage"  label="colour125" category="New Territories"/>
    
     <marker lat="22.468133" lng="114.004065" html="Some stuff to display in the&lt;br&gt;Hong Kong Wetland Park"  label="colour125" category="New Territories"/>
    
     <marker lat="22.491890" lng="114.042347" html="Some stuff to display in the&lt;br&gt;Mai Po Wetlands"  label="colour125" category="New Territories"/>
    
     <marker lat="22.499689" lng="114.076388" html="Some stuff to display in the&lt;br&gt;Tai Fu Tai"  label="colour125" category="New Territories"/>
    
     <marker lat="22.372073" lng="114.120199" html="Some stuff to display in the&lt;br&gt;Sam Tung Uk Museum"  label="colour125" category="New Territories"/>
    
     <marker lat="22.355871" lng="114.087911" html="Some stuff to display in the&lt;br&gt;Tsing Ma Bridge"  label="colour125" category="New Territories"/>
    
     <marker lat="22.490721" lng="114.138486" html="Some stuff to display in the&lt;br&gt;Fung Ying Seen Koon"  label="colour125" category="New Territories"/>
    
     <marker lat="22.501443" lng="114.147016" html="Some stuff to display in the&lt;br&gt;Lung Yeuk Tau Heritage Trail"  label="colour125" category="New Territories"/>
    
     <marker lat="22.456267" lng="114.142971" html="Some stuff to display in the&lt;br&gt;Lam Tsuen Wishing Trees And Tin Hau Temple" label="colour125" category="New Territories"/>
    
     <marker lat="22.383650" lng="114.270880" html="Some stuff to display in the&lt;br&gt;Sai Kung Town/ Sai Kung Promenade"  label="colour125" category="New Territories"/>
    
    </markers>
    Last edited by thetestingsite; 05-29-2008 at 10:52 PM. Reason: added code tags

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
  •