Sencha map infowindow

Sencha map infowindow 的问题

在使用map的过程中,发现多个地标的infowindow是无法关闭的

因为在sencha中不如在js中可以设定多个全局变量来控制,所以google搜来的教程大多不可用

写下我的解决方案

01. showinfomessage:function (map, markers, index) {
02. google.maps.event.addListener(markers<ol>
03. </ol>
04. 'click'function (event) {
05. if (markers) {
06. for (i in markers) {
07. if(markers[i].infowindow) markers[i].infowindow.close();
08. }
09. }
10. markers<ol>
11. </ol>
12. .infowindow.open(map, markers<ol>
13. </ol>
14. );
15. });
16. },
17. onMapMaprender:function (mapview, gmap, options) {
18. var markers = [];
19. var i =0;      
20. store.load(function (records, operation, success) {
21. store.each(function (record) {
22. i=i+1;
23. markers[i]= new google.maps.Marker({
24. position:new google.maps.LatLng([record.get('latitude')], [record.get('longitude')]),
25. map:gmap,
26. draggable:true,
27. title:record.get('name'),
28. animation:google.maps.Animation.DROP
29. });
30. markers[i].infowindow = new google.maps.InfoWindow({
31. content: contentString
32. });
33. mapview.showinfomessage(gmap,  markers,i);
34. })
35. });
36. }

讲数组作为参数传递
有人会问为什么不在一个函数里写完,发现

google.maps.event.addListener
如果不在另外一个函数里会只增加到一个marker上

作者:yiboo
原文:http://www.csdn123.com/html/blogs/20130417/3260.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值