1

单击复选框不会显示组标记,但会显示所有标记和所有组。当我搜索“T^T”时,它需要很长时间。

<script type="text/javascript">
//<![CDATA[

var customIcons = {
  "01": {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_purple.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  },
  "02": {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  },
  "03": {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  },
  "04": {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_brown.png',
    shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
  }
};

function load() {
  var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(13.754059,100.493317),
    zoom: 13,
    mapTypeId: 'roadmap'
  });
  var infoWindow = new google.maps.InfoWindow;

  // Change this depending on the name of your PHP file
  downloadUrl("dbxml.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var name_place = markers[i].getAttribute("name_place");
      var id_category = markers[i].getAttribute("id_category");
      var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("latitude")),
          parseFloat(markers[i].getAttribute("longitude")));
          var html = "<b>" + name_place ;
      var icon = customIcons[id_category] || {};
      var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
        shadow: icon.shadow
      });
      bindInfoWindow(marker, map, infoWindow, html);
    }
  });
}

function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
}

 var markerGroups = { "01": [], "02": [] , "03": [] , "04": [] };}
function toggleGroup(id_category) {
 for (var i = 0; i < markerGroups[id_category].length; i++) {
var marker = markerGroups[id_category][i];
markerGroups[id_category].push(marker);
if (marker.isHidden()) {
  marker.show();
} else {
  marker.hide();
}
 } 
  }

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }

  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {}

//]]>

这是复选框

<p>
    <label>
    <input type="checkbox" id="01"  onclick="toggleGroup('01')"CHECKED/>
    </label>
  01 
  <label>
  <input type="checkbox" id="02"  onclick="toggleGroup('02')" CHECKED/>
  </label>
  02 
  <label>
  <input type="checkbox" id="03"  onclick="toggleGroup('03')" CHECKED/>
  </label>
  03 
  <label>
  <input type="checkbox" id="04" onclick="toggleGroup('04')" CHECKED/>
  </label>
  04</p>

它显示所有标记,但如果单击“复选框”,它不会按组显示标记。

4

0 回答 0