Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我应该模拟哪个事件来获取要在google maps v3的标记上显示的标题_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 我应该模拟哪个事件来获取要在google maps v3的标记上显示的标题

Javascript 我应该模拟哪个事件来获取要在google maps v3的标记上显示的标题,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我正在从google maps api v2迁移到v3。在v2中,我们为工具提示提供了一个自定义覆盖,这与v3中的标题类似。我想摆脱自定义覆盖,因为它在v3中无论如何都不能正常工作,而且作为标题维护起来要简单得多。问题是我在地图之外有一些片段,当它们与地图交互时会显示工具提示。我想我可以用这样的东西来显示标题: showTooltip: function(i) { var marker = i && this.MARKERS ? this.MARKERS[i]

我正在从google maps api v2迁移到v3。在v2中,我们为工具提示提供了一个自定义覆盖,这与v3中的标题类似。我想摆脱自定义覆盖,因为它在v3中无论如何都不能正常工作,而且作为标题维护起来要简单得多。问题是我在地图之外有一些片段,当它们与地图交互时会显示工具提示。我想我可以用这样的东西来显示标题:

   showTooltip: function(i) {
      var marker = i && this.MARKERS ? this.MARKERS[i] : this.marker;
      if (!marker.infoWindowOpen) {
         google.maps.event.trigger(marker, 'mouseover', {ltLng: marker.getPosition()});
      }
   }

但是,标题没有显示。其想法是模拟鼠标在标记上移动,以便显示标题

这就是我如何进行切换来打开和关闭字幕的方法,我认为您可以使用相同的方法:

body .gmnoprint[title] { 
    overflow: visible !important; 
    width: auto  !important; 
    background: transparent;
    opacity: 1  !important; 
}


body[data-captions='true'] .gmnoprint[title*="^"]:after {
    background: none repeat scroll 0 0 rgba(255, 255, 255, 0.85);
    content: attr(title);
    display: block;
    font-size: 90%;
    left: 0em;
    padding: 0em 0.6em;
    position: relative;
    top: 1em;
    white-space: pre;
    width: auto;
    border-radius: 1em;
    vertical-align: top;
    color: #000;
    font-weight: bold;
    font-family: sans-serif;
    text-shadow: 0 0 1px #fff, 0 0 3px #fff;
    opacity: 0.75;
}
然后,您只需切换body tag data captions属性即可打开和关闭标题

它使用CSS显示标题,通常无法编写脚本来显示标题,但使用CSS生成内容的魔力,我们可以以一种吸引人的、可定制的方式显示标题信息

我相信代码击中了一个标记,不确定这是否是你所拥有的,但它应该能够处理任何有标题的东西

在我的例子中,标题是这样的(如果需要,可以是透明的):


这个标题是一个简单的HTML工具提示,没有编程的方式来显示它。最终不需要这个,所以我没有花时间尝试建议的解决方案。
   var marker = new google.maps.Marker({
          position: pos,
          map: map,
          icon: {
              path: 0,
              scale: 3,
              fillColor: spot.color,
              strokeWeight: 8,
              strokeColor: spot.color,
              fillOpacity: 1,
              strokeOpacity: 0.333
          },
         title: "^ "+spot.name
    });