Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.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
Javascript 是否有更新/刷新agm地图组件的方法?_Javascript_Angular_Google Maps Api 3_Rxjs - Fatal编程技术网

Javascript 是否有更新/刷新agm地图组件的方法?

Javascript 是否有更新/刷新agm地图组件的方法?,javascript,angular,google-maps-api-3,rxjs,Javascript,Angular,Google Maps Api 3,Rxjs,我正在尝试更新应用程序中的地图组件,我希望刷新位置并将地图平移到表单中键入的纬度和经度上 我现在有一个问题: HTML组件: 折射局部 类型脚本: refreshMap(){ 常数位置={ 坐标:{lat:this.myform.controls.('latitude').value,lng:this.myform.controls.('longitude').value}, }; this.marker.position=position.coords; const currentLat=

我正在尝试更新应用程序中的地图组件,我希望刷新位置并将地图平移到表单中键入的纬度和经度上

我现在有一个问题:

HTML组件:


折射局部
类型脚本:

refreshMap(){
常数位置={
坐标:{lat:this.myform.controls.('latitude').value,lng:this.myform.controls.('longitude').value},
};
this.marker.position=position.coords;
const currentLat=this.marker.position.lat;
const currentLng=this.marker.position.lng;
此.纬度.设定值(currentLat);
此.经度.设定值(currentLng);
}
这样,当我单击按钮时,它会将agm地图平移到当前输入上的值所表示的位置,并在该位置添加一个标记。我不想使用按钮,而是在输入坐标时做出反应,比如在某个时间后它会更新地图,但通过按钮它对我有效(我在同一屏幕上有输入和agm地图)。我有什么办法可以做到这一点吗?

试试下面的方法

  • 订阅表单的
    valueChanges
    属性。这将在您对表单进行任何更改时执行
  • 通过管道将订阅发送到
    debounceTime
    操作符,这将确保在调用函数之前有一个延迟
  • 通过
    distinctUntilChanged
    操作符对可观察对象进行管道传输,我们不希望对相同的值调用location
从'rxjs'导入{combinelatetest};
从“rxjs/operators”导入{debounceTime,distinctUntilChanged,tap};
latitude$=this.myform.get('latitude').valueChanges;
经度$=this.myform.get('longitude').valueChanges;
formChanges$=CombineTest([this.latitude$,this.longitude$]).pipe(
去BounceTime(1000),
distinctUntilChanged(),
点击(()=>this.refreshMap())
)
恩戈尼尼特(){
this.formChanges$.subscribe()
}
试试下面的方法

  • 订阅表单的
    valueChanges
    属性。这将在您对表单进行任何更改时执行
  • 通过管道将订阅发送到
    debounceTime
    操作符,这将确保在调用函数之前有一个延迟
  • 通过
    distinctUntilChanged
    操作符对可观察对象进行管道传输,我们不希望对相同的值调用location
从'rxjs'导入{combinelatetest};
从“rxjs/operators”导入{debounceTime,distinctUntilChanged,tap};
latitude$=this.myform.get('latitude').valueChanges;
经度$=this.myform.get('longitude').valueChanges;
formChanges$=CombineTest([this.latitude$,this.longitude$]).pipe(
去BounceTime(1000),
distinctUntilChanged(),
点击(()=>this.refreshMap())
)
恩戈尼尼特(){
this.formChanges$.subscribe()
}