Click on google map event is not happening only for emulator and ion view


#1

I have this code below for click event on google map.

        // click event on map to draw X marker and set Post location
        google.maps.event.addListener(map_origin, 'click', function(event) {
            console.log("Click on map");//debug
            var location = {
                lat: event.latLng.lat(),
                lon: event.latLng.lng()
            };
            drawAndSetPlace(location);
        });
    }

it works for ‘ionic serve’ but it does not recognize click on map in emulate ios or ion view in device…


#2

you need to handle touche events. for that you add an overlay to your map:

var overlay = new google.maps.OverlayView();
overlay.draw = function () {};
overlay.setMap(myMap);

#3

@bengtler hmm I was not able to find documentation about “touch” kind of event under OverlayView.

What I used for now is

google.maps.event.addListener(map_origin, 'mousedown', function(){ ... }

But this would trigger everytime I drag around map since it will occur on mousedown.
Could you give me more detail about setting up the click event?