Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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
Angular 如何在我的地图实例中设置正确的缩放值_Angular_Leaflet_Zooming - Fatal编程技术网

Angular 如何在我的地图实例中设置正确的缩放值

Angular 如何在我的地图实例中设置正确的缩放值,angular,leaflet,zooming,Angular,Leaflet,Zooming,我正在尝试动态设置地图的缩放级别,当我最终设法发送正确的缩放值作为输入时,我无法更改地图实例上的缩放值。我还有一个配置服务,在该服务中我正在初始化我的组件,在那里我成功地更改了正确的映射配置(lat、lng输入以及缩放值) 问题:我无法更改正确的地图实例 导入{ AfterViewInit, 改变, 组成部分, ElementRef, 输入, 奥尼特, 视图儿童 }从“@angular/core”开始; 从'@angular/forms'导入{FormControl,FormGroup}; 从“

我正在尝试动态设置地图的缩放级别,当我最终设法发送正确的缩放值作为输入时,我无法更改地图实例上的缩放值。我还有一个配置服务,在该服务中我正在初始化我的组件,在那里我成功地更改了正确的映射配置(lat、lng输入以及缩放值)

问题:我无法更改正确的地图实例

导入{
AfterViewInit,
改变,
组成部分,
ElementRef,
输入,
奥尼特,
视图儿童
}从“@angular/core”开始;
从'@angular/forms'导入{FormControl,FormGroup};
从“传单”中输入*作为L;
从“传单地理搜索”导入*作为地理搜索;
从“传单svgicon”导入*作为divIcon;
从“@…”导入{SInputOptions};
从“../pickuppointform.service”导入{PickupPointFormService};
从“@models/dto/pickup point/coordinates dto”导入{coordinates dto};
从'@models/dto'导入{PickupPointDetailsDTO};
从“@models/dto/pickuppointdto/CustomPickupPointDTO”导入{CustomPickupPointDTO};
从'@angular/common/http'导入{HttpClient};
从“../PickupPointsSharedService”导入{PickupPointsSharedService};
声明var H:任何;
@组成部分({
选择器:“皮卡地图”,
templateUrl:'./pickup.component.html',
})
导出类PickupMapComponent实现OnInit,AfterViewInit{
@ViewChild('map',{static:false})
公共mapElement:ElementRef;
@输入()
公共appId:string;
@输入()
公共应用程序代码:字符串;
@输入()
公共lat:string;
@输入()
公共液化天然气:字符串;
@输入()
公共宽度:字符串;
@输入()
公众高度:弦;
@Input()设置缩放(缩放:数字){
如果(缩放!==未定义){
this.map.setZoom(缩放);
}
控制台日志(缩放);
}
@输入()
公共customPoints:CustomPickupPointDTO;
公共窗体=新窗体组({
searchField:新表单控件(“”)
});
公共搜索选项:SInputOptions={
占位符:“搜索”,
optionalLabel:“(可选)”,
键入:“字符串”
};
公共高度测试:字符串;
私人地图:任何;
私人平台:任何;
私人搜查:任何;
公共磁砖:字符串;
公共查询:字符串;
私有用户界面:任意;
私有maxMarkersLimit=9;
私有markerIndex=1;
private numberIcon=new divIcon.SVGIcon({
circleText:this.markerIndex.toString(),
不透明度:1
});
公共构造函数(
私有http:HttpClient,
公共pickupPointFormService:pickupPointFormService,
公共pickupPointsSharedService:pickupPointsSharedService,
私有更改检测:ChangeDetectorRef
) {
this.heightTest=window.innerHeight+'px';
this.query='';
}
公共ngOnInit(){
this.changesDetection.markForCheck();
}
私有initMap():void{
this.changesDetection.markForCheck();
const zoomValue=this.zoom==未定义?2:this.zoom;
console.log(this.lat);
控制台日志(this.lng);
这是一个.src文件https://2.base.maps.api.here.com/maptile/2.1/maptile/newest/normal.day/{z} /{x}/{y}/512/png8?app_id='+this.appId+'&app_code='+this.appCode+'&ppi=320';
this.map=L.map(this.mapeElement.nativeElement{
波动性:是的,
pixelRatio:window.devicePixelRatio | | 1,
布局对齐:“左下角”,
中心:[this.lat,this.lng],
缩放:缩放值,
图层:[L.tileLayer(this.srcTiles)],
动物控制:错误
});
log('to zoom',this.zoom);
this.map.attributeControl.addAttribute(“©;HERE 2020”);
this.initMarkers();
}
私有initMarkers():void{
常量firstElement=0;
if(this.pickupPointsSharedService.pointDetails){
const maxmarks=this.pickupPointsSharedService.pointDetails.childrence.length{
如果(this.markerIndex>10){return;}
const clicked numbericon=new divIcon.SVGIcon({
circleText:this.markerIndex.toString(),
不透明度:1
});
this.pickupPointFormService.form.controls.defaultPickupPoint.get('latitude').patchValue(e.latlng.lat.toFixed(4));
this.pickupPointFormService.form.controls.defaultPickupPoint.get('longitude').patchValue(e.latlng.lng.toFixed(4));
log(this.markerIndex,'marker index+1');
log(this.pickupPointFormService.form.controls.customPickupPoints);
//.patchValue(即latlng.lat.toFixed(4))
if(this.pickupPointFormService.form.controls.customPickupPoints[this.markerIndex-2]){
log(this.pickupPointFormService.form.get('customPickupPoints').value[this.markerIndex-2]);
console.log(this.pickupPointFormService.form.controls.customPickupPoints[this.markerIndex-2].get('latitude').patchValue(e.latlng.lat.toFixed(4));
控制台日志(e.latlng.lat.toFixed(4));
//this.pickupPointFormService.form.get('customPickupPoints').value[this.markerIndex-2].latitude.patchValue(e.latlng.lat.toFixed(4));
}
//this.pickupPointFormService.form.get('customPickupPoints').va
L.marker([e.latlng.lat,e.latlng.lng],{icon:clickedNumberIcon}).addTo(this.map);
this.markerIndex=this.markerIndex+1;
});
}
}