Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/i-plan.ru/media/zoo/elements/googlemaps/
Upload File :
Current File : /var/www/iplanru/data/www/i-plan.ru/media/zoo/elements/googlemaps/jquery.geocomplete.js

/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */

(function(t,i,e,o){var s={bounds:true,country:null,map:false,details:false,detailsAttribute:"name",location:false,mapOptions:{zoom:14,scrollwheel:false,mapTypeId:"roadmap"},markerOptions:{draggable:false},maxZoom:16,types:["geocode"]};var n=("street_address route intersection political "+"country administrative_area_level_1 administrative_area_level_2 "+"administrative_area_level_3 colloquial_area locality sublocality "+"neighborhood premise subpremise postal_code natural_feature airport "+"park point_of_interest post_box street_number floor room "+"lat lng viewport location "+"formatted_address location_type bounds").split(" ");var a=("id url website vicinity reference name rating "+"international_phone_number icon formatted_phone_number").split(" ");function r(i,e){this.options=t.extend(true,{},s,e);this.input=i;this.$input=t(i);this._defaults=s;this._name="geocomplete";this.init()}t.extend(r.prototype,{init:function(){this.initMap();this.initMarker();this.initGeocoder();this.initDetails();this.initLocation()},initMap:function(){if(!this.options.map){return}if(typeof this.options.map.setCenter=="function"){this.map=this.options.map;return}this.map=new google.maps.Map(t(this.options.map)[0],this.options.mapOptions)},initMarker:function(){if(!this.map){return}var i=t.extend(this.options.markerOptions,{map:this.map});if(i.disabled){return}this.marker=new google.maps.Marker(i);google.maps.event.addListener(this.marker,"dragend",t.proxy(this.markerDragged,this))},initGeocoder:function(){var i={types:this.options.types,bounds:this.options.bounds===true?null:this.options.bounds,componentRestrictions:this.options.componentRestrictions};if(this.options.country){i.componentRestrictions={country:this.options.country}}this.autocomplete=new google.maps.places.Autocomplete(this.input,i);this.geocoder=new google.maps.Geocoder;if(this.map&&this.options.bounds===true){this.autocomplete.bindTo("bounds",this.map)}google.maps.event.addListener(this.autocomplete,"place_changed",t.proxy(this.placeChanged,this));this.$input.keypress(function(t){if(t.keyCode===13){return false}});this.$input.bind("geocode",t.proxy(function(){this.find()},this))},initDetails:function(){if(!this.options.details){return}var i=t(this.options.details),e=this.options.detailsAttribute,o={};function s(t){o[t]=i.find("["+e+"="+t+"]")}t.each(n,function(t,i){s(i);s(i+"_short")});t.each(a,function(t,i){s(i)});this.$details=i;this.details=o},initLocation:function(){var t=this.options.location,i;if(!t){return}if(typeof t=="string"){this.find(t);return}if(t instanceof Array){i=new google.maps.LatLng(t[0],t[1])}if(t instanceof google.maps.LatLng){i=t}if(i){if(this.map){this.map.setCenter(i)}}},find:function(t){this.geocode({address:t||this.$input.val()})},geocode:function(i){if(this.options.bounds&&!i.bounds){if(this.options.bounds===true){i.bounds=this.map&&this.map.getBounds()}else{i.bounds=this.options.bounds}}if(this.options.country){i.region=this.options.country}this.geocoder.geocode(i,t.proxy(this.handleGeocode,this))},handleGeocode:function(t,i){if(i===google.maps.GeocoderStatus.OK){var e=t[0];this.$input.val(e.formatted_address);this.update(e);if(t.length>1){this.trigger("geocode:multiple",t)}}else{this.trigger("geocode:error",i)}},trigger:function(t,i){this.$input.trigger(t,[i])},center:function(t){if(t.viewport){this.map.fitBounds(t.viewport);if(this.map.getZoom()>this.options.maxZoom){this.map.setZoom(this.options.maxZoom)}}else{this.map.setZoom(this.options.maxZoom);this.map.setCenter(t.location)}if(this.marker){this.marker.setPosition(t.location);this.marker.setAnimation(this.options.markerOptions.animation)}},update:function(t){if(this.map){this.center(t.geometry)}if(this.$details){this.fillDetails(t)}this.trigger("geocode:result",t)},fillDetails:function(i){var e={},o=i.geometry,s=o.viewport,n=o.bounds;t.each(i.address_components,function(t,i){var o=i.types[0];e[o]=i.long_name;e[o+"_short"]=i.short_name});t.each(a,function(t,o){e[o]=i[o]});t.extend(e,{formatted_address:i.formatted_address,location_type:o.location_type||"PLACES",viewport:s,bounds:n,location:o.location,lat:o.location.lat(),lng:o.location.lng()});t.each(this.details,t.proxy(function(t,i){var o=e[t];this.setDetail(i,o)},this));this.data=e},setDetail:function(t,i){if(i===o){i=""}else if(typeof i.toUrlValue=="function"){i=i.toUrlValue()}if(t.is(":input")){t.val(i)}else{t.text(i)}},markerDragged:function(t){this.trigger("geocode:dragged",t.latLng)},resetMarker:function(){this.marker.setPosition(this.data.location);this.setDetail(this.details.lat,this.data.location.lat());this.setDetail(this.details.lng,this.data.location.lng())},placeChanged:function(){var t=this.autocomplete.getPlace();if(!t.geometry){this.find(t.name)}else{this.update(t)}}});t.fn.geocomplete=function(i){var e="plugin_geocomplete";if(typeof i=="string"){var o=t(this).data(e)||t(this).geocomplete().data(e),s=o[i];if(typeof s=="function"){s.apply(o,Array.prototype.slice.call(arguments,1));return t(this)}else{if(arguments.length==2){s=arguments[1]}return s}}else{return this.each(function(){var o=t.data(this,e);if(!o){o=new r(this,i);t.data(this,e,o)}})}}})(jQuery,window,document);