์๋ ํ์ธ์, ์ง๊ธ๊น์ง์ ์์ ์ ์ข์ํ์ง๋ง ๊ถ๊ธํฉ๋๋ค.์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ angular1์ google-maps ๊ตฌํ๊ณผ ์ ์ฌํ ์ ์ฒด google.maps ๊ฐ์ฒด์ ๋ํ ์ก์ธ์ค ๊ถํ์ ๋ถ์ฌํ ๊น์? (์ฌ๊ธฐ ์ฐธ์กฐ : http://angular-ui.github.io/angular-google-maps/#!/api/GoogleMapApi)
google.maps ๊ฐ์ฒด๋ฅผ ๊ฐ์ ธ ์ค๋ฉด ๋ค์์ ๋ง๋ค ์ ์์ต๋๋ค.
์ DirectionsRenderer ๋ฐ DirectionsService๋ฅผ ๋ง๋๋ A1 ์ฝ๋ :
uiGmapGoogleMapApi.then(function(maps) {
vm.gmaps = maps;
vm.map.directionsDisplay = new vm.gmaps.DirectionsRenderer();
vm.map.directionsService = new vm.gmaps.DirectionsService();
});
๋๋ ์ LatLng ๊ฐ์ฒด๋ฅผ ๋ง๋ค๋ ค๋ฉด :
var latlng = new vm.gmaps.LatLng(lat, lng);
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ๊ฐ๋ฅํ ๊น์?
ํธ์ง : Google ๊ฐ์ฒด๊ฐ ์ ์ธ๊ณ์ ์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅํ๋ค๋ ๊ฒ์ ์์์ต๋๋ค. ๊ทธ๋์ ์ฐ๋ฆฌ๋ var latlng = new google.maps.LatLng (lat, lng); ๊ทธ๋ฌ๋ Google ๊ฐ์ฒด๊ฐ ๊ธ๋ก๋ฒ ๋ค์ ์คํ์ด์ค๋ฅผ ์ค์ผ์ํค๋ ๊ฒ์ ๋ฐฉ์งํ๋ ๊ฒ์ด ํ๋ก์ ํธ์ ๋ชฉํ๊ฐ ์๋๋๊น?
EDIT to EDIT : ์ด์ LatLngLiteral ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก ํ ๊ฐ์ง ๋ฌธ์ ๋ฅผ ์ฒ๋ฆฌ ํ ์ โโ์์ต๋๋ค.
import {LatLngLiteral} from 'angular2-google-maps/core';
...
var latlng = <LatLngLiteral>{lat: this.latitude, lng: this.longitude};
this.map.setCenter(latlng);
์๋ ํ์ธ์ cviccaro,
google.maps ๊ฐ์ฒด์ ๋ํ ์ก์ธ์ค ๊ถํ์ ์ป์ผ๋ ค๋ฉด ์๋ ์ธ๊ธ ๋ ์ฃผ์์ ์ฐธ์กฐํ์ญ์์ค.
https://github.com/SebastianM/angular2-google-maps/issues/139#issuecomment -187343516
@ parmod-arora,
๊ฐ์ฌ. ์ง๋ ๊ฐ์ฒด๋ฅผ ๊ฐ์ ธ ์์ง๋ง ์ ์ฒด SDK์ API๋ฅผ ์ฐธ์กฐํ์ต๋๋ค. DirectionsRenderer ๋ฐ DirectionsService๋์ง๋ ๊ฐ์ฒด ์์ฒด๊ฐ ์๋๋ผ google.maps ๋ค์ ์คํ์ด์ค์ ์์ต๋๋ค.
๊ทธ๋ฌ๋ ์ด๊ฒ์ ๋ค์ ์๊ฐํ ๋ ์ ์ฒด google.maps ๋ค์ ์คํ์ด์ค์ ๋ํ ์ง์ ์ก์ธ์ค๋ ์ค๊ณ ์ ์ ๊ณต๋์ง ์๊ณ ๋์ ๊ฐ ๋ํผ๊ฐ ๋์ค์ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
@cviccaro ,
๋ด๊ฐ ํ๋ ธ๋ค๋ฉด ์ ์ ํ์ญ์์ค. google.maps์ ์ก์ธ์คํ๊ณ DirectionsRenderer ๋ฐ DirectionsService ์๋น์ค๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์ต๋๋ค.
์๋๋ ์ฝ๋์ ๋๋ค.
declare var google: any;
@Directive({
selector: 'my-comp', // <home></home>
})
export class MyComp {
constructor(private _mapsWrapper:GoogleMapsAPIWrapper){
_mapsWrapper.getMap().then((m: mapTypes.GoogleMap) => {
console.log(google.maps);
});
}
}
@ parmod-arora ์ ํํฉ๋๋ค. ์๋ณธ ๊ฒ์๋ฌผ์ ๋ํ ํธ์ง ๋ด์ฉ์ ์ผ์ ๋ ๊ธ๋ก๋ฒ Google ๊ฐ์ฒด๋ฅผ ์ค์ ๋ก ์ฌ์ฉํ ์ ์์์ ์์์ผ๋ฏ๋ก ๋ด ์ง๋ฌธ์ด ์ฝ๊ฐ ๋ฒ์ด๋ฌ์ต๋๋ค. ์ด ํ๋ก์ ํธ๋ ๊ฒฐ๊ตญ ์ ์ญ ๋ค์ ์คํ์ด์ค์์ Google ๊ฐ์ฒด๋ฅผ ์ ๊ฑฐํ์ฌ DirectionsRenderer ๋๋ DirectionsService๋ฅผ ์ด๊ธฐํํ๊ธฐ ์ํด ๊ฐ์ ธ์ฌ ๋ชจ๋์ ์ ๊ณตํฉ๋๊น?
์ด ํ๋ก์ ํธ๋ ๊ฒฐ๊ตญ ๊ธ๋ก๋ฒ ๋ค์ ์คํ์ด์ค์์ Google ๊ฐ์ฒด๋ฅผ ์ ๊ฑฐํฉ๋๊น?
์๋์, ์ด๊ฒ์ ํ๋ก์ ํธ์ ๋ชฉํ๊ฐ ์๋๋๋ค. angular2 / google์ง๋์ ์ฌ์ฉํ๊ธฐ ์ฌ์ด ์ถ์ํ ๋ ์ด์ด๋ฅผ ์ ๊ณตํฉ๋๋ค. DirectionsRenderer ๋๋ DirectionsService์ ๊ฐ์ Google์ง๋ API์ ํน์ ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์๊ฐํ ์ ์์ต๋๋ค. Angular 2๋ฅผ์ํ ์ข์ API๊ฐ ์ด๋ป๊ฒ ์๊ฒผ๋์ง ๋ ผ์ํ๊ธฐ ์ํด ์ด๊ฒ์ ์ด์ด ๋ณด์์ต๋๋ค.
์ฌ๊ธฐ์์ ๋ชจ๋ ๊ฒ์ ์ฌ๋ฐ๋ฅด๊ฒ ์ดํดํ๊ณ ์๋ค๋ฉด์ด๋ฅผ ์ฒ๋ฆฌํ๋ ๊ฐ์ฅ ๊ฐ์ง ๋ฐฉ๋ฒ์ ์ ์ญ ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ ์๋น์ค๋ฅผ ๊ฐ๋ ๊ฒ์ด ์๋๊น์? ์ด๊ฒ์ ํ ์คํธ๋ฅผ์ํ ์กฐ๋กฑ์ ๊ฐ๋ฅํ๊ฒํ๊ณ ์ ์ญ ์์กด์ฑ์ ํผํ ์ ์์ต๋๋ค.
์๋ ํ์ธ์ @cviccaro ๋น์ ์ google.maps ๊ฐ์ฒด๊ฐ ์๋ํ๋ค๊ณ ์ธ๊ธํ์ต๋๋ค. ์ด๋ป๊ฒํ๋์ง ๋ณด์ฌ ์ฃผ์๊ฒ ์ต๋๊น? GoogleMapsAPIWrapper๋ฅผ ํตํด ์ด๋ฃจ์ด ์ก์ต๋๊น?
์ด ๋ฌธ์ ๋ ์ต๊ทผ ํ๋์ด ์์๊ธฐ ๋๋ฌธ์ ์๋์ผ๋ก ์ค๋๋ ๊ฒ์ผ๋ก ํ์๋์์ต๋๋ค. ๋ ์ด์ ํ๋์ด ๋ฐ์ํ์ง ์์ผ๋ฉด ํ์๋ฉ๋๋ค. ๊ทํ์ ๊ธฐ์ฌ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ฌ๊ธฐ์์ ๋ชจ๋ ๊ฒ์ ์ฌ๋ฐ๋ฅด๊ฒ ์ดํดํ๊ณ ์๋ค๋ฉด์ด๋ฅผ ์ฒ๋ฆฌํ๋ ๊ฐ์ฅ ๊ฐ์ง ๋ฐฉ๋ฒ์ ์ ์ญ ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ ์๋น์ค๋ฅผ ๊ฐ๋ ๊ฒ์ด ์๋๊น์? ์ด๊ฒ์ ํ ์คํธ๋ฅผ์ํ ์กฐ๋กฑ์ ๊ฐ๋ฅํ๊ฒํ๊ณ ์ ์ญ ์์กด์ฑ์ ํผํ ์ ์์ต๋๋ค.