谷歌地图v3标记标题属性
在我的函数中,我循环遍历状态数组并将标记放置在每个状态的中心。我希望每个标记工具提示显示其特定信息。但是,由于某种原因,当我将鼠标悬停在标记上时,即使我使用 title 属性实例化了标记,工具提示也不会在其中任何一个标记上弹出。
请参阅下面的代码:
mark = new google.maps.Marker({
map: map,
position: center,
title:inspStates[i].name+ "<br/>"+"total: "+inspStates[i].totalInsp+ "<br/>"+ info
});
我的错误是什么?
In my function I am looping through an array of states and placing markers in the center of each state. I want each marker tooltip to display its specific information. However, for some reason when I mouse over the markers a tooltip doesn't popup over any of them even though I instantiated the marker with the title property.
see code below:
mark = new google.maps.Marker({
map: map,
position: center,
title:inspStates[i].name+ "<br/>"+"total: "+inspStates[i].totalInsp+ "<br/>"+ info
});
what is my error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码有错误
title:inspStates[i].name+ "
"+"total: "+inspStates[i].totalInsp+ "
"+ info;
结尾的分号是错误的。您正在定义一个对象属性,但不是简单变量。
2.根据您的代码,所有标记将显示在同一位置(当然,如果每次循环迭代都没有定义
center
),也许应该有类似这样的
inspStates[i]。位置
?UPD
这是我的代码示例。
也许会有帮助。此代码显示了三个带有预定义标题的标记。你的代码和我的一样吗?还有一个问题:代码中的变量
center
是否在每次循环迭代中发生更改。我已经讨论过了,但oyu还没有发表评论。您能否发布您的代码示例以获得更多帮助?
You have error in your code
title:inspStates[i].name+ "
"+"total: "+inspStates[i].totalInsp+ "
"+ info;
The trailing semicolon is mistaken. You are defining an object property but not the simple variable.
2. According to your code all markers will be shown at same place(Of course, if
center
is not being defined each loop iteration)Maybe there should be something like this
inspStates[i].position
?UPD
Here is my code sample.
Maybe it will be helpfull. Three markers with predifined titles has been shown by this code. Is your code like my? Also one question: Is variable
center
from your code being changed each loop itaration. I have talked about it but oyu haven't commented it.Could you please post your code sample to get more help?
我已将disableDefaultUI 设置为true,这显然导致工具提示不显示。当我重新启用它时,所有标记都有一个包含正确信息的工具提示。
I had set the disableDefaultUI to true which apparently caused the tooltips not to be shown. When I reenabled it all the markers had a tooltip with the proper information.