2

これに1週間取り組んでおり、いくつかのガイダンスで行うことができます:

マップ上のマーカーをフィルタリングするには、2 列のチェック ボックスを使用する必要があります。
列 1 は: data.ConType
列 2 は: data.Operator

チェックボックスをチェックして、チェックボックスの両方の列の基準に一致するマーカーのみを返す必要があります。

私はそれを最初の列で動作させ、&&関数を使用して2番目の列を読み取って一致させようとしましたが、これまでのところ機能しません。
show 関数の作業セクションは次のとおりです。

// === Store the category and name info as a marker properties ===
      marker.mycategory = data.ConType;
      marker.myname = data.Name;
      marker.myoperator = data.Operator,
      gmarkers.push(marker);
      // end Looping through the JSON data
      <!-- Map traffic begin -->
      (function (marker, data) {
          // Attaching a click event to the current marker
          google.maps.event.addListener(marker, 'click', function(e) {}); // end Attaching a click event to the current marker
          })(marker, data); // end Creating a closure

      }
} // end of initialize function

// == 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].setVisible(true);
    }
  }
  // == 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].setVisible(false);
    }
  }
  // == clear the checkbox ==
  document.getElementById(category+"box").checked = false;
  // == close the info window, in case its open on a marker that we just hid
  infoBubble.close();
}

// == 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) {
  google.maps.event.trigger(gmarkers[i],"click");
}

この種の作業基準を持つポインターまたは作業中の Web ページ/jsfiddle/GitHub を持っている人はいますか?

4

0 に答える 0