Google Maps toDataURL does not seem to work


#1

I am trying to use toDataURL() to take a snapshot of the map. I used this very basic code to test if it works.

console.log("Calling toDataURL()");
this.map.toDataURL()
.then(
  data => {
    console.log("Success: " + data);
  }
)
.catch(
  exc =>
  {
    console.log("Error");
  }
)

I waited until the map was fully loaded and manually invoked the code. But it did not seem to work. The output was

Calling toDataURL()

and that was all. What have I done wrong?