又发现一个小bug

1 view
Skip to first unread message

lch...@gmail.com

unread,
Dec 11, 2005, 10:26:17 AM12/11/05
to 灵图地图接口讨论区
为多个标记添加infoWindow的时候,只有最后一个添加的infoWindow显示正常,其它的都显示不出来

K_Reverter

unread,
Dec 11, 2005, 7:25:37 PM12/11/05
to 灵图地图接口讨论区
这个不是bug这个应该是你的infowindow显示函数中的变量值已经丢失的缘故

要注意到当Javascript语句运行到你对GMarker的动作绑定的时候,被绑定函数的某一个变量比如(html)对应的地址的值可能是你希望的字符串,比如"你好",
可是当用户点击着这个GMarker的时候,该值是不是已经变化了或者不存在了?这样就会出错

lch...@gmail.com

unread,
Dec 11, 2005, 8:26:48 PM12/11/05
to 灵图地图接口讨论区
我没有使用变量
类似以下代码,一试便知.
var marker1 = new LTMarker( new LTPoint( 11636224 , 3991040 ) );
  maps.addOverLay( marker1 );
LTEvent.addListener( marker1 , "mouseover" , function(){
marker1.openInfoWinHtml( "AAA!" ) } );
marker1 = new LTMarker( new LTPoint( 11636224 , 3992140 ) );
  maps.addOverLay( marker1 );
LTEvent.addListener( marker1 , "mouseover" , function(){
marker1.openInfoWinHtml( "111!" ) } );
marker1 = new LTMarker( new LTPoint( 11636224 , 3991240 ) );
  maps.addOverLay( marker1 );
LTEvent.addListener( marker1 , "mouseover" , function(){
marker1.openInfoWinHtml( "BBB!" ) } );
marker1 = new LTMarker( new LTPoint( 11636224 , 3991340 ) );
  maps.addOverLay( marker1 );
LTEvent.addListener( marker1 , "mouseover" , function(){
marker1.openInfoWinHtml( "CCC!" ) } );

K_Reverter

unread,
Dec 12, 2005, 4:59:31 AM12/12/05
to 灵图地图接口讨论区
我试了一下,以上代码基本正常

不过你对四个LTMarker都是用同一个变量名称,我觉得难免会出问题
如果你确实要使用同样的变量名,也建议在所有的


marker1 = new LTMarker( new LTPoint( 11636224 , 3991240 ) );

前面加上var 以便重新分配变量地址,如:
var marker1 = new LTMarker( new LTPoint( 11636224 , 3992140 ) );
这样应该就能够解决

Reply all
Reply to author
Forward
0 new messages