Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Error: Uncaught InvalidValueError: setIcon: not a string; and no url property; and no path property

I just started getting this error today for Google Maps:

Uncaught InvalidValueError: setIcon: not a string; and no url property; and no path property

I haven't changed any code in months.

The error is happening on this page: http://gusmodern.com/pages/store-locator

Has anyone come across this before?

like image 775
Patrick Brown Avatar asked Sep 30 '22 22:09

Patrick Brown


2 Answers

I updated to the specific version reference https://maps.googleapis.com/maps/api/js?v=3&sensor=true and the error went away. I had this across multiple of my geolocation websites and mobile apps.

like image 129
Rob Avatar answered Oct 03 '22 01:10

Rob


I got the same error just recently in some of my code. Thanks to another question in the past, I realized that when I set the markers I needed to make sure the variables I was bringing in for the anchor and scaled size were float numbers and not coming in as strings. This must be a new requirement with a recent update.

In my own code I changed

currentIcon = {
            url: 'http://www.example.com/img/avatars/'+name+'.png',
            origin: new google.maps.Point(0, 0),
            anchor: new google.maps.Point(aw,ah),
            scaledSize: new google.maps.Size(w,h)
        };

to

currentIcon = {
            url: 'http://www.example.com/img/avatars/'+name+'.png',
            origin: new google.maps.Point(0, 0),
            anchor: new google.maps.Point(parseFloat(aw),parseFloat(ah)),
            scaledSize: new google.maps.Size(parseFloat(w),parseFloat(h))
        };

and it now works fine for me.

like image 23
Scott Avatar answered Oct 03 '22 01:10

Scott