我使用的是谷歌地图API v3。我想在默认的谷歌地标/poi上禁用点击操作。例如,当我放大到UCLA时,学校图标就会出现(这很好),但我不想让用户点击并查看该位置的详细信息。我应该使用哪个API函数?
发布于 2016-07-21 02:16:07
谷歌已经为此公开了一个选项。请参阅google.maps.MapOptions
in the docs的clickableIcons
。
初始化代码示例:
map = new google.maps.Map(document.getElementById('map'), {
clickableIcons: false
});
发布于 2017-03-16 23:32:28
将此选项添加到mapOption clickableIcons: false
这是更多的选择,我想你会
draggable: true, // this is for disable the Draggable
disableDefaultUI: true, // this for disable Default UI
fullscreenControl: false, // this is for disable Full Screen
scrollwheel: true, // this is for disable Scroll Wheel
disableDoubleClickZoom: false, // this is for disable Double Click Zoom
draggableCursor:'crosshair',// this is for cursor type
draggingCursor:'move', // this is for dragging cursor type
minZoom: 3, // this is for min zoom for map
maxZoom: 18 , // this is for max zoom for map
//note : max, min zoom it's so important for my design.
zoom: 14, // this is to make default zoom
clickableIcons: false, // this is to disable all labels icons except your custom infowindow or Infobox.
发布于 2011-09-18 23:23:53
我遇到了同样的问题。谷歌最近似乎改变了他们的api,使基础地图标签“可点击”,但还没有一个简单的API调用来禁用它们的点击能力。http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f1ac9ad4da3606fe
我希望看到谷歌像这样添加一个简单的地图选项,但可惜它还不存在
var opts = { clickableLabels:false };
var map = new maps.google.com.map(div,opts);
以下解决方案有效,但由于它依赖于自定义样式的地图瓦片,因此免费地图被限制为(每天加载2,500个地图)- See Google Maps FAQ。
function initialize() {
// For more details see
// http://code.google.com/apis/maps/documentation/javascript/styling.html
var noPOILabels = [
{
featureType: "poi",
elementType: "labels",
stylers: [ { visibility: "off" } ]
}
];
// Create a new StyledMapType object, passing it the array of styles,
// as well as the name to be displayed on the map type control.
var noPOIMapType = new google.maps.StyledMapType(noPOILabels,
{name: "NO POI"});
// Create a map object, and include the MapTypeId to add
// to the map type control.
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(55.6468, 37.581),
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'no_poi']
}
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
//Associate the styled map with the MapTypeId and set it to display.
map.mapTypes.set('no_poi', noPOIMapType);
map.setMapTypeId('no_poi');
}
https://stackoverflow.com/questions/7267789
复制相似问题