Google maps 在谷歌地图信息窗口angular2中显示自定义标记
map.component.ts代码:Google maps 在谷歌地图信息窗口angular2中显示自定义标记,google-maps,angular,Google Maps,Angular,map.component.ts代码: ...... infoWindow = new google.maps.InfoWindow( { content: `<custom-tag></custom-tag>` //***not displaying anything*** }); infoWindow.open(map, marker); ...... 。。。。。。 infoWindow=新建google.maps.infoWindow( { 内容:`
......
infoWindow = new google.maps.InfoWindow(
{
content: `<custom-tag></custom-tag>` //***not displaying anything***
});
infoWindow.open(map, marker);
......
。。。。。。
infoWindow=新建google.maps.infoWindow(
{
内容:`/***不显示任何内容***
});
信息窗口。打开(地图、标记);
......
map.component.html代码:
<custom-tag></custom-tag> <!--***displays hi***-->
<div class="google-maps"></div>
<h2>hi</h2>
custom-tag.component.html代码:
<custom-tag></custom-tag> <!--***displays hi***-->
<div class="google-maps"></div>
<h2>hi</h2>
hi
module.ts、routing.ts文件肯定没有错误。
信息窗口只是打开,什么也不显示,
请帮助我找出信息窗口没有显示任何内容的原因。您必须通过
ComponentFactoryResolver
const compFactory = this.resolver.resolveComponentFactory(CustomTag);
this.compRef = compFactory.create(this.injector);
this.appRef.attachView(this.compRef.hostView);
let div = document.createElement('div');
div.appendChild(this.compRef.location.nativeElement);
this.infoWindow.setContent(div);
this.infoWindow.open(this.map, marker);
这里是
不要忘记将CustomTag
组件添加到entryComponents