removing default mouseover tooltip from marker in google-maps

本秂侑毒 提交于 2019-12-01 08:37:05
scniro

You could manually remove the element title attribute on mouseover.

Try changing

google.maps.event.addListener(marker, 'mouseover', function () {

To

google.maps.event.addListener(marker, 'mouseover', function (e) {
    e.ya.target.removeAttribute('title');

Also for Edge, you need to be change it to:

e.ya.target.parentElement.removeAttribute('title')

JSFiddle Link (Google Maps API not working)

I have been taking advantage of this thread in working on almost the same problem. I am able to get the Google Maps API to properly display European accented glyphs in the pop-up display when a marker is clicked, but the same encoded text string is not properly rendered on mouseover.

So, after looking at the helpful code example in JSFiddle, and not being able to use that suggested technique for removing the 'title' text, it finally became clear to me what MrUpsidown was suggesting when he thought we might just change the name of the property being displayed as a title. I did not realize that the definition of the reserved property 'title' was "text to be displayed on hover." So, the simplest solution is to use a property such as 'myTitle' in the Marker options list. When there is no title property, hovering becomes a non-event.

It appears that the title of your marker is set to the html content of your pop up window. When you create the marker object, give it a title attribute of what you would like to be displayed (i.e. name of your location...)

var marker = new google.maps.Marker({
  position: whateverpositionyouset,
  title: whatevertitleyouwant,
  map: map
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!