lundi 24 mai 2021

How can I get the value of a clicked Polygon for an If/Else so I can call on a function so open/close a navigation bar

I can't find info online on how can I get the value of a clicked Polygon. I am currently making a map using Google Maps API wherein I need to interact with the created polygons displayed on click. Here's a sad attempt of an if else statement I tried to make.

const WawangPulo =[
                    {lng:120.926721,lat: 14.736549},
                    {lng:120.928094,lat: 14.734183},
                    {lng:120.926819,lat:14.733144},
                    {lng:120.926471,lat: 14.730332},
                    {lng:120.928069,lat: 14.730409},
                    {lng:120.930301,lat: 14.725948},
                    {lng:120.933373,lat: 14.727335},
                    {lng:120.93333,lat: 14.728539},
                    {lng:120.933416,lat: 14.729161},
                    {lng:120.932858,lat: 14.72995},
                    {lng:120.931871,lat: 14.73107},
                    {lng:120.931485,lat: 14.73161},
                    {lng:120.931613,lat: 14.734059},
                    {lng: 120.926721,lat: 14.736549},
        ];
            const WawangPuloPolygon = new google.maps.Polygon({
                paths: WawangPulo,
                strokeColor: "Red",
                strokeOpacity: 0.8,
                strokeWeight: 3,
                fillColor: "Red",
                fillOpacity: 0.35
            });
            WawangPuloPolygon.addListener("click",WawangPuloInfo);

    $WawangPuloPolygon.addListener("click",WawangPuloInfo);
    function WawangPuloInfo() {
      currentvalue = document.getElementById("WawangPuloPolygon").onclick;
      if(booleanValue === true)
      {
         openNav;
      }
      else
      {
         closeNav;
      }
    }

<section class="section-1">
            <script type="text/javascript" 
                src="https://maps.googleapis.com/maps/api/js?key=theAPIkey=initMap">
                </script>
            <script type="text/javascript" 
            src="js.js">
        </script> 
        <div id="map"></div>
        </section>

Aucun commentaire:

Enregistrer un commentaire