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