Giter Club home page Giter Club logo

ionic-googlemaps-quickdemo-v5's People

Contributors

wf9a5m75 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ionic-googlemaps-quickdemo-v5's Issues

Struggling with Directions

Hi,
I'm fairly new to native google maps (I've used Maps JavascriptAPI successfuly in the past). I followed the quickdemo-v5 example and managed to get "current device location" and "geocoder" to work but I'm unable to get directions to work as it gives me an error as below when I call the requestDirection() method. Can anyone please help me solve this problem.

ERROR Error: Uncaught (in promise): TypeError: Cannot redefine property: waypoints
TypeError: Cannot redefine property: waypoints
at Function.defineProperty ()
at new DirectionsRenderer (DirectionsRenderer.js:55)
at Map.addDirectionsRenderer (Map.js:1156)
at index.js:1762
at GoogleMap.push../node_modules/@ionic-native/google-maps/index.js.GoogleMap.addDirectionsRendererSync (index.js:1774)
at home.page.ts:208
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Object.onInvoke (core.js:41667)
at ZoneDelegate.invoke (zone-evergreen.js:363)
at Zone.run (zone-evergreen.js:123)
at resolvePromise (zone-evergreen.js:798)
at zone-evergreen.js:864
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41645)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at drainMicroTaskQueue (zone-evergreen.js:569)

I copied and used the code from the quickdemo-v5 example.. snippet below:

requestDirection() {
DirectionsService.route({
origin: this.origin,
destination: this.destination,
travelMode: TravelModeId.DRIVING
}).then((result: DirectionsResult) => {
console.log(JSON.stringify(result, null, 2));
this.bounds = result.routes[0].bounds;

  console.log(this.bounds);

  if (!this.renderer) {
    this.renderer = this.map.addDirectionsRendererSync({
      directions: result,
      panel: 'guide',
      draggable: true
    });
    console.log(this.renderer);
    this.renderer.on(GoogleMapsEvent.DIRECTIONS_CHANGED).subscribe(this.onDirectionChanged.bind(this));
    console.log(this.renderer.on(GoogleMapsEvent.DIRECTIONS_CHANGED).subscribe(this.onDirectionChanged.bind(this)));
  } else {
    this.renderer.setDirections(result);
    console.log(this.renderer.setDirections(result));
  }
});

}

onDirectionChanged() {
const directions: DirectionsResult = this.renderer.getDirections();
this.origin = directions.routes[0].legs[0].start_location;
this.destination = directions.routes[0].legs[0].end_location;
this.bounds = directions.routes[0].bounds;
}

onSplitterDragEnd() {
this.map.animateCamera({
target: this.bounds,
duration: 500
});

}

// Update server with user position
updateDBPosition() {
this.uID = this.authService.userData.uid;
this.updateValues = {
currentPosition: this.userPosition,
// status: 'online',
};
this.userPositionService.update_userPosition(this.uID, this.updateValues);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.