/**
 * Mapy google
 * 
 * Wymagane mootools
 */


/**
 * Obiekt mapy
 */
var GeocoderMap = new Class({

	Extends: BasicMap,


	/**
	 * Obiekt GClientGeocoder
	 */
	geo:null,
	





	/**
	 * Konstruktor
	 * 
	 * @param string container_id
	 * @param string resource_path
	 */
	initialize: function( container_id, resource_path )
	{
		this.parent( container_id, resource_path );
			
		if ( !GBrowserIsCompatible() ) 
			return false;

	// geocoder
		this.geo = new GClientGeocoder(); 
	},
	
	
	
	/**
	 * Znajduje lokację. 
	 * 
	 * Wyzwala event 'locate' z obiektem GLatLng lub null - jeżeli nie znaleziono
	 */
	locate: function( search_string )
	{
		this.geo.getLocations(
			search_string, 
			function (result)
			{ 
				var point = null;
				
				if (result.Status.code == G_GEO_SUCCESS) {
					var p = result.Placemark[0].Point.coordinates;
					point =  new GLatLng(p[1],p[0]);
				}
				
				this.fireEvent( 'locate', point );
			}.bind( this )
		);
	}
});






