【发布时间】:2017-10-06 16:56:21
【问题描述】:
我是 ionic 框架的新手。我正在构建一个应用程序,它与科尔多瓦谷歌地图插件一起使用。 我的问题是:我希望在加载地图后显示所有自定义信息窗口。我尝试了很多选择,但仍然没有运气。现在它每次点击一个标记只打开一个窗口,当我点击另一个标记时关闭它。也许有人可以帮我解决这个问题? 非常感谢!!
addMarkers(markers){
for(let marker of markers){
this.map.addCircle({
center:{lat:marker.lat, lng:marker.lng},
radius: 50,
strokeColor: 'red',
strokeWidth:1,
fillColor:'red'
});
this.map.addMarker({
icon: {
'url': "./assets/marker.png",
'size': {
width: 27,
height: 10
},
},
animation: 'DROP',
position: {
lat: marker.lat,
lng: marker.lng
}
}).then((marker)=>{
marker.on(GoogleMapsEvent.MARKER_CLICK)
.subscribe(() => {
this.bindInfo(marker, this.setDiv(div));
})
})
}
}
setDiv(div){
let compFactory = this.resolver.resolveComponentFactory(DivComponent);
this.compRef = compFactory.create(this.injector);
if (this.compRef) this.compRef.instance.timeInSeconds = div.time;
this.appRef.attachView(this.compRef.hostView);
let div = document.createElement('div');
div.appendChild(this.compRef.location.nativeElement);
return div
}
bindInfo(marker, content){
let info= new HtmlInfoWindow();
info.setContent(content);
info.open(marker)
}
【问题讨论】:
标签: angular google-maps google-maps-api-3 cordova-plugins ionic3