Angular-google-maps: ๊ธธ์ฐพ๊ธฐ ์„œ๋น„์Šค

์— ๋งŒ๋“  2016๋…„ 07์›” 08์ผ  ยท  54์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: SebastianM/angular-google-maps

์•ˆ๋…•ํ•˜์„ธ์š”,

๊ธธ์ฐพ๊ธฐ ์„œ๋น„์Šค ๋ฅผ ์ง€์›ํ•  ๊ณ„ํš์ด ์žˆ์Šต๋‹ˆ๊นŒ?

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด ์ง€์‹œ๋ฌธ์€ ๊ท€ํ•˜์˜ ์š”๊ตฌ ์‚ฌํ•ญ์„ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

import {GoogleMapsAPIWrapper} from 'angular2-google-maps/core/services/google-maps-api-wrapper';
import { Directive,  Input} from '@angular/core';
declare var google: any;



@Directive({
  selector: 'sebm-google-map-directions'
})
export class DirectionsMapDirective {
  @Input() origin;
  @Input() destination;
  constructor (private gmapsApi: GoogleMapsAPIWrapper) {}
  ngOnInit(){
    this.gmapsApi.getNativeMap().then(map => {
              var directionsService = new google.maps.DirectionsService;
              var directionsDisplay = new google.maps.DirectionsRenderer;
              directionsDisplay.setMap(map);
              directionsService.route({
                      origin: {lat: this.origin.latitude, lng: this.origin.longitude},
                      destination: {lat: this.destination.latitude, lng: this.destination.longitude},
                      waypoints: [],
                      optimizeWaypoints: true,
                      travelMode: 'DRIVING'
                    }, function(response, status) {
                                if (status === 'OK') {
                                  directionsDisplay.setDirections(response);
                                } else {
                                  window.alert('Directions request failed due to ' + status);
                                }
              });

    });
  }
}

๋ชจ๋“  54 ๋Œ“๊ธ€

์ €์—๊ฒŒ๋„ ๊ฐ™์€ ์งˆ๋ฌธ..

angular2-google-maps์™€ ํ•จ๊ป˜ ๊ธธ์ฐพ๊ธฐ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

-> ๊ธธ์ฐพ๊ธฐ ์„œ๋น„์Šค
-> ์˜ˆ

๋‹น์‹ ์˜ ๋…ธ๊ณ ์— ์ง„์‹ฌ์œผ๋กœ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค
-- ํฌ๋ฆฌ์Šค

์ด๊ฒƒ์ด ๋‚ด๊ฐ€ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋Š” ํ•ญ๋ชฉ์ธ์ง€ ์•Œ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. ์ €๋Š” ์ง€๋„ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋‘ ์œ„์น˜ ์‚ฌ์ด์—์„œ Google์˜ ์ œ์•ˆ๋œ ๋ฐฉํ–ฅ์„ ํ‘œ์‹œํ•ด์•ผ ํ•˜๋Š” ๋‹ค์†Œ ์ง€๋„๊ฐ€ ๋งŽ์€ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด์•˜์ง€๋งŒ ์ฐพ์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ ์•Œ๋ ค์ฃผ์„ธ์š”. ์–ด๋Š ์ชฝ์ด๋“ , ์ด ํ”„๋กœ์ ํŠธ๋Š” ํ™˜์ƒ์ ์ž…๋‹ˆ๋‹ค! ์ž‘์—… ํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค

์ด ์ง€์‹œ๋ฌธ์€ ๊ท€ํ•˜์˜ ์š”๊ตฌ ์‚ฌํ•ญ์„ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

import {GoogleMapsAPIWrapper} from 'angular2-google-maps/core/services/google-maps-api-wrapper';
import { Directive,  Input} from '@angular/core';
declare var google: any;



@Directive({
  selector: 'sebm-google-map-directions'
})
export class DirectionsMapDirective {
  @Input() origin;
  @Input() destination;
  constructor (private gmapsApi: GoogleMapsAPIWrapper) {}
  ngOnInit(){
    this.gmapsApi.getNativeMap().then(map => {
              var directionsService = new google.maps.DirectionsService;
              var directionsDisplay = new google.maps.DirectionsRenderer;
              directionsDisplay.setMap(map);
              directionsService.route({
                      origin: {lat: this.origin.latitude, lng: this.origin.longitude},
                      destination: {lat: this.destination.latitude, lng: this.destination.longitude},
                      waypoints: [],
                      optimizeWaypoints: true,
                      travelMode: 'DRIVING'
                    }, function(response, status) {
                                if (status === 'OK') {
                                  directionsDisplay.setDirections(response);
                                } else {
                                  window.alert('Directions request failed due to ' + status);
                                }
              });

    });
  }
}

Hey david, ์ง€์‹œ์— ๊ฐ์‚ฌํ•˜์ง€๋งŒ ๋‚ด ์ฝ”๋“œ์— ํฌํ•จ์‹œํ‚ค๋Š” ๋ฐ ์–ด๋ ค์›€์„ ๊ฒช๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ตฌ๊ธ€ ์ง€๋„ ๋”์— ๋ฐ”๋กœ ๋„ฃ์–ด์•ผ ํ•˜๋‚˜์š”? ์˜ˆ๋ฅผ ๋“ค์–ด:
<sebm-google-map sebm-google-map-directions [origin=x] [destination=y][zoomControl]="false" [latitude]="lat" [longitude]="lng" (mapClick)="mapClicked($event)"> </sebm-google-map>

๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ์ž‘๋™์‹œํ‚ค๋Š” ๋ฐ ์–ด๋ ค์›€์„ ๊ฒช๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ €๋Š” ์‹ค์ œ๋กœ Angular 2๋ฅผ ์ฒ˜์Œ ์ ‘ํ–ˆ์Šต๋‹ˆ๋‹ค... ๋„์™€์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š” @ahardworker , ์ด๊ฒƒ์ด ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค:

<sebm-google-map>
  <sebm-google-map-directions [origin]="origin" [destination]="destination"></sebm-google-map-directions>
</sebm-google-map>

๊ตฌ์„ฑ ์š”์†Œ ์ปจํŠธ๋กค๋Ÿฌ ํด๋ž˜์Šค์—์„œ ์ด ์†์„ฑ์„ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

origin = { longitude: 4.333, lattitude: -1.2222 };  // its a example aleatory position
destination = { longitude: 22.311, lattitude: -0.123 };  // its a example aleatory position

๊ฐ์‚ฌ ํ•ด์š”! ๊ทธ๊ฒƒ์˜ ์ž‘๋™. ํ•˜์ง€๋งŒ ๋™์ ์œผ๋กœ ๊ฒฝ์œ ์ง€๋ฅผ ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ ํŽ˜์ด์ง€๋ฅผ ์ƒˆ๋กœ ๊ณ ์น˜์ง€ ์•Š๊ณ  ๋ฐฉํ–ฅ์„ ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

์‹ค์ œ๋กœ ์—ฌ๊ธฐ์— ๋‚ด๊ฐ€ ์–ป์€ ๊ฒƒ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
๋‚ด ๊ตฌ์„ฑ ์š”์†Œ์— ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

@ViewChild(DirectionsMapDirective) vc:DirectionsMapDirective;
๊ทธ๋Ÿฐ ๋‹ค์Œ ์ƒˆ ๊ฒฝ์œ ์ง€๊ฐ€ ์ถ”๊ฐ€๋  ๋•Œ๋งˆ๋‹ค ๊ตฌ์„ฑ ์š”์†Œ์—์„œ vc.updateDirections()๋ฅผ ํ˜ธ์ถœํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ง€์‹œ๋ฌธ์—์„œ ์ฝ”๋“œ๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. ํ•˜๋Š” ๊ฒƒ์ด ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๊นŒ?

๋ฌผ๋ก  @ahardworker , waypoints๋Š” ์œ„์น˜์˜ ๋ฐฐ์—ด์ž…๋‹ˆ๋‹ค. ์ง€์‹œ๋ฌธ์— ๋…ผ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ž…๋ ฅ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด ๋ฐฐ์—ด์„ ์‚ฝ์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด...

<sebm-google-map>
  <sebm-google-map-directions [origin]="origin" [destination]="destination" [waypoints]="waypoints"></sebm-google-map-directions>
</sebm-google-map>

์ง€๋ น:

@Directive({
  selector: 'sebm-google-map-directions'
})
export class DirectionsMapDirective {
  @Input() origin;
  @Input() destination;
  @Input() waypoits;
  constructor (private gmapsApi: GoogleMapsAPIWrapper) {}
  ngOnInit(){
    this.gmapsApi.getNativeMap().then(map => {
              var directionsService = new google.maps.DirectionsService;
              var directionsDisplay = new google.maps.DirectionsRenderer;
              directionsDisplay.setMap(map);
              directionsService.route({
                      origin: {lat: this.origin.latitude, lng: this.origin.longitude},
                      destination: {lat: this.destination.latitude, lng: this.destination.longitude},
                      waypoints: waypoints,
                      optimizeWaypoints: true,
                      travelMode: 'DRIVING'
                    }, function(response, status) {
                                if (status === 'OK') {
                                  directionsDisplay.setDirections(response);
                                } else {
                                  window.alert('Directions request failed due to ' + status);
                                }
              });

    });
  }
}

์•ˆ๋…•ํ•˜์„ธ์š” @davidpestana
Directions-Directive๋ฅผ ํฌํ•จํ•˜๋ ค๊ณ  ํ–ˆ์ง€๋งŒ ๋‹ค์Œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
Can't bind to 'origin' since it isn't a known property of 'sebm-google-map-directions'.

(์™œ ์„œ์‹์ด ๋‚˜์œ์ง€ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ์–ด์จŒ๋“  ์ฝ์„ ์ˆ˜ ์žˆ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค.)

HTML
<sebm-google-map [latitude]="lat" [longitude]="lng" [zoom]="zoom"> <sebm-google-map-marker [latitude]="latHome" [longitude]="lngHome" [title]="'titleHome'"</sebm-google-map-marker> <sebm-google-map-marker [latitude]="latComp" [longitude]="lngComp" [title]="titleComp"</sebm-google-map-marker> <sebm-google-map-directions [origin]="origin" [destination]="destination"></sebm-google-map-directions> </sebm-google-map>

์š”์†Œ
`@์ปดํฌ๋„ŒํŠธ({
์„ ํƒ๊ธฐ: 'google-maps',
์Šคํƒ€์ผ: [require('./googleMaps.scss')],
ํ…œํ”Œ๋ฆฟ: require('./googleMaps.html'),
})
๋‚ด๋ณด๋‚ด๊ธฐ ํด๋ž˜์Šค GoogleMaps {
์œ„๋„ ํ™ˆ: ๋ฒˆํ˜ธ = 48.151839;
lngHome: ๋ฒˆํ˜ธ = 13.831726;
latComp: ์ˆซ์ž = 48.329500;
lngComp: ๋ฒˆํ˜ธ = 14.319765;
titleComp: ๋ฌธ์ž์—ด = "dynatrace";
ํ™•๋Œ€/์ถ•์†Œ: ์ˆซ์ž = 10;

์œ„๋„: ์ˆซ์ž = (this.latComp + this.latHome) / 2;
lng: ์ˆซ์ž = (this.lngComp + this.lngHome) / 2;

์›์  = { ๊ฒฝ๋„: 4.333, ์œ„๋„: -1.2222 };
๋ชฉ์ ์ง€ = { ๊ฒฝ๋„: 22.311, ์œ„๋„: -0.123 };
}`

์ง€์‹œ๋ฌธ์„ ์–ด๋”˜๊ฐ€์— ๋“ฑ๋กํ•ด์•ผ ํ•ฉ๋‹ˆ๊นŒ?

@ProkerBen ์˜ˆ, ์‚ฌ์šฉํ•˜๋Š” ๋‹ค๋ฅธ ์ง€์‹œ๋ฌธ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์‚ฌ์šฉ ์ค‘์ธ ๋ชจ๋“ˆ์— ์ง€์‹œ๋ฌธ์„ ์„ ์–ธ์œผ๋กœ ๋“ฑ๋กํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ @ProkerBen , @lazarljubenovic์ด ๋งํ–ˆ๋“ฏ์ด ๋ชจ๋“ˆ์— ์ง€์‹œ๋ฌธ์„ ๋“ฑ๋กํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

import { CustomMapDirective } from '[your route to directive folder]/google-map.directive';
...
@NgModule({
  imports: [...],
  exports: [..],
  declarations:[...,CustomMapDirective]
})

@davidpestana DirectionsMapDirective๋Š” ๊ฒฝ๋กœ๋ฅผ ํ‘œ์‹œํ•˜์ง€๋งŒ ํ™•๋Œ€/์ถ•์†Œ=17๋กœ ์„ค์ •ํ–ˆ์ง€๋งŒ ํ™•๋Œ€๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Google API ์†์„ฑ์€ DirectionsDisplayService๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋ชจ๋“  ์›จ์ดํฌ์ธํŠธ๋ฅผ ๋ณด๊ธฐ ์œ„ํ•ด ์ง€๋„๊ฐ€ ์ž๋™์œผ๋กœ ํ™•๋Œ€/์ถ•์†Œ๋ฉ๋‹ˆ๋‹ค. Zoom ๊ฐ’์„ ์„ค์ •ํ•˜๋ฉด ๋ฌด์‹œ๋ฉ๋‹ˆ๋‹ค.

@davidpestana ์•ผ! ๋‚˜๋Š” GMapSDK์˜ ์ˆœ์ˆ˜ํ•œ ๊ธฐ๋Šฅ์„ ์‹œ๋„ํ–ˆ๊ณ  ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

}, function(response, status) {
  if (status === 'OK') {
    directionsDisplay.setOptions({ preserveViewport: true });
    directionsDisplay.setDirections(response);
  } else {
    window.alert('Directions request failed due to ' + status);
  }

DirectionsDisplay.setOptions({ preserveViewport: true }) ์ง€๋„๊ฐ€ ํ™•๋Œ€/์ถ•์†Œ ๊ฐ’์„ ์œ ์ง€ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

@davidpestana ์•ˆ๋…•ํ•˜์„ธ์š”,

API์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์Šค๋ ˆ๋“œ์—์„œ ๋ณด์—ฌ์ค€ ๊ฒƒ๊ณผ ๊ฐ™์€ ์ง€์‹œ๋ฌธ์„ ์‚ฌ์šฉํ•˜๊ณ  ์•„์ฃผ ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค!
๋‚ด๊ฐ€ ๊ฐ€์ง„ ์œ ์ผํ•œ ๋ฌธ์ œ๋Š” ๋™์ผํ•œ ์ง€๋„์— ์ƒˆ ๊ฒฝ๋กœ๋ฅผ ํ‘œ์‹œํ•ด์•ผ ํ•  ๋•Œ์ž…๋‹ˆ๋‹ค. ์ƒ์œ„ Component์—์„œ ๋™์ผํ•œ ํ•จ์ˆ˜๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•˜๊ณ  ์ด์ „ ๊ฒฝ๋กœ ์œ„์— ์ƒˆ ๊ฒฝ๋กœ๋ฅผ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๋‚ด๊ฐ€ ๊ฐ€์ง€๊ณ ์žˆ๋Š” ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
`
๋‚ด๋ณด๋‚ด๊ธฐ ํด๋ž˜์Šค DirectionsMapDirective {
@Input() ๋ชฉ์ ์ง€ :๋ฌธ์ž์—ด;
@Input() ์ถœ์ฒ˜:๋ฌธ์ž์—ด;

constructor (private gmapsApi: GoogleMapsAPIWrapper) {

}

ngOnInit(){
    this.setMap();
}

setMap():void{
    this.gmapsApi.getNativeMap().then(map => {
        var directionsService = new google.maps.DirectionsService;
        var directionsDisplay = new google.maps.DirectionsRenderer({draggable: true});
        directionsDisplay.setMap(map);
        directionsService.route({
            origin: this.origin,
            destination: this.destination,
            waypoints: [],
            optimizeWaypoints: true,
            travelMode: 'DRIVING'
        }, function(response, status) {
            if (status === 'OK') {
                directionsDisplay.setDirections(response);
            } else {
                window.alert('Directions request failed due to ' + status);
            }
        });

    });
}

}
`
์ƒˆ ๊ฒฝ๋กœ๋ฅผ ํ‘œ์‹œํ•ด์•ผ ํ•  ๋•Œ ์ƒ์œ„ ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ setMap ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ์ถœ๋ฐœ์ง€ ๋ฐ ๋Œ€์ƒ ๋ณ€์ˆ˜๊ฐ€ ๋ณ€๊ฒฝ๋ฉ๋‹ˆ๋‹ค.
์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ ๋งต์„ ๋‹ค์‹œ ๋กœ๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๊นŒ?

@davidpestana ๋‚˜๋„
@okanok ์ด๊ฑฐ ์•Œ์•„๋ƒˆ์–ด?

์•ˆ๋…•ํ•˜์„ธ์š” @davidpestana ๋ฐ @ahardworker , ์ง€์‹œ๋ฌธ๊ณผ ์ง€์ •๋œ HTML david๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ–ˆ์ง€๋งŒ ๊ณ„์† ์ด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. "InvalidValueError: in property origin: not a string; and not a LatLng or LatLngLiteral: in property lat: not a number; ๋ฐ ์•Œ ์ˆ˜ ์—†๋Š” ์†์„ฑ ์œ„๋„".

Component.ts
์›์  = { ๊ฒฝ๋„: 4.333, ์œ„๋„: -1.2222 }; // ์˜ˆ์‹œ์ ์ธ ์š”ํ–‰ ์œ„์น˜
๋ชฉ์ ์ง€ = { ๊ฒฝ๋„: 22.311, ์œ„๋„: -0.123 }; // ์˜ˆ์‹œ์ ์ธ ์š”ํ–‰ ์œ„์น˜

Component.html

<sebm-google-map-directions [origin]="origin" [destination]="destination"></sebm-google-map-directions>

์˜ค๋ฅ˜: InvalidValueError: ์†์„ฑ ์ถœ์ฒ˜: ๋ฌธ์ž์—ด์ด ์•„๋‹™๋‹ˆ๋‹ค. LatLng ๋˜๋Š” LatLngLiteral์ด ์•„๋‹™๋‹ˆ๋‹ค. ์†์„ฑ์—์„œ lat: ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ๋ฐ ์•Œ ์ˆ˜์—†๋Š” ์†์„ฑ ์œ„๋„

์–ด๋–ค ์•„์ด๋””์–ด๊ฐ€ ์žˆ์Šต๋‹ˆ๊นŒ?

๊ฐ์‚ฌ ํ•ด์š”

@developernm ์œ„๋„๋ฅผ ์ž˜๋ชป ์ž…๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค ;)

@bene-starzengruber๋Š” ์กฐ๊ธˆ ์„œ๋‘๋ฅด๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค lol

๋‚˜๋Š” ํฐ ๊ด€์‹ฌ์„ ๊ฐ€์ง€๊ณ  ์ด ์ฃผ์ œ๋ฅผ ๋”ฐ๋ž์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๊ฒƒ์ด ํ”„๋กœ์ ํŠธ(์ฝ”์–ด)์— ํ†ตํ•ฉ๋˜๊ธฐ๋ฅผ ๊ธฐ๋Œ€ํ•ฉ๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋˜ํ•œ ๊ฒฝ๋กœ ๊ณ„ํš๊ณผ ๊ธธ ์ฐพ๊ธฐ API๊ฐ€ ํ•„์š”ํ•˜๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

@davidpestana @ahardworker ๊ธธ์ฐพ๊ธฐ ์ง€๋„๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์—ฌ๋Ÿฌ ๋ฐฉํ–ฅ์„ ๋ฐ›๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚ด ์ง€๋„ ๊ฒฝ๋กœ๋ฅผ ์ฒจ๋ถ€ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋งค๋ฒˆ ๋‹จ์ผ ๊ฒฝ๋กœ๋ฅผ ์–ป๋Š” ๋ฐฉ๋ฒ•์„ ์ œ์•ˆํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

๋ชฉ์ ์ง€ ๊ฐ’์ด ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค My DirectionsMapDirective ์ง€์‹œ๋ฌธ์„ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

๋ฏธ๋ฆฌ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

screen shot 2017-01-18 at 6 29 22 pm

@okanok @marimuthum17 ,
๋ช‡ ์‹œ๊ฐ„ ๋™์•ˆ ์‹œ๋„ํ•œ ํ›„์— ์ด ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค... ์—ฌ๊ธฐ์—์„œ ์ „์—ญ ๋ฐฉํ–ฅ ํ‘œ์‹œ๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒƒ์ด ํ•„์š”ํ•˜๋‹ค๋Š” ๊ฒƒ์„ ์ฝ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ง€์‹œ๋ฌธ ๋‚ด๋ถ€์— DirectionsDisplay๋ฅผ ์ •์˜ํ•˜๋ฉด ๋งค๋ฒˆ DirectionRenderer์˜ ์ƒˆ ์ธ์Šคํ„ด์Šค๊ฐ€ ์ƒ์„ฑ๋˜๋ฏ€๋กœ ์ด์ „ ๊ฒฝ๋กœ๋ฅผ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๋‚ด ๊ตฌ์„ฑ ์š”์†Œ์— DirectionRenderer๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
if(this.directionsDisplay === undefined){ this.mapsAPILoader.load().then(() => { this.directionsDisplay = new google.maps.DirectionsRenderer; this.showDirective = true; }); }

๊ทธ๋Ÿฐ ๋‹ค์Œ ์ง€์‹œ๋ฌธ์— @Input() directionsDisplay; ์‚ฝ์ž…ํ•˜์‹ญ์‹œ์˜ค.

๋ณ„๊ฑฐ ์•„๋‹Œ๊ฑฐ ๊ฐ™์€๋ฐ.. ํšจ๊ณผ๊ฐ€ ์žˆ๋„ค์š”..

@zuschy ์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค . ๊ทธ๊ฒƒ์€ ๋งค๋ ฅ์ฒ˜๋Ÿผ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค!!. ๋„์™€ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. @Input() DirectionsDisplay: any; // ์ž…๋ ฅ์— ๋Œ€ํ•œ ์œ ํ˜•์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋‹น์‹ ์€ ๋‚ด ํ•˜๋ฃจ๋ฅผ ์ €์žฅํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ์ด๊ฒƒ์„ ํ”„๋กœ์ ํŠธ์— ํ†ตํ•ฉํ•˜๊ธฐ ์œ„ํ•ด ์˜ˆ์ œ๋กœ ์“ธ๋งŒํผ ์นœ์ ˆ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

@zuschy , @marimuthum17
๋‚˜๋Š” ์ด์™€ ๊ฐ™์€ ์ž…๋ ฅ์„ ํ†ตํ•ด ์ง€์‹œ๋ฌธ์— DirectionsDisplay๋ฅผ ๋ณด๋‚ด๋ ค๊ณ  ์‹œ๋„ํ–ˆ์ง€๋งŒ ์ง€์‹œ๋ฌธ์—์„œ DirectionsDisplay๋Š” ํ•ญ์ƒ ์ •์˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

<sebm-google-map-directions *ngIf="marker_count > 1" [directionsDisplay]="directionsDisplay" [waypointCnt]="waypointCnt" [origin]="origin" [destination]="destination" [waypoints]="waypoints"></sebm-google-map-directions>

๊ตฌ์„ฑ ์š”์†Œ์—์„œ ๋‚˜๋Š” ์ด๊ฒƒ์„ํ•ฉ๋‹ˆ๋‹ค

 ngOnInit() {
        this.searchControl = new FormControl();
        this.setCurrentPosition();
        if(this.directionsDisplay === undefined){
            this.gmapsApi.getNativeMap().then(map => {               
                this.directionsDisplay = new google.maps.DirectionsRenderer({
                    draggable: true,
                    map: map,
                });
            });
        }

๊ทธ๋ฆฌ๊ณ  ์ง€์‹œ๋ฌธ์—์„œ

@Input() directionsDisplay;

ngOnChanges(changes: SimpleChanges) {
        console.log('onChange fired');
        console.log('changing', changes);
        this.gmapsApi.getNativeMap().then(map => {
            var directionsService = new google.maps.DirectionsService;
            this.directionsDisplay.addListener('directions_changed', function() {
                computeTotalDistance(this.directionsDisplay.getDirections());
            });

            this.directionsDisplay.setMap(map);
            directionsService.route({
                origin: {lat: this.origin.latitude, lng: this.origin.longitude},
                destination: {lat: this.destination.latitude, lng: this.destination.longitude},
                waypoints: this.waypoints,
                optimizeWaypoints: true,
                travelMode: 'DRIVING'
            }, function(response, status) {
                if (status === 'OK') {
                    //directionsDisplay.setDirections({routes: []});
                    this.directionsDisplay.setDirections(response);
                } else {
                    window.alert('Directions request failed due to ' + status);
                }
            });

Replying to @ssssssssss ใ… ใ…œ
๋‚˜๋„ ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ง€์‹œ๋ฌธ์—์„œ DirectionsDisplay๊ฐ€ ์ •์˜๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

@jjjjjjjjjjjjjjjjr
์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๋‚ด ์ง€์‹œ๋ฌธ์„ ์„ ์–ธํ•œ ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@ViewChild(DirectionsMapDirective) vc: DirectionsMapDirective;
........์•„๋ž˜์™€ ๊ฐ™์ด ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค.
if(this.vc.directionsDisplay === ์ •์˜๋˜์ง€ ์•Š์Œ){ this.mapsAPILoader.load().then(() => {
this.vc.directionsDisplay = ์ƒˆ๋กœ์šด google.maps.DirectionsRenderer;
});

@Bonzysalesman @Giusti @manohar-nyros
google-map-directions-display-in-angular-2

๋‚ด ํ”„๋กœ์ ํŠธ ์ค‘ ํ•˜๋‚˜์— ๋Œ€ํ•ด ๊ฐ๋„ 2์—์„œ Google์ง€๋„ ๊ธธ ์ฐพ๊ธฐ ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.
์—ฌ๊ธฐ์— ์ด๊ฒƒ์— ๋Œ€ํ•œ ๊ธฐ์‚ฌ๊ฐ€ ํ•˜๋‚˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ „์ฒด ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์—ฌ๊ธฐ์— ๋ฐ๋ชจ๊ฐ€ ์ฒจ๋ถ€๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์›ํ•˜๋Š” ๊ฒฝ์šฐ ์Šคํฌ๋ฆฝํŠธ๋„ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์ด ๋‹ค๋ฅธ ์‚ฌ๋žŒ์—๊ฒŒ๋„ ๋„์›€์ด๋˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค.

@marimuthum17
ํ•œ ๋ฒˆ ์‚ดํŽด๋ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋˜ ๋‹ค๋ฅธ ๋ฌธ์ œ๋Š” ng-for์— ์ž๋™ ์™„์„ฑ ํ•„๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ ์˜ˆ์—์„œ + ๋ฒ„ํŠผ์ด ์žˆ๊ณ  ๋‹ค๋ฅธ ๊ฒ€์ƒ‰ ํ•„๋“œ๊ฐ€ ๋‚˜ํƒ€๋‚  ๊ฒƒ์ด๋ผ๊ณ  ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฒ€์ƒ‰ ํ•„๋“œ๋Š” #pickupInput / #pickupoutput์— ๋ฐ”์ธ๋”ฉ๋˜์–ด์•ผ ํ•˜๊ณ  @Viewchild๊ฐ€ ์žˆ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ?

@marimuthum17
๋„์™€ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์€ ๋‚˜๋ฅผ ์œ„ํ•ด ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์‹œ ํ•œ๋ฒˆ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

@marimuthum17 , @zuschy
์ด ์ง€์‹œ๋ฌธ์€ ์ง€๊ธˆ๊นŒ์ง€ ์ž˜ ์ž‘๋™ํ•˜๊ณ  ์žˆ์ง€๋งŒ ๋‹ค๋ฅธ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉ์ž๊ฐ€ ์ƒ์„ฑ๋œ ๊ฒฝ๋กœ์—์„œ ๋งˆ์ปค๋ฅผ ๋“œ๋ž˜๊ทธํ•œ ๋‹ค์Œ ํ•ด๋‹น ๊ฒฝ๋กœ์— ๋งˆ์ปค๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋“œ๋ž˜๊ทธํ•œ ๋งˆ์ปค๊ฐ€ ์‹œ์ž‘์ ์œผ๋กœ ๋‹ค์‹œ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค( this.vc.updateDirections()) ํ˜ธ์ถœํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ง€์‹œ๋ฌธ์—์„œ "directions_changed"๋ฅผ ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

Directive์—์„œ @Output ๋ฅผ ๋งŒ๋“ค๋ ค๊ณ  ํ–ˆ์ง€๋งŒ @Input ๋ฐ @Output ๋กœ origin์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
๋‚˜๋Š” ๋˜ํ•œ directionsDisplay ๊ฐ€ ์ƒ์„ฑ๋œ Component์˜ ngOnInit ์— ๋ฆฌ์Šค๋„ˆ๋ฅผ ๋ฐฐ์น˜ํ•˜๋ ค๊ณ  ์‹œ๋„ํ–ˆ์ง€๋งŒ ์–ด์จŒ๋“  .addListener ์—์„œ ์ •์˜๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์–ด๋–ค ๋งˆ์ปค๊ฐ€ ๋“œ๋ž˜๊ทธ๋˜์—ˆ๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ๋‚ด ์•„์ด๋””์–ด๋Š” Directions_changed ๋ฆฌ์Šค๋„ˆ์—์„œ ์ „ํ™˜ ์ผ€์ด์Šค๋ฅผ ๋งŒ๋“ค๊ณ  requestOrigin ๊ฐ€ ์ถœ๋ฐœ์ง€/๋ชฉ์ ์ง€ ๋˜๋Š” ์›จ์ดํฌ์ธํŠธ ์ค‘ ํ•˜๋‚˜์™€ ์ผ์น˜ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ ๋‚ด ์ฝ”๋“œ

์ง€๋ น

export class DirectionsMapDirective {
    // get variables from map.component
    @Input() origin;
    @Input() destination;
    @Input() waypoints;
    @Input() waypointCnt;
    @Input() directionsDisplay;

    constructor (private gmapsApi: GoogleMapsAPIWrapper) {}

    // updateDirections has 2 optional parameters. gets called in map.component
    updateDirections(directionsDisplay, o?, d?){
        this.gmapsApi.getNativeMap().then(map => {
            var directionsService = new google.maps.DirectionsService;
            directionsDisplay.addListener('directions_changed', function() {
                //this.vc.computeTotalDistance(this.directionsDisplay.getDirections());

                if(directionsDisplay && directionsDisplay.dragResult){
                    let requestOrigin = directionsDisplay.dragResult.request.origin;
                    let requestDestination = directionsDisplay.dragResult.request.destination;
                    console.log(this.origin)
                    if(this.origin && (requestOrigin.lat.toString() == this.origin.latitude && requestOrigin.lng.toString() == this.origin.longitude)){
                        console.log('if?');
                        let temp_lat = requestDestination.lat.toString();
                        let temp_lng = requestDestination.lng.toString();
                        this.origin.latitude = temp_lat;
                        this.origin.longitude = temp_lng;
                        this.vc.updateDirections(directionsDisplay);
                    }
                }
                console.log(directionsDisplay);
            });


            //if origin / destination are undefined use value from optional parameters.
            directionsDisplay.setMap(map);
            if(!this.destination && d) {
                this.destination = d;
            }
            if(!this.origin && o) {
                this.origin = o;
            }

            // give the route the data, travel mode is driving bc users should plan a camping/ roadtrip.
            directionsService.route({
                origin: {lat: this.origin.latitude, lng: this.origin.longitude},
                destination: {lat: this.destination.latitude, lng: this.destination.longitude},
                waypoints: this.waypoints,
                optimizeWaypoints: true,
                travelMode: 'DRIVING'
            }, function(response, status) {
                console.log(status);
                if(status == 'OK'){
                    console.log('new route created')
                    var legs = response.routes[0].legs;
                    for (var i = 0; i < legs.length; i++) {
                        let inputFieldStart = document.getElementById('start') as HTMLInputElement;
                        let inputFieldDestination = document.getElementById('destination') as HTMLInputElement;
                        if(inputFieldStart.value == ''){
                            inputFieldStart.value = legs[i].start_address;
                        }
                        if(inputFieldDestination.value == ''){
                            inputFieldDestination.value = legs[i].end_address;
                        }
                    }
                    if (status === 'OK') {
                        directionsDisplay.setDirections(response);
                    } else {
                        window.alert('Directions request failed due to ' + status);
                    }
                }else{
                    console.log('keine Route mรถglich!')
                }
            });

            //function for displaying the travel distance
            function computeTotalDistance(result) {
                var total = 0;
                var myroute = result.routes[0];
                for (var i = 0; i < myroute.legs.length; i++) {
                    total += myroute.legs[i].distance.value;
                }
                total = total / 1000;
                document.getElementById('trip_length').innerHTML = 'The trip is <span id="trip_length_nr">' +total + '</span>km long.';
            }
        });
    }
}

์š”์†Œ:

์—ฌ๊ธฐ์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ Mapclicked / Autocomplete์—์„œ this.vc.updateDirections(this.directionsDisplay); ๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ์—ฌ๊ธฐ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฆฌ์Šค๋„ˆ๋ฅผ ์‹œ๋„ํ–ˆ์„ ๋•Œ:

ngOnInit() {


        this.searchControl = new FormControl();

        this.setCurrentPosition();

        this.mapsAPILoader.load().then(() => {
            this.geocoder = new google.maps.Geocoder;
            this.directionsDisplay = new google.maps.DirectionsRenderer({draggable: true});
            this.directionsDisplay.addListener('directions_changed', function() {
                //directionsDisplay = undefined?????
                if(this.directionsDisplay && this.directionsDisplay.dragResult){
                    let requestOrigin = this.directionsDisplay.dragResult.request.origin;
                    let requestDestination = this.directionsDisplay.dragResult.request.destination;
                    console.log(this.origin)
                    if(this.origin && (requestOrigin.lat.toString() == this.origin.latitude && requestOrigin.lng.toString() == this.origin.longitude)){
                        console.log('if?');
                        let temp_lat = requestDestination.lat.toString();
                        let temp_lng = requestDestination.lng.toString();
                        this.origin.latitude = temp_lat;
                        this.origin.longitude = temp_lng;
                        this.vc.updateDirections(this.directionsDisplay);
                    }
                }
                console.log(this.directionsDisplay);
            });
            let autocomplete = new google.maps.places.Autocomplete(this.OriginSearchElementRef.nativeElement, {
                types: ["address"]
            });
            let autocomplete2 = new google.maps.places.Autocomplete(this.DestinationSearchElementRef.nativeElement, {
                types: ["address"]
            });
            let autocomplete3 = new google.maps.places.Autocomplete(this.WaypointSearchElementRef.nativeElement, {
                types: ["address"]
            });

            autocomplete.addListener("place_changed", () => {
                this.addAutocomplete(autocomplete, 'origin');
            });
            autocomplete2.addListener("place_changed", () => {
                this.addAutocomplete(autocomplete2, 'destination');
                this.vc.updateDirections(this.directionsDisplay);
            });
            autocomplete3.addListener("place_changed", () => {
                this.addAutocomplete(autocomplete3, 'waypoint');
                this.vc.updateDirections(this.directionsDisplay);
            });

        });

    }

์งˆ๋ฌธ:

ํ˜„์žฌ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋ชฉ๋ก์„ ๊ตฌ๋… ์ค‘์ž…๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ๋งˆ์ปค๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•  ๋•Œ ngFor๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋งˆ์ปค๋ฅผ ๋งŒ๋“ค๊ณ  ์ œ๊ฑฐํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํŠน์ • ๋งˆ์ปค์™€ ๊ธธ์ฐพ๊ธฐ๋ฅผ ์—ฐ๊ฒฐํ•œ ๋‹ค์Œ ์ง€๋„์—์„œ ๋งˆ์ปค๊ฐ€ ์ œ๊ฑฐ๋  ๋•Œ ๊ธธ์ฐพ๊ธฐ๋ฅผ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๊นŒ?

๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ฌ์šฉ์ž๋Š” ์•ฑ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋งํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ปค๋Š” ์œ„์น˜์— ๋Œ€ํ•œ ๋ฐฉํ–ฅ๊ณผ ํ•จ๊ป˜ ์ง€๋„์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋“ค์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค๊ณ  ๋งํ•  ๋•Œ. ์ง€๋„์—์„œ ๋งˆ์ปค์™€ ์—ฐ๊ฒฐ๋œ ๋ฐฉํ–ฅ์„ ์ œ๊ฑฐํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋˜ํ•œ watchPosition์œผ๋กœ ์‚ฌ์šฉ์ž์˜ ์œ„์น˜๋ฅผ โ€‹โ€‹๊ด€์ฐฐํ•ฉ๋‹ˆ๋‹ค. ๋ถ„๋ช…ํžˆ ๋งˆ์ปค ์œ„์น˜์™€ ๋ฐฉํ–ฅ์ด ์—…๋ฐ์ดํŠธ๋˜๊ธฐ๋ฅผ ์›ํ•ฉ๋‹ˆ๋‹ค.

@davidpestana ํ›Œ๋ฅญํ•œ ์ž‘์—…์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค... ๊ธฐ๋ณธ ์ง€์‹œ๋ฌธ์„ ๊ตฌํ˜„ํ–ˆ์ง€๋งŒ "ZERO_RESULTS๋กœ ์ธํ•ด ๊ธธ์ฐพ๊ธฐ ์š”์ฒญ์ด ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค"๋ผ๋Š” ์˜ค๋ฅ˜๊ฐ€ ํ‘œ์‹œ๋˜๋ฉด ์ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ ๊นŒ์š”?

๋‚˜๋Š” ๋˜ํ•œ์ด ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค ์ด๊ฒƒ์„ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค :

https://github.com/SebastianM/angular-google-maps/issues/985

์ฝ”๋“œ์—๋Š” ์•„๋ฌด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
api๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๋™์•ˆ Google ์ง€๋„ ํ‚ค๋ฅผ ์ถ”๊ฐ€ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”. ๋˜๋Š” Google ๋ฌธ์„œ์— ๋”ฐ๋ผ ๋งค์ผ ์ œํ•œ ์š”์ฒญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

@marimuthum17 ๋‹น์‹ ์ด ๋งž์Šต๋‹ˆ๋‹ค ๋‹น์‹ ์˜ ์ฝ”๋“œ์— ์•„๋ฌด ๋ฌธ์ œ๊ฐ€ ์—†์—ˆ์Šต๋‹ˆ๋‹ค ... ์‚ฌ์‹ค ๋‚˜๋Š” placeId์˜ ์ผ๋ถ€๋ฅผ ๋†“์ณค์Šต๋‹ˆ๋‹ค ... ๋‚˜๋Š” placeId๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ œ๊ณตํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์ด ๋ฌธ์ œ์˜€์Šต๋‹ˆ๋‹ค ...

@MartiniHenry1988 google์˜ ๊ธธ์ฐพ๊ธฐ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค....์™„์ „ํ•œ ์˜ˆ๋ฅผ ๋ณด๋ ค๋ฉด @marimuthum17 ์˜ ์ด์ „ ๋Œ“๊ธ€์„ ์ฐธ์กฐํ•˜์„ธ์š”.

๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ์Šต๋‹ˆ๊นŒ? directionsDisplay.setMap(map); ํ–‰์—์„œ ์•„๋ž˜ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

Argument of type 'GoogleMap' is not assignable to parameter of type 'Map'

@kildareflare @amitdahan ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ˆ˜์ • ์‚ฌํ•ญ์„ ์ฐพ์€ ์ ์ด ์žˆ์Šต๋‹ˆ๊นŒ?

์ €๋„ ์ด ๋ฌธ์ œ์— ์ง๋ฉดํ•ด ์žˆ์Šต๋‹ˆ๋‹ค. @chaoranxie ํ•ด๊ฒฐ์ฑ…์„ ์ฐพ์•˜์Šต๋‹ˆ๊นŒ?

์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ์ฃผ์ œ๊ฐ€ ์ด๋ฏธ ์•ฝ๊ฐ„ ์˜ค๋ž˜๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ณ  ์žˆ์ง€๋งŒ ๋ฌธ์ œ๊ฐ€ ์žˆ์œผ๋ฉฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
'sebm-google-map-directions'์˜ ์•Œ๋ ค์ง„ ์†์„ฑ์ด ์•„๋‹ˆ๋ฏ€๋กœ 'origin'์— ๋ฐ”์ธ๋”ฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ ์œ„์—์„œ ํ•ด๊ฒฐ์ฑ…์„ ์ œ์‹œํ–ˆ๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋Š”๋ฐ ๋ˆ„๊ตฐ๊ฐ€ ์˜ˆ๋ฅผ ๋“ค์–ด์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

๋‚ด ํ•˜์ฐฎ์€ ์˜์–ด ์‹ค๋ ฅ์— ์ฃ„์†กํ•˜๋‹ค๋Š” ๋ง์”€์„ ๋“œ๋ฆฌ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค

@Fabian-Thug ์–ด๋–ค ๋ฒ„์ „์˜ Angular๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๊นŒ? ์ €๋Š” 4*์— ์žˆ์œผ๋ฉฐ ์ง€์‹œ๋ฌธ์ด ๋‹ค๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
์ง€์‹œ๋ฌธ์—์„œ ๊ตฌ๋ฌธ์„ ์„ ํƒ๊ธฐ: 'sebm-google-map-directions'์—์„œ ์„ ํƒ๊ธฐ ['sebm-google-map-directions']๋กœ ๋ณ€๊ฒฝํ•œ ๋‹ค์Œ HTML์—์„œ AS ๋Œ€์‹  ์š”์†Œ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ

์ž๋™ ์™„์„ฑ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์œผ๋ฉฐ ๋ฒ„ํŠผ์œผ๋กœ ๋‹ค์‹œ ์ž‘์„ฑํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ( @marimuthum17 ์ฝ”๋“œ ์˜ˆ์ œ ์‚ฌ์šฉ - ๊ทธ์˜ ์‚ฌ์ดํŠธ์—์„œ๋Š” ์ž‘๋™ํ•˜์ง€ ์•Š์ง€๋งŒ ๋ฌธ์ œ๋Š” ์ด๋ฒคํŠธ์— ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

[์—…๋ฐ์ดํŠธ]
์ด๊ฒƒ์„ ๋ณ€๊ฒฝํ•˜์‹ญ์‹œ์˜ค:
์žฅ์†Œ: google.maps.places.PlaceResult = autocomplete.getPlace();
์ด์—:
const ์žฅ์†Œ = autocomplete.getPlace();

@davidpestana @marimuthum17 ์œ„์˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ์‚ฌ์šฉ์ž์˜ ํ˜„์žฌ ์œ„์น˜์™€ ์„ ํƒํ•œ ๋ชฉ์ ์ง€ ์‚ฌ์ด์˜ ๋ฐฉํ–ฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ ๋งˆ์ปค ์•„์ด์ฝ˜์„ ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค! ๊ทธ๋ ‡๊ฒŒํ•˜๋Š” ๋ฐฉ๋ฒ•?
๋ฐฉํ–ฅ ๊ฒฐ๊ณผ์— ์‚ฌ์šฉ์ž ์ง€์ • ๋งˆ์ปค๋ฅผ ํฌํ•จํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

@davidpestana
์ด ์†”๋ฃจ์…˜์— import { CustomMapDirective } from '[๋””๋ ‰ํ‹ฐ๋ธŒ ํด๋”๋กœ์˜ ๊ฒฝ๋กœ]/google-map.directive'; ํ•˜์ง€๋งŒ ์ด๊ฒƒ์„ ์œ„ํ•ด ์ผ๋ถ€ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๊นŒ ??

์˜ค๋ฅ˜ ๋ฐœ์ƒ ์œ ํ˜• ์˜ค๋ฅ˜: ์ •์˜๋˜์ง€ ์•Š์€ '์›๋ณธ' ์†์„ฑ์„ ์„ค์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

@ViewChild(DirectionsMapDirective) vc: DirectionsMapDirective;
๊ณต๊ฐœ ์ถœ์ฒ˜ : ๋ชจ๋“  ;
๊ณต๊ณต ๋ชฉ์ ์ง€ : ๋ชจ๋“ ;
๊ฑด์„ค์ž(
๊ฐœ์ธ ๋ชจ๋‹ฌ ์„œ๋น„์Šค : NgbModal,

private mapsAPILoader: MapsAPILoader,
private ngZone: NgZone,
private gmapsApi: GoogleMapsAPIWrapper,
private _elementRef : ElementRef

) {}

๊ฐ’ ์ „๋‹ฌ
this.vc.origin = { ๊ฒฝ๋„: 77.333, ์œ„๋„: 12.2222 };
this.vc.destination = { ๊ฒฝ๋„: 90.311, ์œ„๋„: 28.123 };
this.vc.updateDirections();

๋ฏธ๋ฆฌ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋‚ด ์ง€๋„์— ๋‘ ์ง€์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์–ด๋–ป๊ฒŒ ๊ทธ ์‚ฌ์ด์˜ ๋ฐฉํ–ฅ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

component.ts

'@angular/core'์—์„œ { ๊ตฌ์„ฑ์š”์†Œ } ๊ฐ€์ ธ์˜ค๊ธฐ;
'@agm/core'์—์„œ { MouseEvent } ๊ฐ€์ ธ์˜ค๊ธฐ;

@์š”์†Œ({
์„ ํƒ๊ธฐ: '์•ฑ ๋ฃจํŠธ',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
๋‚ด๋ณด๋‚ด๊ธฐ ํด๋ž˜์Šค AppComponent {
ํ™•๋Œ€/์ถ•์†Œ: ์ˆซ์ž = 8;

์œ„๋„: ์ˆซ์ž = 51.673858;
lng: ์ˆซ์ž = 7.815982;

๋งˆ์ปค: ๋งˆ์ปค[] = [
{
์œ„๋„: 51.673858,
lng: 7.815982,
๋ ˆ์ด๋ธ”: 'A',
๋“œ๋ž˜๊ทธ ๊ฐ€๋Šฅ: ์ฐธ
},
{
์œ„๋„: 51.373858,
๊ธธ์ด: 7.215982,
๋ ˆ์ด๋ธ”: 'B',
๋“œ๋ž˜๊ทธ ๊ฐ€๋Šฅ: ๊ฑฐ์ง“
}
]

}

์ธํ„ฐํŽ˜์ด์Šค ๋งˆ์ปค {
์œ„๋„: ์ˆซ์ž;
๊ธธ์ด: ์ˆซ์ž;
๋ ˆ์ด๋ธ”?: ๋ฌธ์ž์—ด;
๋“œ๋ž˜๊ทธ ๊ฐ€๋Šฅ: ๋ถ€์šธ;
}

@davidpestana ๊ท€ํ•˜์˜ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
"'sebm-google-map-directions'์˜ ์•Œ๋ ค์ง„ ์†์„ฑ์ด ์•„๋‹ˆ๋ฏ€๋กœ 'origin'์— ๋ฐ”์ธ๋”ฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."

  1. 'sebm-google-map-directions'๊ฐ€ Angular ๊ตฌ์„ฑ ์š”์†Œ์ด๊ณ  'origin' ์ž…๋ ฅ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ด ๋ชจ๋“ˆ์˜ ์ผ๋ถ€์ธ์ง€ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค.
  2. 'sebm-google-map-directions'๊ฐ€ ์›น ๊ตฌ์„ฑ์š”์†Œ์ธ ๊ฒฝ์šฐ ์ด ๊ตฌ์„ฑ์š”์†Œ์˜ '@NgModule.schemas'์— 'CUSTOM_ELEMENTS_SCHEMA'๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด ๋ฉ”์‹œ์ง€๋ฅผ ํ‘œ์‹œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  3. ์†์„ฑ์„ ํ—ˆ์šฉํ•˜๋ ค๋ฉด ์ด ๊ตฌ์„ฑ์š”์†Œ์˜ '@NgModule.schemas'์— 'NO_ERRORS_SCHEMA'๋ฅผ ์ถ”๊ฐ€ํ•˜์‹ญ์‹œ์˜ค. ("

@davidpestana ๊ฒฝ์œ ์ง€๊ฐ€ Places API, LatLng ๋“ฑ์˜ ์‘๋‹ต์œผ๋กœ ์ •์˜๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์€ ์ฃผ๋ชฉํ•  ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

let waypoints = [
    {location: {placeId: place_id}}
];

https://developers.google.com/maps/documentation/javascript/directions#DirectionsRequests

์ด ๋ชจ๋“  ๊ฒƒ์ด ๋‚˜๋ฅผ ์œ„ํ•ด ์ผํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ๋‹ค๋ฅธ ์ง€์‹œ๋ฌธ๊ณผ ๋™์ผํ•œ ํ˜•์‹์ธ ๊ฒฝ์šฐ agm/core์— ์ถ”๊ฐ€ํ•  ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๊นŒ?

์ด์— ๋Œ€ํ•œ ์—…๋ฐ์ดํŠธ๊ฐ€ ์žˆ์Šต๋‹ˆ๊นŒ?

origin ๋ฐ destination ๋ฅผ ๋ฌธ์ž์—ด๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

์ถ”์ • _time & distance_์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์—†๋Š” ์ด์œ ๋Š” ์ด ์ฝ”๋“œ ๋ธ”๋ก์ด ์•„๋ž˜์— ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ํด๋ž˜์Šค์˜ this.xyz ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์ฝ๊ธฐ/์“ฐ๊ธฐ ์•ก์„ธ์Šค ๊ถŒํ•œ์ด ์—†๋Š” ์ต๋ช… ์ฝœ๋ฐฑ ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
}, function(response: any, status: any) {

์•„๋ž˜๋กœ ๋ณ€๊ฒฝ ํ•œ ํ›„ ํ•ด๋‹น ๊ธฐ๋Šฅ ๋‚ด๋ถ€์— ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๊ณ  ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. typescript ํด๋ž˜์Šค์— ๊ณ ์œ ํ•œ es6 ํ™”์‚ดํ‘œ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ์ •๋ณด: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
}, (response: any, status: any) => {

์•ˆ๋…•ํ•˜์‹ญ๋‹ˆ๊นŒ,
๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ๋ฐฉํ–ฅ ๊ฒฝ๋กœ์˜ ๊ฒฝ๋กœ์—์„œ ์ถœ๋ ฅ์œผ๋กœ ํด๋ฆญ ์‹œ์ž‘ ์œ„์น˜์™€ ๊ฐ™์€ ์ด๋ฒคํŠธ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

๊ฐ์‚ฌ ํ•ด์š”

์•ˆ๋…•ํ•˜์„ธ์š” @davidpestana , @marimuthum17 , @okanok

์ฒ˜์Œ์œผ๋กœ ๊ฒฝ๋กœ๋ฅผ ๊ทธ๋ฆด ๋•Œ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ํ‘œ์‹œ๋˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ์ƒˆ๋กœ์šด ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ๊ฒฝ๋กœ๋ฅผ ๊ทธ๋ฆฌ๋ ค๊ณ  ํ•˜๋ฉด ์ฒซ ๋ฒˆ์งธ ๊ฒฝ๋กœ๊ฐ€ ์ง€์›Œ์ง€์ง€ ์•Š๊ณ  ์ƒˆ ๊ฒฝ๋กœ์˜ ๊ฒฝ์šฐ ์„ ์ด ํ‘œ์‹œ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ ๋‚ด ์ฝ”๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ตฌ์„ฑ ์š”์†Œ.ts,

showDirections( ) { if ('geolocation' in navigator) { navigator.geolocation.getCurrentPosition((position) => { this.org = { latitude: position.coords.latitude, longitude: position.coords.longitude}; this.dst = {longitude: this.cycle.longitude, latitude: this.cycle.latitude}; console.log('Src ' + this.org.latitude ); console.log('Dst' + this.dst.latitude ); }); } }

์ด ํ•จ์ˆ˜๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ํ›„ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ๋ฐ ๊ตฌ์„ฑ ์š”์†Œ์˜ html,
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom"> <appCycleDirection *ngIf="dst !== undefined" [org]="org" [dst]="dst"></appCycleDirection> <agm-marker [style.height.px]="map.offsetHeight" [latitude]="lat" [longitude]="lng"></agm-marker> </agm-map>

์ง€์‹œ์–ด ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

````
import { ์ง€์‹œ์–ด, ์ž…๋ ฅ, OnInit } from '@angular/core';
'@agm/core'์—์„œ {GoogleMapsAPIWrapper} ๊ฐ€์ ธ์˜ค๊ธฐ;

let google: any;
@์ง€๋ น({
// tslint:disable-next-line:directive-selector
์„ ํƒ๊ธฐ: 'appCycleDirection'
})
๋‚ด๋ณด๋‚ด๊ธฐ ํด๋ž˜์Šค CycleDirectionDirective ๊ตฌํ˜„ OnInit {

@Input() ์กฐ์ง;
@์ž…๋ ฅ() dst;
@Input() originPlaceId: ๋ชจ๋‘;
@Input() destinationPlaceId: ๋ชจ๋‘;
@Input() ์›จ์ดํฌ์ธํŠธ: ๋ชจ๋‘;
@Input() ๋ฐฉํ–ฅํ‘œ์‹œ: ๋ชจ๋‘;
@Input() ์ถ”์ •์‹œ๊ฐ„: ๋ชจ๋‘;
@Input() ์ถ”์ • ๊ฑฐ๋ฆฌ: ๋ชจ๋‘;
์ƒ์„ฑ์ž(๋น„๊ณต๊ฐœ gmapsApi: GoogleMapsAPIWrapper) { }

ngOnInit() {
console.log(' ์ง€์‹œ๋ฌธ์—์„œ ');
console.log(this.org);
this.gmapsApi.getNativeMap().then(์ง€๋„ => {
const DirectionsService = ์ƒˆ๋กœ์šด google.maps.DirectionsService;
const DirectionsDisplay = ์ƒˆ๋กœ์šด google.maps.DirectionsRenderer;
DirectionsDisplay.setMap(์ง€๋„);
DirectionsService.route({
์ถœ๋ฐœ์ง€: {์œ„๋„: this.org.latitude, lng: this.org.longitude},
๋ชฉ์ ์ง€: {์œ„๋„: this.dst.latitude, lng: this.dst.longitude},
์›จ์ดํฌ์ธํŠธ: [],
optimizeWaypoints: ์ฐธ,
์—ฌํ–‰ ๋ชจ๋“œ: 'TRANSIT'
}, ํ•จ์ˆ˜(์‘๋‹ต, ์ƒํƒœ) {
if (์ƒํƒœ === 'ํ™•์ธ') {
DirectionsDisplay.setDirections(์‘๋‹ต);
console.log(์‘๋‹ต);
} ๋˜ ๋‹ค๋ฅธ {
window.alert('' + ์ƒํƒœ๋กœ ์ธํ•ด ๊ธธ์ฐพ๊ธฐ ์š”์ฒญ ์‹คํŒจ);
}
});

});

}

}

```

๋‚ด ์ฝ”๋“œ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ์ƒˆ ๊ฒฝ๋กœ๊ฐ€ ํ‘œ์‹œ๋  ๋•Œ ์ฒซ ๋ฒˆ์งธ ๊ฒฝ๋กœ๋ฅผ ์‚ฌ๋ผ์ง€๊ฒŒ ๋งŒ๋“ค๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š”, ๋„๋กœ์— ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ์–ด๋„ ๋ ๊นŒ์š”?
๊ฐ์‚ฌ ํ•ด์š”

๋‚˜๋Š” ๋‚ด ํ”„๋กœ์ ํŠธ์—์„œ ๋™์ผํ•œ ์ง€์‹œ๋ฌธ์„ ์‚ฌ์šฉํ–ˆ๊ณ  ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•œ ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค. Waze, Uber ๋˜๋Š” lyft ์šด์ „ ์ง€๋„์™€ ๊ฐ™์€ ๋„๋กœ์—์„œ ๊ตํ†ต๋Ÿ‰(๋นจ๊ฐ„์ƒ‰, ๋…ธ๋ž€์ƒ‰ ๋˜๋Š” ํŒŒ๋ž€์ƒ‰ ๋ถ€๋ถ„)์„ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?
๋‹น์‹ ์˜ ๋„์›€์„ ๋†’์ด ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค

์ด ์‚ฌ๋žŒ์€ ์ด ์ง€์‹œ๋ฌธ์„ ํ›Œ๋ฅญํ•˜๊ฒŒ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ €๋Š” ๊ทธ๊ฒƒ์„ ์‹œ๋„ํ–ˆ๊ณ  ์•„์ฃผ ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. AGM์— ํฌํ•จ๋  ์ˆ˜ ์žˆ๋Š”์ง€ ๊ณ ๋ คํ•˜์‹ญ์‹œ์˜ค.

https://github.com/explooosion/Agm-Direction

routewithagm

์ด ๋ฌธ์ œ๋Š” ์ตœ๊ทผ ํ™œ๋™์ด ์—†์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ž๋™์œผ๋กœ ์˜ค๋ž˜๋œ ๊ฒƒ์œผ๋กœ ํ‘œ์‹œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋” ์ด์ƒ ํ™œ๋™์ด ์—†์œผ๋ฉด ํ์‡„๋ฉ๋‹ˆ๋‹ค. ๊ท€ํ•˜์˜ ๊ธฐ์—ฌ์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰