Exception in template helper: TypeError: b.get is not a function

maybe someone can see whats wrong here?
I have this helper, but i get that error:
“Exception in template helper: TypeError: b.get is not a function”
inPolygon: function(RefId){
console.log(RefId); //ok
var cursor = Polygons.find({RefId:RefId});
cursor.forEach( function(zonePolygon) {
console.log(zonePolygon.zoneString); // ok
var decodedPath = google.maps.geometry.encoding.decodePath(zonePolygon.zoneString);
console.log(decodedPath); //ok
var curPosition = new google.maps.LatLng(32.0680324, 34.8027191);
return google.maps.geometry.poly.containsLocation(curPosition, decodedPath) ? true : false;


Your code snippet doesn’t show anything that lines up with the exception (no b variable, no get function call), which means it’s happening elsewhere. Can you paste in the full exception stack trace?

Thanks. This one is in google map apis:
that’s where the error points to:


Okay - so b is the second parameter of the containsLocation function. Whatever your passing into the containsLocation function for decodedPath doesn’t have an available get function. Double check the value of decodedPath and make sure it’s the proper object containsLocation is expecting.

1 Like

Great I’ll check that.
May I also ask, assuming I wanted the loop to stop after returning true, what would I do?

forEach wasn’t designed to be broken out of. If you want to loop over the items in the cursor, and break when something happens, maybe consider first getting the cursor docs as an array (using cursor.fetch()), then loop over them using a standard for loop (breaking when you want to).

1 Like