1
저는이 분야의 응용 프로그램 개발에 초보자입니다.
API 위도와 경도로부터 응답을 받고 있는데,이를 Google지도에 전달하여지도에 표식을 배치합니다. 하지만 난 오류오류 : TypeError : _this._objectInstance.remove가 함수가 아닙니다.
ERROR: TypeError: _this._objectInstance.remove is not a function.
에게이 유형의 스크립트 코드
getLocation(item){
console.log(item.Street);
var headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append("Accept", 'application/json');
let options = new RequestOptions({ headers: headers });
let postParams = {
Street: "fortesting",
City: "string",
zipORpincode: "string",
DistrictORcounty: "string",
State: "string",
Country: "string"
}
this.http.post('http://link of an API',postParams, options)
.subscribe(
res => {
let dataTemp = res.json(); //dataTemp is the json object you showed me
this.Longitude = dataTemp.Longitude; //contains a [] object with all yours users
this.Latitude = dataTemp.Latitude;
console.log(this.Longitude);//This is for log
console.log(this.Latitude);//This is for log
let mapOptions: GoogleMapOptions = {
camera: {
target: {
lat: this.Latitude,
lng: this.Longitude
},
zoom: 18,
tilt: 30
}
};
this.map = GoogleMaps.create('map_canvas', mapOptions);
// Wait the MAP_READY before using any methods.
this.map.one(GoogleMapsEvent.MAP_READY)
.then(() => {
console.log('Map is ready!');
// Now you can use all methods safely.
this.map.addMarker({
title: 'Ionic',
icon: 'blue',
animation: 'DROP',
position: {
lat: this.Latitude,
lng: this.Longitude
}
})
.then(marker => {
marker.on(GoogleMapsEvent.MARKER_CLICK)
.subscribe(() => {
alert('clicked');
});
});
});
},
err => {
console.log(err);
}
);
}
을 얻고이 map_canvas
가정
<button ion-button block menuToggle="right" color="menu-o"
(click)='getLocation(results)'>
<div>
<ion-icon name="create"></ion-icon>
<label>Get Location</label>
</div>
</button>
에 의해 제안? –
이 코드 조각은 괜찮습니다. 오류는 'remove' 함수를 호출하는 구성 요소에서 비롯됩니다. 대신 찾을 수 있을까요? – trichetriche
코드에서 remove 함수를 사용하지 않았습니다. – Bala