问题
I'm getting the error Uncaught TypeError: Cannot read property '__e3_' of null randomly when dragging a polygon inside a google map. I mean, most of the times when I drag the polygon works as expected, but rarely a few times fails.
In the Google Chrome console, the error shown is:
1) Error header:
Uncaught TypeError: Cannot read property '__e3_' of null js?libraries=drawing,geometry:87
2) Error body:
_.I.hasListeners @ js?libraries=drawing,geometry:87
_.I.trigger @ js?libraries=drawing,geometry:88
W1 @ poly.js:20
_.t.mm @ poly.js:82
_.I.trigger @ js?libraries=drawing,geometry:88
(anonymous function) @ js?libraries=drawing,geometry:34
_.I.trigger @ js?libraries=drawing,geometry:88
(anonymous function) @ common.js:79
_.I.trigger @ js?libraries=drawing,geometry:88
Mm @ common.js:69
(anonymous function) @ common.js:225
(anonymous function) @ common.js:225
Edited: Instead of pasting the chunks of code, I provide a fiddle as an example with the code working: https://jsfiddle.net/w6Lnk47u/16/
The error seems to be in this line:
var isMarkerContained = google.maps.geometry.poly.containsLocation(CREAR_CAMP.markerWithLabelCasaClub.getPosition(), CREAR_CAMP.polygonArea);
To reproduce the error, someone has to:
1) Click on the left-enabled one first and draw a polygon on the map.
2) Click to the right now enabled button (when the draw of the polygon finishes it enables) and it will appear a marker inside the polygon. Now is when the error could come. Someone just have to try moving and resizing the polygon (trying to leave the marker out of the polygon area) and it will appear the error in the Google Chrome console. As I said, it happens randomly and few times.
回答1:
Update 2019: I was unable to reproduce the problem again, the error must had been fixed from Google.
It's seem to be a bug with Google.
Here is a fiddle with the minimum code that Google suggests for drawing: https://jsfiddle.net/TomKarachristos/hc7nwwdx/. I only change the options.
if you play enough you will see that the same error is triggered, so is not a problem in your code.
if you want not appear this error you must use the window.onerror:
window.onerror = function(msg, url, lineNo, columnNo, error) {
#maybe some condition code
return true; //suppress error
}
but I don't recommend it.
来源:https://stackoverflow.com/questions/35116937/uncaught-typeerror-cannot-read-property-e3-of-null