๋ฌธ์ ์ค๋ช
"nearbySearch()"๋ฅผ ์คํํ๊ธฐ ์ํด ์ฅ์ ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํฉ๋๋ค.
๋ฌธ์ ์ฌํ ๋จ๊ณ ๋ฐ ์ต์ํ์ ๋ฐ๋ชจ
๊ณต๊ฐ findHospital() {
์ง๋ = new google.maps.Map(document.createElement('div'));
var ์ฅ์ ์๋น์ค = ์๋ก์ด google.maps.places.PlacesService(์ง๋);
var ์ฅ์: ๋ชจ๋ = Observable.bindCallback(placesService.nearbySearch);
var pyrmont = new google.maps.LatLng(19.107567, 72.8335)
var request = {
location: pyrmont,
radius: 200,
types: ['hospital', 'health'] // this is where you set the map to get the hospitals and health related places
};
return place(request)
.map((response) => {
let result: IDistanceResult;
console.log(response);
return result = {
directions: response[0],
status: response[1]
}
});
}
_๋ฐ๋ชจ์์ ๋ฌธ์ ๋ฅผ ํ์ธํ๋ ค๋ฉด ์ด๋ค ๋จ๊ณ๋ฅผ ์๋ํด์ผ ํฉ๋๊น?_
ํ์ฌ ํ๋
์กํ์ง ์์ TypeError: ์ ์๋์ง ์์ 'nearbySearch' ์์ฑ์ ์ฝ์ ์ ์์ต๋๋ค.
์์/์ํ๋ ํ๋
์ฃผ๋ณ ์ฅ์ ๋ชฉ๋ก ๋ฐํ
angular2 ๋ฐ angular-google-maps ๋ฒ์
์ต์
๊ธฐํ ์ ๋ณด
๋๋ DirectionsService๊ฐ ์ ์๋ํ๋ ๊ฒ ๊ฐ์์ ๋ฌป๊ธฐ ๋๋ฌธ์ ์ฅ์ ์๋น์ค๋ ๊ทธ๋ ๊ฒ ํ ๊ฒ์ด๋ผ๊ณ ๊ฐ์ ํ์ต๋๋ค.
์๋ง๋ ๋ค์์ ์ฌ์ฉํด์ผ ํ ๊ฒ์
๋๋ค.
var service = new google.maps.places.PlacesService(document.createElement('div'));
๋ค๋ฅธ ๊ณณ์์ ๋งต์ ์ฌ์ฉํ์ง ์๋ ํ PlacesService
๋ ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ผ๋ถ๊ฐ ์๋๋ฏ๋ก ๋ฌธ์ ๋ AGM๊ณผ ๊ด๋ จ์ด ์์ต๋๋ค.
@jgutix ๊ฐ ์๋น์ค ์ธ์คํด์คํ์ ๊ดํด ๋งํ ๊ฒ๊ณผ ์ค์ ๋ก ๊ทธ๋ฐ ์์ผ๋ก ์ ์๋ํ๋ค๋ ๊ฒ์ ๋ฐ๋ณตํ๊ณ ์ถ์์ต๋๋ค. ์ ๋ textSearch ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๋ฐ๋ก ์๋ํฉ๋๋ค. Observable.bindCallback()์์ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค.