Reinos.nl internet media examples

Manually show/hide markers

Maps 5.0.1 Live

Checkboxes that show and hide markers with the Javascript API: every marker gets its own key with keys, showMarker and hideMarker find it by that key.

Template
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="   crossorigin="anonymous"></script>

<p>
<input checked class="checkbox" type="checkbox" value="amsterdam"/> <strong>Amsterdam</strong>
<input checked class="checkbox" type="checkbox" value="rotterdam"/>  <strong>Rotterdam</strong>
<input checked class="checkbox" type="checkbox" value="den-haag"/> <strong>Den-Haag</strong>
</p>

{exp:reinos_maps:html_header}
{exp:reinos_maps:map
    width="100%"
    fit_map:markers="yes"
}
   {maps:add_marker
            address="amsterdam"
            keys="amsterdam"
    }
    {maps:add_marker
        address="rotterdam"
        keys="rotterdam"
    }
    {maps:add_marker
        address="den-haag"
        keys="den-haag"
    }
{/exp:reinos_maps:map}
{exp:reinos_maps:html_footer}

<script>
$(function(){
    $(".checkbox").click(function(){

        //show marker
        if($(this).is(":checked")) {
            REINOS_MAPS.api("showMarker", {
                mapID : "reinos_map_1",
                key : $(this).val()
            });
        //hide
        } else {
             REINOS_MAPS.api("hideMarker", {
                mapID : "reinos_map_1",
                key : $(this).val()
            });
        }
    });
});
</script>

Build it in your own site

What this example needs in ExpressionEngine, step by step.

  1. Install Maps.
  2. Put the code in a template.

This example comes from the Maps docs: the preview runs exactly the code above.