Creating Collections from Google Places Api


#1

Hi, I´m wondering what´s the best way to create a collection from a returned search in google places api

right now my approach is using a service(google.maps.places.PlacesService) and on the callback function I´m trying to create a place to add to my collection.

code:

function performSearch() {
   for (var i = 0; i < 4; i++) {
      urlLugar = arrayPlaces[i];
      var request = {
		bounds: map.getBounds(),
		keyword: urlLugar
    };
	service.radarSearch(request, callback);
};
function callback(results, status) {
		  if (status !== google.maps.places.PlacesServiceStatus.OK) {
		    console.error(status);
		    return;
		  }
	          for (var i = 0, result; result = results[i]; i++) {
	               addMarker(result);
		       var comment = [];
		       var placeCreated = {
			    id: result.id,
			    comments: comment,
			    rating: 0,
			    location: result.geometry.location
		       }
		      Meteor.call('place.create', placeCreated, function(err){
			     if(err){
				    Materialize.toast("Error", 4000);
			     }else {
				     Materialize.toast("Success", 4000);
			     }
		       });	    
	        }  
 }

When I try this I get the following error:

Exception while simulating the effect of invoking ‘place.create’ TypeError: Meteor.error is not a constructor(…)

Also this is the method I use to create places

   'place.create'(place){
          Places.insert(place, function(err){
                       if(err){
                            throw new Meteor.error();
                       }
                })
          }
    });

I would like to know if this is the best approach and if it isn´t what could be?

Thanks and regards