首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >禁用google地图上的可点击地标

禁用google地图上的可点击地标
EN

Stack Overflow用户
提问于 2011-09-01 16:29:18
回答 5查看 22.5K关注 0票数 31

我使用的是谷歌地图API v3。我想在默认的谷歌地标/poi上禁用点击操作。例如,当我放大到UCLA时,学校图标就会出现(这很好),但我不想让用户点击并查看该位置的详细信息。我应该使用哪个API函数?

EN

回答 5

Stack Overflow用户

发布于 2016-07-21 02:16:07

谷歌已经为此公开了一个选项。请参阅google.maps.MapOptions in the docsclickableIcons

初始化代码示例:

代码语言:javascript
复制
map = new google.maps.Map(document.getElementById('map'), {
    clickableIcons: false
});
票数 45
EN

Stack Overflow用户

发布于 2017-03-16 23:32:28

将此选项添加到mapOption clickableIcons: false

这是更多的选择,我想你会

代码语言:javascript
复制
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.

票数 9
EN

Stack Overflow用户

发布于 2011-09-18 23:23:53

我遇到了同样的问题。谷歌最近似乎改变了他们的api,使基础地图标签“可点击”,但还没有一个简单的API调用来禁用它们的点击能力。http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f1ac9ad4da3606fe

我希望看到谷歌像这样添加一个简单的地图选项,但可惜它还不存在

代码语言:javascript
复制
var opts = { clickableLabels:false };
var map = new maps.google.com.map(div,opts);

以下解决方案有效,但由于它依赖于自定义样式的地图瓦片,因此免费地图被限制为(每天加载2,500个地图)- See Google Maps FAQ

代码语言:javascript
复制
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');
}
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7267789

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档