Home » Javascript » Is not a function error in googlemaps api javascript

Is not a function error in googlemaps api javascript

Posted by: admin August 19, 2018 Leave a comment


I am using google api to show the vehicle current position in one of my function i have a code like this

 function fromLatLngToDivPixel(map, latLng) {
    var overlay = new google.maps.OverlayView();
    overlay.draw = function () { };
    var point = overlay.getProjection().fromLatLngToDivPixel(latLng);
    overlay = null
    return point;

but while executing this code i am getting the error on this overlay.setMap(null);

and i am not able to execute this.
the error says

Uncaught TypeError: this.pa.remove is not a function

yes i know it is very dificult to answer questions like this, but if only anyone have the idea about this error?

i am attaching the image for better reference.enter image description here

and when i commented this line my code is running properly,

can i use the function without this -> overlay.setMap(null);