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

I just started getting this error today for Google Maps:

Uncaught InvalidValueError: setIcon: not a string; and there is no url property; and no property of the path

I have not changed the code for several months.

Error on this page: http://gusmodern.com/pages/store-locator

Has anyone come across this before?

+5
source share
4 answers

I updated the link to a specific version of https://maps.googleapis.com/maps/api/js?v=3&sensor=true and the error went away. I had it on several of my geolocation sites and mobile applications.

+3
source

I got the same error just recently in some of my codes. In connection with another question in the past, I realized that when I set markers, I need to make sure that the variables that I entered for the binding and scaled size were floating point numbers and not included in the lines. This should 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 now it works great for me.

+1
source

From two days I also experienced this problem. In my case, I set MarkerImage on a map with a null argument. This means that I hide markers on the map.

This worked until:

 markers = new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: new google.maps.MarkerImage(null) }); 

Now this seems like a solution:

 markers = new google.maps.Marker({ map: map, position: results[0].geometry.location }); markers.setVisible(false); 

Hope this helps. Good luck

0
source

I had the same problem with the icon as the MarkerWithLabel {} property.

Decision:

 var nullIcon = { url: '', size: new google.maps.Size(0, 0), origin: new google.maps.Point(0, 0), anchor: new google.maps.Point(0, 0) }; 
0
source

Source: https://habr.com/ru/post/1202177/


All Articles