mxn.register('googlev3', {

MapstractionGeocoder: {

	init: function(api) {
		if(google.maps.Geocoder) {
			this.geocoders[api] = new google.maps.Geocoder();
		}
	},

	geocode: function(address, callback, error_callback) {
		var geocoder = this.geocoders[this.api];
		var me = this;
		// TODO: build address string for request
		geocoder.geocode({
				'address': address
			}, function(response) {
				me.geocodeCallback(response, callback, error_callback);
			});
	},

	reverseGeocode: function(point, callback, error_callback) {
		var geocoder = this.geocoders[this.api];

		// TODO: Add provider code
	},

	geocodeCallback: function(response, callback, error_callback){
		if (!response || response.length < 1) {
			if(error_callback) {
				error_callback(response);
			}
			return;
		}

		if(callback) {
			var locations = [];
			for(i = 0; i < response.length; i++) {
				var result = response[i];
				var location = new mxn.Location();
				location.address = result.formatted_address;
				location.point = new mxn.LatLonPoint(result.geometry.location.lat(), result.geometry.location.lng());
				locations.push(location);
			}
			callback(locations);
		}
	}
}
});
