Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid argument - Google map error in Edge browser

I have been getting this error

Invalid argument

from Google map v3 in Edge browser. Everything else is working fine even after getting the error. This strange behavior is occurring only when I try to move the cursor out of the map to the right side (over the browser scroll). It is happening only in Edge.

I have created a JSFiddle which is in the pristine condition as Google mentioned. But am getting the same error in that case also. I have reported this bug to the google map support forum and in the meanwhile trying to find a solution from the largest community I know. Thanks in advance. You can check the code below

function initMap() {
  var uluru = {lat: -25.344, lng: 131.036};
  var map = new google.maps.Map(
      document.getElementById('map'), {zoom: 4, center: uluru});
  var marker = new google.maps.Marker({position: uluru, map: map});
}
like image 302
Abin Thaha Avatar asked Aug 08 '18 10:08

Abin Thaha


1 Answers

I was able to reproduce the issue and here is what I have found:

The problem occurs in the following code in common.js file on the edge:

if ("undefined" != typeof a.compareDocumentPosition)
    return a == b || !!(a.compareDocumentPosition(b) & 16);

specifically compareDocumentPosition function call as it does not like argument b. The actual function block:

function (a, b) {
    if (!a || !b)
        return !1;
    if (a.contains && 1 == b.nodeType)
        return a == b || a.contains(b);
    if ("undefined" != typeof a.compareDocumentPosition)
        return a == b || !!(a.compareDocumentPosition(b) & 16);
    for (; b && a != b;)
        b = b.parentNode;
    return b == a;
};

This block is called whenever mouseout event occurs on map container and argument a is your map container element and b is scrollbar object. When you move mouse out of the map and onto the scrollbar of the browser window all other browsers call the same method with nodeType of scrollbar object being 1 and in turn executing return a == b || a.contains(b); code block.

However, in case of edge nodeType for scrollbar object is undefined and it executes return a == b || !!(a.compareDocumentPosition(b) & 16); codeblock and passes scrollbar object to compareDocumentPosition function call which then logs Invalid argument. on the console.

You can see the bug report that I filed here.

like image 108
Dipen Shah Avatar answered Sep 27 '22 20:09

Dipen Shah