Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the API response directly as soon as it runs successfully #41

Closed
er-shrey opened this issue Aug 24, 2018 · 3 comments
Closed

Get the API response directly as soon as it runs successfully #41

er-shrey opened this issue Aug 24, 2018 · 3 comments
Labels
enhancement Indicates new feature requests

Comments

@er-shrey
Copy link

Sometimes the API will result as:

geocoded_waypoints:[{}, {}]
0:{}
1:{}
routes:[]
status:"ZERO_RESULTS"

i.e. directions not found, at this time (onChange) event will not get fired. Is there any workaround.

(let the user gave wrong destination location, say in the mid of ocean)

@er-shrey
Copy link
Author

@output() onSuccess: EventEmitter = new EventEmitter();

private directionDraw() {
this.gmapsApi.getNativeMap().then((map: GoogleMap) => {
this.onSuccess.emit(this.directionsDisplay.getDirections());
if (typeof this.directionsDisplay === 'undefined') {
this.directionsDisplay = new google.maps.DirectionsRenderer(this.renderOptions);
this.directionsDisplay.setMap(map);
this.directionsDisplay.addListener('directions_changed', () => {
// #18 - listener for dragable routes
this.onChange.emit(this.directionsDisplay.getDirections());
});
}

I think this update will work

@explooosion explooosion added the enhancement Indicates new feature requests label Aug 24, 2018
explooosion added a commit that referenced this issue Aug 29, 2018
@explooosion explooosion reopened this Aug 29, 2018
@explooosion
Copy link
Owner

Hi! @er-shrey .

Please install the latest version(0.7.2).

HTML

  <agm-direction
	...
    (onResponse)="onResponse($event)"
  >
  </agm-direction>

TypeScript

  public onResponse(event: any) {
    console.log('onResponse', event);
  }

@er-shrey
Copy link
Author

Thanks buddy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants