google maps api3 infowindow won't close on android

13 views Asked by At

google maps api 3

cordova 11.0.0

jQuery 1.11.1

I have infowindows associated with my map markers.

When I run in a browser, touching the X in the upper right hand corner of the infowindow closes the window.

When I run on an android phone, touching the X does nothing

Here's the code

function onDeviceReady() {

    $(document).on('pageshow', '#map-content', function (e, data) {

    map = new google.maps.Map(document.getElementById("map_canvas"), {
        zoom: 8,
        center: { lat: current latitude, lng: current longitude },
        mapTypeControl: false,
    });

    var myLatlng = new google.maps.LatLng(currentLat, currentLong);

    //infowindow = new google.maps.InfoWindow();

    var marker = new google.maps.Marker({
        position: myLatlng,
    });

    marker.setMap(map);

    for (address in addresses array) {

                var eventLatLng = new google.maps.LatLng(address latitude, address longitude);
                
                const contentString = updateContent2(i);

                const  pt = new google.maps.Marker({
                    position: eventLatLng,
                    icon: some icon,
                    map,
                    optimized: false,
                    arrIdx:  `${i + 1}`
                })

                pt.infowindow = new google.maps.InfoWindow({
                    content: contentString
                });

                google.maps.event.addListener(pt.infowindow, 'closeclick', function() {   
                    pt.infowindow.close();
                });

                ptArr.push(pt);

                google.maps.event.addListener(pt,'click',function() {  

                   if (openIdx != -1) {
                    ptArr[openIdx].infowindow.close();
                   }

                   openIdx = pt.arrIdx;
                
                   this.infowindow.open(map,pt);
                   
                });


    }

   }

}

I'm at my wits end.

Can anyone tell me how to close the infowindow?

0

There are 0 answers