fusion error - searchStr.test is not a function

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

fusion error - searchStr.test is not a function

sebafr

Today, all off ours mapguide servers (5 different places, 2 different
versions) happened this error:

fusionSF.js:132996 Uncaught TypeError: searchStr.test is not a function

Looking at fusionSF,js i found this code:

...
Array.prototype.find = function(searchStr) {
  var returnArray = null;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      if (searchStr.test(this[i])) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
};


Somebody knows whats happens ?

I comment the lines below and everything works again, apparently well, but I
wanted to know why?

...
Array.prototype.find = function(searchStr) {
  var returnArray = null;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      //if (searchStr.test(this[i])) {
      //  if (!returnArray) { returnArray = [] }
      //  returnArray.push(i);
      //}
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
};

thanks in advance
sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

GordonL
I am pretty sure the problem is with the Google Maps API.

Remove all the Google layers and I think this solves the error.  

I am looking into how to choose the older Google Map API Version so that we
can continue using Google Maps in mapguide.




--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

GordonL
In reply to this post by sebafr
Here's how I fixed my Google layers:

In Maestro, open your Flexible Web Layout (ApplicationDefinition)
Click Edit as XML
Scroll to the bottom
Replace the line:
<GoogleScript>http://maps.google.com/maps/api/js?sensor=false</GoogleScript>

with the following:

<GoogleScript>http://maps.google.com/maps/api/js?v=3.3&amp;sensor=true&amp;client=</GoogleScript>
   



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

BMason
I get an error in the XML document (1272.25)  when I replace that line
Gordan.  



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

sebafr
In reply to this post by GordonL
Many thanks for your response GordonL!

It worked, and now everything makes sense: google was the problem !!!

I change as you said, and the version (v parameter) was the solution.

The google api recommends putting only the main version and letting them
choose the last released minor version for us, there I put only: v=3 and
everything worked perfect.

Thanks again for your time.
Sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

Jackie Ng
Though your problem appears to be resolved, I'm personally curious as to what
searchStr is if it is passes the typeof(searchStr) == 'function' test.

If it's trying to call .test() on it, then one would think searchStr being
passed in is a regex (RegExp) as that's the only thing I know of that you
can call .test() against, but a regex would not pass the typeof(searchStr)
== 'function' test, so what is being passed in here?

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

sebafr
That's a good discussion, Jackie!
I think 'test' is a method of the searchstr object that derives from
Array.prototype.find.
Testing, after Gordon's tips, on handling the versions in google api, I
noticed that the latest version is assumed whenever no version is reported
in the google api call. The last version in development is 3.32.8 and this
searchstr.temp function does not exist in this context and for some reason,
in the load of the google map, this routine that runs the searchStr.temp is
executed and therefore gives the commented error. When we use any other
version before that, in the map load, it simply does not pass through these
lines in fusionSF.js, that is, it does not give an error, but it does not
mean that it exists, but that simply in the previous versions of google api
this routine is not called. Now why is running this now, only the google
team could respond.
Best Regards
Sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

Jackie Ng
In reply to this post by sebafr
I'll make a patch release of Fusion shortly to include this fix.

Though my fix will be to test for both searchStr and searchStr.test before
calling it, instead of removing that whole if block, on the extreme
off-chance that something should still be hitting down this code path.

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: fusion error - searchStr.test is not a function

NMaj
In reply to this post by BMason
I had the same problem with MapGuideMaestro 6.0m5 XML editor, so
MapGuideMaestro 6.0m8 fixed the problem.



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users