关于鼠标放上去弹出框,提个问题. (google map)

soosoom 2009-04-02 09:24:02
如这个例子:
http://www.google.com/apis/maps/ ... rkerinfowindow.html

我是想知道,
1.那个橙红色的圈圈(是叫标记吗) ,如果能定义到我想要的坐标上呢? 这个是随机的吗?
(代码里写着: // 在地图的随机位置添加 5 个标记
// 注意我们并没有把秘密消息添加到标记的实例数据中)

2.鼠标点击的时候,弹出框的内容,我可以自已定义吗?比如:我里面的内容要换行的.甚至是要插进图片的.

(代码里写着: function initialize() {
var message = ["这","是","个","秘密","消息"];

我不知道怎么设置这个弹出内容.

希望有朋友可以帮一下忙. 感谢!

其实,我是想做到这种效果.

http://www.zbird.com/experience/next
...全文
502 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cwisme 2009-10-17
  • 打赏
  • 举报
回复
晕,搞个写个方法,搞个循环不就行了吗?
EchooooL 2009-04-03
  • 打赏
  • 举报
回复
1:那个是叫标记,至于标记的地点是根据你自己而定的,var point = new GLatLng(x,y) 其中x,y是你要标记地点的经纬度!
2:var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("你要现实的内容,自己定义!");
其中方式是click,就是说你要点击才会产生效果。。至于你说你想的那个效果,只要把click改为mousemove就行了。。
具体可以参阅http://www.codechina.org/doc/google/gmapapi/#Display_Info_Windows_Above_Markers
希望可以对楼主有帮组~
soosoom 2009-04-03
  • 打赏
  • 举报
回复


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?

file=api&v=2&key=ABQIAAAAmSyaZYJEj-

zmAamQg_Fp6BQUdL8CL9NK1APCG9xk56Ma5zl32BTSNGgpdQgj1PRIyxFaQXrkGAHHAA"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[


function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(34.265,108.46), 5);
map.setCenter(new GLatLng(30.265,100.46), 4); //第二个标记,不生效,是这样写吗


}
var point = new GLatLng(30.22,120.20);
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function(){marker.openInfoWindowHtml

("HangZhou!");});

GEvent.addListener(marker, "mouseover", function(){marker.openInfoWindowHtml

("ShenZhen!");}); //第二个标记的标注,请问是这样写吗?谢谢!


map.addOverlay(marker);

}

</script>
</head>
<body onload="load()">
<div id="map" style="width: 1000px; height: 800px"></div>
</body>
</html>



假如我想加入第二个标记和标注的时候,请问是这样写吗?谢谢! 小弟是急着需要这么个东西,我不是程序员,希望大家能指点的下,有时间我一定再详细看看,谢谢! 麻烦了!


EchooooL 2009-04-03
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[


function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(34.265,108.46), 5);
}

var point = new GLatLng(30.22,120.20);
var marker = new GMarker(point);
GEvent.addListener(marker, "mouseover", function(){marker.openInfoWindowHtml("HangZhou!");});

map.addOverlay(marker);

}

</script>
</head>
<body onload="load()">
<div id="map" style="width: 1000px; height: 800px"></div>
</body>
</html>


试试吧,如果您想多了解Google Map,还是希望多看看Google Maps API中文同步文档
soosoom 2009-04-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 mclun0907 的回复:]
1:那个是叫标记,至于标记的地点是根据你自己而定的,var point = new GLatLng(x,y) 其中x,y是你要标记地点的经纬度!
2:var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml("你要现实的内容,自己定义!");
其中方式是click,就是说你要点击才会产生效果。。至于你说你想的那个效果,只要把click改为mousemove就行了。。
具体可以参阅http://www.codechi…
[/Quote]

假如我有要定义10个标记,如下写么.

var point = new GLatLng(x1,y1)
var point = new GLatLng(x2,y2)
……
var point = new GLatLng(x10,y10)
--------------------------------------
marker.openInfoWindowHtml("内容,1");
marker.openInfoWindowHtml("内容,2");
……
marker.openInfoWindowHtml("内容,10");


但是这样无效呢, 希望有经验的朋友可以给一点建议我,谢谢!

例子如下 :http://www.google.com/apis/maps/documentation/markerinfowindow.html


soosoom 2009-04-02
  • 打赏
  • 举报
回复
http://www.google.com/apis/maps/documentation/markerinfowindow.html

上面那个连接坏了,我重发一下.
goldlive_8888 2009-04-02
  • 打赏
  • 举报
回复
如果你现在开发的工程是二次开发,那我建议你还是查查本工程内是否有相似的功能。

81,076

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧