Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: GoogleMapsAPI is not defined for node-googlemaps

I am using node-googlemaps to query the Google Maps API from Node js. I have created my Server API key as a Developer. According to the this documentation, I have to make a publicConfig variable with my API key and certain other parameters. My publicConfig variable is as follows:

 var gm = require('googlemaps');
 var publicConfig = {
  key: 'myKey',
  stagger_time:1000, // for elevationPath
  encode_polylines:false,
  secure:true // use https
};
 var gmAPI = new GoogleMapsAPI(publicConfig);

When I run the Code, I get the following error

 ReferenceError: GoogleMapsAPI is not defined

Can somebody help me on this issue?

like image 526
shubhamagiwal92 Avatar asked Sep 27 '15 12:09

shubhamagiwal92


People also ask

Why is Google Maps API not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.

What does Google is not defined mean?

If this error message appears while trying to access our map page, it means that Google is being blocked, either by the browser or the network.

Why is my API key not working?

API keys have multiple dependencies that can result in errors like: "The user is not authorized for this operation based on …". Please make sure you are using the correct credentials and endpoint with the correct API key.


1 Answers

To Resolve this issue I had include the following line of Code

var GoogleMapsAPI = require('googlemaps');
like image 197
shubhamagiwal92 Avatar answered Sep 26 '22 02:09

shubhamagiwal92