在Google地图API中禁用或更改位置的默认行为3 [英] Disable or change default behavior of location on Google Maps api 3

查看:147
本文介绍了在Google地图API中禁用或更改位置的默认行为3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施一个应用程序,在这个应用程序中,使用非常大的显示器,用户可以选择出现在屏幕上的几个标记中的一个,并将其信息打印在infowindow上。
此选择可以在一个用例上使用Microsoft Surface进行。
虽然我遇到了以下问题。



这是用户触摸标记时发生的情况



这就是用户触摸位置本身时发生的情况,而不是标记



I覆盖像这样的标记行为

  google.maps.event.addListener(marker,'click',function(){
requestMarkerDetails(this);
infoWindow.open(map,this);
});



  function requestMarkerDetails(mkr){
var details_service = new google.maps.places.PlacesService(map);
details_service.getDetails({
placeId:mkr.place.placeId
},function(result,status){
if(status!= google.maps.places.PlacesServiceStatus。 OK){
alert(status);
return;
}
var contentStr ='< div id =bodyContent>'+'< font size = 12>'+
'< p>'+ result.name +< br>+ result.formatted_address +< br>+
result.formatted_phone_number +'< / p>'+'< / div>';

infoWindow.setContent(contentStr);
});





$ b因此,基本上我需要的是让它自己点击图标,不是标记不做任何事情,或者我需要使它能够点击图标才能显示出更大的infowindow,而不是默认的标记。

解决方案

所以,我做了一些挖掘,感谢Emmanuel,他将我链接到这个问题,这最终导致我此问题。起初它似乎没有希望,因为谷歌已经标记为不会解决。但我一直在阅读,他们最终通过 clickableIcons false ,在地图上。



当然,我希望做的是实际上更改infoWindow,以便显示我制作的更大的窗口,并且仅禁用单击他们。


I'm implementing an application where, using a very large display, the user can select one of several markers that appear on the screen and its information is printed on an infowindow. This selection can happen using a Microsoft Surface on one use case. I'm running into the following problem, though.

This is what happens when the user touches the marker

And this is what happens when the user touches the location itself, not the marker

I overrode the behavior of the marker like this

google.maps.event.addListener(marker, 'click', function () {
    requestMarkerDetails(this);
    infoWindow.open(map, this);
});

And

function requestMarkerDetails(mkr) {
    var details_service = new google.maps.places.PlacesService(map);
    details_service.getDetails({
        placeId: mkr.place.placeId
    }, function (result, status) {
        if (status != google.maps.places.PlacesServiceStatus.OK) {
            alert(status);
            return;
        }
        var contentStr = '<div id="bodyContent">' + '<font size = "12">' +
                '<p>' + result.name + "<br>" + result.formatted_address + "<br>" +
                result.formatted_phone_number + '</p>' + '</div>';

        infoWindow.setContent(contentStr);
    });
}

So basically what I need is to either make it so tapping the icon itself, not the marker does nothing, or I need to make it so tapping the icon brings up the larger infowindow, rather than the default one.

解决方案

So, I did some digging, thanks to Emmanuel, who linked me to this question, which eventually led me to this issue. At first it seemed hopeless, because google had marked it as "won't solve". But I kept reading on, and they did eventually solve it, by [edit: allowing us to set] clickableIcons tofalse, on the map.

Of course, what I hoped to do was actually change the infoWindow so it would show the larger window I made, and this only disables clicking on them.

这篇关于在Google地图API中禁用或更改位置的默认行为3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆