Javascript addListener在Firefox谷歌地图中不工作

Javascript addListener在Firefox谷歌地图中不工作,javascript,google-maps,firefox,google-maps-api-3,Javascript,Google Maps,Firefox,Google Maps Api 3,我已经创建了下面的方法来为我的谷歌地图添加标记。这些结果是动态的,并在地图移动时创建 function addMarker2(lat, lng, hid, label, map) { var price = label; if (price == null) price = "0.00" var marker = new RichMarker({ position: new google.maps.LatLng(lat, lng),

我已经创建了下面的方法来为我的谷歌地图添加标记。这些结果是动态的,并在地图移动时创建

function addMarker2(lat, lng, hid, label, map) {
    var price = label;
    if (price == null)
        price = "0.00"


    var marker = new RichMarker({
        position: new google.maps.LatLng(lat, lng),
        map: map,
        draggable: false,
        flat: true,
        //anchor: RichMarkerPosition.MIDDLE,
        content: '<div data-hid="' + hid + '" class="map-tooltip">' + price + '&nbsp;</div>',
        id: hid
    });
    markers.push(marker);

    marker.addListener('click', function () {
    //marker.addListener('click', function (e) {
        // stop event from bubbling to map click event
        //e = e || window.event;
        //var e = window.event || e;
        event.preventDefault();
        // close any open infoboxes
        if (infowindow != null)
            infowindow.close();

        // find clicked hotel
        var hotel;
        $.each(hotel_json, function (i, obj) {
            if (obj.hid === hid) {
                hotel = obj;
            }
        });

        // build infobox html
        var contentString = '<img src="' + hotel.img + '" alt="" style="height: 150px; width: 100%"><a class="favourite-button toggle-select" id="favourite-button"><i class="fa fa-heart-o fa-2x"></i></a><h5><span style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"><a href="javascript:;" style="text-decoration: none; color: #888">' + hotel.name + '</a></span><br /><div class="mt5 text-warning-custom"><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i></div></h5><span>Guesthouse</span><p class="text-primary"><sup class="h6 pr5">R</sup><span class="h3">' + hotel.price + '</span><sup class="h6 pl5">ZAR</sup></p><div class="map-action-btns"><a href="javascript:;" class="btn btn-sm btn-info btn-block"><i class="fa fa-file"></i>&nbsp;Request Quote</a><a href="javascript:;" class="btn btn-sm btn-success btn-block"><i class="fa fa-calendar-o"></i>&nbsp;Book Now</a></div>';

        // open infobox
        infowindow = new google.maps.InfoWindow({
            content: contentString,
            maxWidth: 200
        });

        infowindow.open(map, marker);
    });
}
功能添加标记2(lat、lng、hid、标签、地图){
var价格=标签;
如果(价格==null)
价格=“0.00”
var marker=新的RichMarker({
位置:新google.maps.LatLng(lat,lng),
地图:地图,
可拖动:错误,
平:是的,
//主播:RichMarkerPosition.MIDDLE,
内容:''+价格+'',
id:hid
});
标记器。推(标记器);
marker.addListener('click',函数(){
//marker.addListener('click',函数(e){
//停止事件冒泡以映射单击事件
//e=e | | window.event;
//var e=window.event | e;
event.preventDefault();
//关闭所有打开的信息框
if(infowindow!=null)
infowindow.close();
//查找点击酒店
瓦尔酒店;
美元,每个(酒店,功能(i,obj){
if(obj.hid==hid){
酒店=obj;
}
});
//构建信息框html
var contentString='
宾馆

R'+hotel.price+'ZAR

; //打开信息框 infowindow=新建google.maps.infowindow({ content:contentString, 最大宽度:200 }); 信息窗口。打开(地图、标记); }); }

如果单击自定义标记,将显示其他信息。问题出现在event.preventDefault()中这在Chrome和IE上运行良好。我在网上尝试了多种解决方案,但没有成功。希望我只是错过了一些简单的解决方案。所有的帮助都会得到感谢。我在评论中留下了一些我尝试过的东西。

检查您的控制台。仅供参考,FF不使用全局事件模型,您需要明确地将其作为事件h的参数传递andler:
marker.addListener('click',函数(事件){…})
您好,谢谢您的快速响应。我已经检查了我的控制台。如果我添加这样的事件,它在FF中会显示为未定义。哦,是的,这是一个自定义方法。检查传递给它的参数。我想它应该传递事件对象。没有真正的对象。这是从返回lat和lng值的API的返回方法调用的。然后,它会添加markers在运行中。好的,很抱歉造成混淆,很长时间我没有使用google maps API。现在使用
event.preventDefault()的预期行为是什么;
在google maps marker上做什么?你能提供MCVE吗?检查你的控制台。仅供参考,FF不使用全局事件模型,你需要将它作为事件处理程序的参数明确地传递:
marker.addListener('click',function(event){…})
您好,谢谢您的快速响应。我已经检查了我的控制台。如果我添加这样的事件,它在FF中会显示为未定义。哦,是的,这是一个自定义方法。检查传递给它的参数。我想它应该传递事件对象。没有真正的对象。这是从返回lat和lng值的API的返回方法调用的。然后,它会添加markers在运行中。好的,很抱歉造成混淆,我很久没有使用google maps API了。现在,在google maps marker上使用
event.preventDefault();
的预期行为是什么?您能提供MCVE吗?