mxn.register("googlev3",{Geocoder:{init:function(){this.geocoders[this.api]=new google.maps.Geocoder},geocode:function(a){var b=this;if(a.hasOwnProperty("lat")&&a.hasOwnProperty("lon"))a.latlon=a.lat+","+a.lon,this.geocoders[this.api].geocode({address:a.latlon},function(a,c){b.geocode_callback(a,c)});else{if(!a.hasOwnProperty("address")||a.address===null||a.address==="")a.address=[a.street,a.locality,a.region,a.country].join(", ");this.geocoders[this.api].geocode({address:a.address},function(a,c){b.geocode_callback(a,c)})}},geocode_callback:function(a,b){var c=[];if(b!=google.maps.GeocoderStatus.OK)this.error_callback(b);else{for(var d=0;d<a.length;d++){var e={};e.street="",e.locality="",e.postcode="",e.region="",e.country="",e.formatted_address="";var f=a[d],g=[];for(var h=0;h<f.address_components.length;h++){var i=f.address_components[h];for(var j=0;j<i.types.length;j++){var k=i.types[j];switch(k){case"country":e.country=i.long_name;break;case"administrative_area_level_1":e.region=i.long_name;break;case"locality":e.locality=i.long_name;break;case"street_address":e.street=i.long_name;break;case"postal_code":e.postcode=i.long_name;break;case"street_number":g.unshift(i.long_name);break;case"route":g.push(i.long_name)}}}e.street===""&&g.length>0&&(e.street=g.join(" ")),e.formatted_address=f.formatted_address,e.point=new mxn.LatLonPoint(f.geometry.location.lat(),f.geometry.location.lng()),c.push(e)}this.callback(c)}}}});
