Select Link or Checkbox to Display Category Markers

前端 未结 2 1685
旧巷少年郎
旧巷少年郎 2021-01-25 19:00

I am somewhat stuck at trying to tell Javascript to do what I want it to do.

I have an example map http://calwestcultural.com/sgs/backup/example-map.html and I have cate

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-25 19:49

    I got a clue on how to do this from this answer without multiple category arrays. More so, google maps v3 example linked there showed the following.

    var gmarkers = [];
    var marker = new google.maps.Marker({
        position: latlng,
        icon: gicons[category],
        shadow: iconShadow,
        map: map,
        title: name,
        zIndex: Math.round(latlng.lat()*-100000)<<5
    });
    // === Store the category and name info as a marker properties ===
    marker.mycategory = category;                                 
    marker.myname = name;
    gmarkers.push(marker);
    

    Then just filter by the category on the marker as depicted in the exmaple.

    // == shows all markers of a particular category, and ensures the checkbox is checked ==
    function show(category) {
       for (var i=0; i

提交回复
热议问题