Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 在谷歌地图信息窗口angular2中显示自定义标记_Google Maps_Angular - Fatal编程技术网

Google maps 在谷歌地图信息窗口angular2中显示自定义标记

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( { 内容:`

map.component.ts代码:

......
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