2012-05-29 132 views
-2

这是有问题的网页...谷歌地图的JavaScript标记问题

http://dev.digitalskydesign.com/locations/

去那里,悬停的谷歌地图上的“绿色”图标之一。在你点击它之前,将鼠标悬停在它上面,你会看到一堆代码弹出。

我不想让代码出现,但我很难弄清楚如何在JavaScript代码中处理这些代码。

处理这个地图可以在这里找到的JavaScript代码...

http://dev.digitalskydesign.com/wp-content/themes/Teamsters-FCU/locations-iframe.php

还有一个名为“分支的locations.txt” .txt文件,基本上是刚地址和地址解析为所有的地图标记位置。

我不是一个JavaScript大师(只是一个网页设计师),所以如果你能告诉我什么代码修改/包括以及放在哪里,那将是非常感激。

谢谢你们!

回答

1

看起来你的工具提示属性中有html。

看起来代码:var label = points[i].textArray[2]; 是造成这个问题。

如果您希望获得提示的HTML标记,则需要将事件添加到标记的mouseover事件中,该事件在元素中显示工具提示,并在mouseout上添加事件以删除提示元素。

您拥有的其他选项是将标签更改为没有HTML标记的东西。

添加使用JavaScript代码提示的下面是一个例子:

其中一些来自How to call fromLatLngToDivPixel in Google Maps API V3?

//You need this to get the projection... put this code at the top of your javascript after you declare map 
var overlay = new google.maps.OverlayView(); 
overlay.draw = function() {}; 
overlay.setMap(map); //Where map is your Map2 instance 

//Put this code at line 164 
var label = ''; 
points[i].marker = new GMarker(points[i],{title: label, icon:tinyIcon(opts.icon)}); 
google.maps.event.addListener(points[i].marker, 'mouseover', function() { 

//Create the tip and get the Point so position the tip 
var toolTip = document.createElement('div'),   
    point = overlay.getProjection().fromLatLngToDivPixel(this.getPosition()); 
toolTop.styles.position = 'absolute'; 
toolTop.styles.left = point.x; 
toolTop.styles.top = point.y 

document.body.appendChild(toolTip); 

google.maps.event.addListener(this, 'mouseout', function() { 
    document.body.removeChild(toolTip); 
    }); 

}); 
+0

被带到我要以$ 5或1 BTC的HTML工具提示的例子+您投票:p – Jay

+0

我不是JavaScript的大师,我基本上只是从谷歌的一个例子中复制这段代码,并自定义它来适应我的网站主题。任何帮助一个特定的代码,我可能会添加(以及在哪里广告),将不胜感激。 – DigitalSky

+0

我是StackOverflow的新手......什么是BTC? – DigitalSky