javascript - phonegap-googlemaps-plugin + $ionicPopup

标签 javascript css cordova ionic-framework phonegap-plugins

我正在使用 IonicFramework 开发一个应用程序与 phonegap-googlemaps-plugin也就是说,当用户点击 infoWindow 的标记时,它会调用一个确认函数,然后调用 launchNavigation如果为真

我的问题是,如果我使用 native confirm 功能,它会很好用,但是当我尝试使用 $ionicPopup.confirm({}) 我无法点击确认按钮。看起来我一直在点击 map 。

我已经尝试更改“popup-containe”类的 z-index 属性,但似乎没有按我预期的方式工作。

    data.map(function (m) {

        var latLng = new plugin.google.maps.LatLng(m.lat, m.lng)
        latLngs.push(latLng);

        map.addMarker({
            position: latLng,
            title: m.placa,
            snippet: 'Clique para ir nessa localização.',
            styles : {
                'text-align': 'center',
                'font-weight': 'bold'
            }
        }, function (marker) {

            marker.addEventListener(plugin.google.maps.event.INFO_CLICK, function(marker) {

                var confirm = $ionicPopup.confirm({
                    title: m.placa,
                    template: 'Abrir navegação para essa localização?',
                    okText: 'Sim',
                    cancelText: 'Não'
                })

                document.getElementsByClassName('popup-container')[0].style.zIndez = 999999;

                confirm.then(function (response) {
                    if (response) {
                        map.getMyLocation(function (location) {
                            mobileLocation = location.latLng;

                            marker.getPosition(function(markerLocation) {

                                plugin.google.maps.external.launchNavigation({
                                    'from': mobileLocation,
                                    'to': markerLocation
                                });

                            })
                        })
                    }
                })

                $timeout(function() {
                    confirm.close();
                }, 3000);

                /*
                if (confirm("Abrir direção para " + m.placa)) {
                    map.getMyLocation(function(location) {
                        mobileLocation = location.latLng;

                        marker.getPosition(function (markerLocation) {

                            plugin.google.maps.external.launchNavigation({
                                "from": mobileLocation,
                                "to": markerLocation
                            });

                        });

                    });
                }
                */
            });
        });
    });

enter image description here

谢谢

最佳答案

简单就是你只要设置

map.setClickable(false) 当显示 $ionicPopup 然后在 map.setClickable(true) 之后。

完美运行。

关于javascript - phonegap-googlemaps-plugin + $ionicPopup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32524521/

相关文章:

java - 从 javascript 函数访问 Java String 对象

android - 无效数据, block 必须是字符串或缓冲区,而不是对象 - ionic 和 firebase

JavaScript 游戏 - 无法通过 0.5 像素偏移和错误边界渲染进入中心圆圈

Javascript 鼠标悬停函数

javascript - 从 JavaScript 数组中随机选择不重复的项目

jquery - 从谷歌地图中删除时间信息

css - 如何使用 Sass 和 BEM 编写修饰符

html - 列表影响菜单?

javascript - Cordova 反向地理编码返回错误

javascript - 通过 javascript 仅显示 asp 验证器的错误消息