Вход Регистрация
Файл: templates/backend/default/assets/plugins/jquery-gmap/gmaps.min.js
Строк: 1612
<?php
if("object"!=typeof window.google||!window.google.maps)throw"Google Maps API is required. Please register the following JavaScript library http://maps.google.com/maps/api/js?sensor=true.";var extend_object=function(e,t){var n;if(e===t)return e;for(n in t)e[n]=t[n];return e},replace_object=function(e,t){var n;if(e===t)return e;for(n in t)void 0!=e[n]&&(e[n]=t[n]);return e},array_map=function(e,t){var n,i=Array.prototype.slice.call(arguments,2),o=[],a=e.length;if(Array.prototype.map&&e.map===Array.prototype.map)o=Array.prototype.map.call(e,function(e){return callback_params=i,callback_params.splice(0,0,e),t.apply(this,callback_params)});else for(n=0;a>n;n++)callback_params=i,callback_params.splice(0,0,e[n]),o.push(t.apply(this,callback_params));return o},array_flat=function(e){var t,n=[];for(t=0;t<e.length;t++)n=n.concat(e[t]);return n},coordsToLatLngs=function(e,t){var n=e[0],i=e[1];return t&&(n=e[1],i=e[0]),new google.maps.LatLng(n,i)},arrayToLatLng=function(e,t){var n;for(n=0;n<e.length;n++)e[n]=e[n].length>0&&"number"!=typeof e[n][0]?arrayToLatLng(e[n],t):coordsToLatLngs(e[n],t);return e},getElementById=function(e,t){var n,e=e.replace("#","");return n="jQuery"in this&&t?$("#"+e,t)[0]:document.getElementById(e)},findAbsolutePosition=function(e){var t=0,n=0;if(e.offsetParent)do t+=e.offsetLeft,n+=e.offsetTop;while(e=e.offsetParent);return[t,n]},GMaps=function(){"use strict";var e=document,t=function(t){t.zoom=t.zoom||15,t.mapType=t.mapType||"roadmap";var n,i=this,o=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","idle","maptypeid_changed","projection_changed","resize","tilesloaded","zoom_changed"],a=["mousemove","mouseout","mouseover"],r=["el","lat","lng","mapType","width","height","markerClusterer","enableNewStyle"],s=t.el||t.div,l=t.markerClusterer,c=google.maps.MapTypeId[t.mapType.toUpperCase()],u=new google.maps.LatLng(t.lat,t.lng),d=t.zoomControl||!0,h=t.zoomControlOpt||{style:"DEFAULT",position:"TOP_LEFT"},f=h.style||"DEFAULT",p=h.position||"TOP_LEFT",m=t.panControl||!0,g=t.mapTypeControl||!0,v=t.scaleControl||!0,b=t.streetViewControl||!0,T=T||!0,C={},y={zoom:this.zoom,center:u,mapTypeId:c},E={panControl:m,zoomControl:d,zoomControlOptions:{style:google.maps.ZoomControlStyle[f],position:google.maps.ControlPosition[p]},mapTypeControl:g,scaleControl:v,streetViewControl:b,overviewMapControl:T};if(this.el="string"==typeof t.el||"string"==typeof t.div?getElementById(s,t.context):s,"undefined"==typeof this.el||null===this.el)throw"No element defined.";for(window.context_menu=window.context_menu||{},window.context_menu[i.el.id]={},this.controls=[],this.overlays=[],this.layers=[],this.singleLayers={},this.markers=[],this.polylines=[],this.routes=[],this.polygons=[],this.infoWindow=null,this.overlay_el=null,this.zoom=t.zoom,this.registered_events={},this.el.style.width=t.width||this.el.scrollWidth||this.el.offsetWidth,this.el.style.height=t.height||this.el.scrollHeight||this.el.offsetHeight,google.maps.visualRefresh=t.enableNewStyle,n=0;n<r.length;n++)delete t[r[n]];for(1!=t.disableDefaultUI&&(y=extend_object(y,E)),C=extend_object(y,t),n=0;n<o.length;n++)delete C[o[n]];for(n=0;n<a.length;n++)delete C[a[n]];this.map=new google.maps.Map(this.el,C),l&&(this.markerClusterer=l.apply(this,[this.map]));var D=function(e,t){var n="",o=window.context_menu[i.el.id][e];for(var a in o)if(o.hasOwnProperty(a)){var r=o[a];n+='<li><a id="'+e+"_"+a+'" href="#">'+r.title+"</a></li>"}if(getElementById("gmaps_context_menu")){var s=getElementById("gmaps_context_menu");s.innerHTML=n;var l=s.getElementsByTagName("a"),c=l.length;for(a=0;c>a;a++){var u=l[a],d=function(n){n.preventDefault(),o[this.id.replace(e+"_","")].action.apply(i,[t]),i.hideContextMenu()};google.maps.event.clearListeners(u,"click"),google.maps.event.addDomListenerOnce(u,"click",d,!1)}var h=findAbsolutePosition.apply(this,[i.el]),f=h[0]+t.pixel.x-15,p=h[1]+t.pixel.y-15;s.style.left=f+"px",s.style.top=p+"px",s.style.display="block"}};this.buildContextMenu=function(e,t){if("marker"===e){t.pixel={};var n=new google.maps.OverlayView;n.setMap(i.map),n.draw=function(){var i=n.getProjection(),o=t.marker.getPosition();t.pixel=i.fromLatLngToContainerPixel(o),D(e,t)}}else D(e,t)},this.setContextMenu=function(t){window.context_menu[i.el.id][t.control]={};var n,o=e.createElement("ul");for(n in t.options)if(t.options.hasOwnProperty(n)){var a=t.options[n];window.context_menu[i.el.id][t.control][a.name]={title:a.title,action:a.action}}o.id="gmaps_context_menu",o.style.display="none",o.style.position="absolute",o.style.minWidth="100px",o.style.background="white",o.style.listStyle="none",o.style.padding="8px",o.style.boxShadow="2px 2px 6px #ccc",e.body.appendChild(o);var r=getElementById("gmaps_context_menu");google.maps.event.addDomListener(r,"mouseout",function(e){e.relatedTarget&&this.contains(e.relatedTarget)||window.setTimeout(function(){r.style.display="none"},400)},!1)},this.hideContextMenu=function(){var e=getElementById("gmaps_context_menu");e&&(e.style.display="none")};for(var _=function(e,n){google.maps.event.addListener(e,n,function(e){void 0==e&&(e=this),t[n].apply(this,[e]),i.hideContextMenu()})},I=0;I<o.length;I++){var S=o[I];S in t&&_(this.map,S)}for(var I=0;I<a.length;I++){var S=a[I];S in t&&_(this.map,S)}google.maps.event.addListener(this.map,"rightclick",function(e){t.rightclick&&t.rightclick.apply(this,[e]),void 0!=window.context_menu[i.el.id].map&&i.buildContextMenu("map",e)}),this.refresh=function(){google.maps.event.trigger(this.map,"resize")},this.fitZoom=function(){var e,t=[],n=this.markers.length;for(e=0;n>e;e++)t.push(this.markers[e].getPosition());this.fitLatLngBounds(t)},this.fitLatLngBounds=function(e){for(var t=e.length,n=new google.maps.LatLngBounds,i=0;t>i;i++)n.extend(e[i]);this.map.fitBounds(n)},this.setCenter=function(e,t,n){this.map.panTo(new google.maps.LatLng(e,t)),n&&n()},this.getElement=function(){return this.el},this.zoomIn=function(e){e=e||1,this.zoom=this.map.getZoom()+e,this.map.setZoom(this.zoom)},this.zoomOut=function(e){e=e||1,this.zoom=this.map.getZoom()-e,this.map.setZoom(this.zoom)};var w,O=[];for(w in this.map)"function"!=typeof this.map[w]||this[w]||O.push(w);for(n=0;n<O.length;n++)!function(e,t,n){e[n]=function(){return t[n].apply(t,arguments)}}(this,this.map,O[n])};return t}(this);GMaps.prototype.createControl=function(e){var t=document.createElement("div");t.style.cursor="pointer",t.style.fontFamily="Arial, sans-serif",t.style.fontSize="13px",t.style.boxShadow="rgba(0, 0, 0, 0.398438) 0px 2px 4px";for(var n in e.style)t.style[n]=e.style[n];e.id&&(t.id=e.id),e.classes&&(t.className=e.classes),e.content&&(t.innerHTML=e.content);for(var i in e.events)!function(t,n){google.maps.event.addDomListener(t,n,function(){e.events[n].apply(this,[this])})}(t,i);return t.index=1,t},GMaps.prototype.addControl=function(e){var t=google.maps.ControlPosition[e.position.toUpperCase()];delete e.position;var n=this.createControl(e);return this.controls.push(n),this.map.controls[t].push(n),n},GMaps.prototype.createMarker=function(e){if(void 0==e.lat&&void 0==e.lng&&void 0==e.position)throw"No latitude or longitude defined.";var t=this,n=e.details,i=e.fences,o=e.outside,a={position:new google.maps.LatLng(e.lat,e.lng),map:null};delete e.lat,delete e.lng,delete e.fences,delete e.outside;var r=extend_object(a,e),s=new google.maps.Marker(r);if(s.fences=i,e.infoWindow){s.infoWindow=new google.maps.InfoWindow(e.infoWindow);for(var l=["closeclick","content_changed","domready","position_changed","zindex_changed"],c=0;c<l.length;c++)!function(t,n){e.infoWindow[n]&&google.maps.event.addListener(t,n,function(t){e.infoWindow[n].apply(this,[t])})}(s.infoWindow,l[c])}for(var u=["animation_changed","clickable_changed","cursor_changed","draggable_changed","flat_changed","icon_changed","position_changed","shadow_changed","shape_changed","title_changed","visible_changed","zindex_changed"],d=["dblclick","drag","dragend","dragstart","mousedown","mouseout","mouseover","mouseup"],c=0;c<u.length;c++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(){e[n].apply(this,[this])})}(s,u[c]);for(var c=0;c<d.length;c++)!function(t,n,i){e[i]&&google.maps.event.addListener(n,i,function(n){n.pixel||(n.pixel=t.getProjection().fromLatLngToPoint(n.latLng)),e[i].apply(this,[n])})}(this.map,s,d[c]);return google.maps.event.addListener(s,"click",function(){this.details=n,e.click&&e.click.apply(this,[this]),s.infoWindow&&(t.hideInfoWindows(),s.infoWindow.open(t.map,s))}),google.maps.event.addListener(s,"rightclick",function(n){n.marker=this,e.rightclick&&e.rightclick.apply(this,[n]),void 0!=window.context_menu[t.el.id].marker&&t.buildContextMenu("marker",n)}),s.fences&&google.maps.event.addListener(s,"dragend",function(){t.checkMarkerGeofence(s,function(e,t){o(e,t)})}),s},GMaps.prototype.addMarker=function(e){var t;if(e.hasOwnProperty("gm_accessors_"))t=e;else{if(!(e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")||e.position))throw"No latitude or longitude defined.";t=this.createMarker(e)}return t.setMap(this.map),this.markerClusterer&&this.markerClusterer.addMarker(t),this.markers.push(t),GMaps.fire("marker_added",t,this),t},GMaps.prototype.addMarkers=function(e){for(var t,n=0;t=e[n];n++)this.addMarker(t);return this.markers},GMaps.prototype.hideInfoWindows=function(){for(var e,t=0;e=this.markers[t];t++)e.infoWindow&&e.infoWindow.close()},GMaps.prototype.removeMarker=function(e){for(var t=0;t<this.markers.length;t++)if(this.markers[t]===e){this.markers[t].setMap(null),this.markers.splice(t,1),GMaps.fire("marker_removed",e,this);break}return e},GMaps.prototype.removeMarkers=function(e){for(var e=e||this.markers,t=0;t<this.markers.length;t++)this.markers[t]===e[t]&&this.markers[t].setMap(null);for(var n=[],t=0;t<this.markers.length;t++)null!=this.markers[t].getMap()&&n.push(this.markers[t]);this.markers=n},GMaps.prototype.drawOverlay=function(e){var t=new google.maps.OverlayView,n=!0;return t.setMap(this.map),null!=e.auto_show&&(n=e.auto_show),t.onAdd=function(){var n=document.createElement("div");n.style.borderStyle="none",n.style.borderWidth="0px",n.style.position="absolute",n.style.zIndex=100,n.innerHTML=e.content,t.el=n,e.layer||(e.layer="overlayLayer");var i=this.getPanes(),o=i[e.layer],a=["contextmenu","DOMMouseScroll","dblclick","mousedown"];o.appendChild(n);for(var r=0;r<a.length;r++)!function(e,t){google.maps.event.addDomListener(e,t,function(e){-1!=navigator.userAgent.toLowerCase().indexOf("msie")&&document.all?(e.cancelBubble=!0,e.returnValue=!1):e.stopPropagation()})}(n,a[r]);google.maps.event.trigger(this,"ready")},t.draw=function(){var i=this.getProjection(),o=i.fromLatLngToDivPixel(new google.maps.LatLng(e.lat,e.lng));e.horizontalOffset=e.horizontalOffset||0,e.verticalOffset=e.verticalOffset||0;var a=t.el,r=a.children[0],s=r.clientHeight,l=r.clientWidth;switch(e.verticalAlign){case"top":a.style.top=o.y-s+e.verticalOffset+"px";break;default:case"middle":a.style.top=o.y-s/2+e.verticalOffset+"px";break;case"bottom":a.style.top=o.y+e.verticalOffset+"px"}switch(e.horizontalAlign){case"left":a.style.left=o.x-l+e.horizontalOffset+"px";break;default:case"center":a.style.left=o.x-l/2+e.horizontalOffset+"px";break;case"right":a.style.left=o.x+e.horizontalOffset+"px"}a.style.display=n?"block":"none",n||e.show.apply(this,[a])},t.onRemove=function(){var n=t.el;e.remove?e.remove.apply(this,[n]):(t.el.parentNode.removeChild(t.el),t.el=null)},this.overlays.push(t),t},GMaps.prototype.removeOverlay=function(e){for(var t=0;t<this.overlays.length;t++)if(this.overlays[t]===e){this.overlays[t].setMap(null),this.overlays.splice(t,1);break}},GMaps.prototype.removeOverlays=function(){for(var e,t=0;e=this.overlays[t];t++)e.setMap(null);this.overlays=[]},GMaps.prototype.drawPolyline=function(e){var t=[],n=e.path;if(n.length)if(void 0===n[0][0])t=n;else for(var i,o=0;i=n[o];o++)t.push(new google.maps.LatLng(i[0],i[1]));var a={map:this.map,path:t,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight,geodesic:e.geodesic,clickable:!0,editable:!1,visible:!0};e.hasOwnProperty("clickable")&&(a.clickable=e.clickable),e.hasOwnProperty("editable")&&(a.editable=e.editable),e.hasOwnProperty("icons")&&(a.icons=e.icons),e.hasOwnProperty("zIndex")&&(a.zIndex=e.zIndex);for(var r=new google.maps.Polyline(a),s=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],l=0;l<s.length;l++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(t){e[n].apply(this,[t])})}(r,s[l]);return this.polylines.push(r),GMaps.fire("polyline_added",r,this),r},GMaps.prototype.removePolyline=function(e){for(var t=0;t<this.polylines.length;t++)if(this.polylines[t]===e){this.polylines[t].setMap(null),this.polylines.splice(t,1),GMaps.fire("polyline_removed",e,this);break}},GMaps.prototype.removePolylines=function(){for(var e,t=0;e=this.polylines[t];t++)e.setMap(null);this.polylines=[]},GMaps.prototype.drawCircle=function(e){e=extend_object({map:this.map,center:new google.maps.LatLng(e.lat,e.lng)},e),delete e.lat,delete e.lng;for(var t=new google.maps.Circle(e),n=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],i=0;i<n.length;i++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(t){e[n].apply(this,[t])})}(t,n[i]);return this.polygons.push(t),t},GMaps.prototype.drawRectangle=function(e){e=extend_object({map:this.map},e);var t=new google.maps.LatLngBounds(new google.maps.LatLng(e.bounds[0][0],e.bounds[0][1]),new google.maps.LatLng(e.bounds[1][0],e.bounds[1][1]));e.bounds=t;for(var n=new google.maps.Rectangle(e),i=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],o=0;o<i.length;o++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(t){e[n].apply(this,[t])})}(n,i[o]);return this.polygons.push(n),n},GMaps.prototype.drawPolygon=function(e){var t=!1;e.hasOwnProperty("useGeoJSON")&&(t=e.useGeoJSON),delete e.useGeoJSON,e=extend_object({map:this.map},e),0==t&&(e.paths=[e.paths.slice(0)]),e.paths.length>0&&e.paths[0].length>0&&(e.paths=array_flat(array_map(e.paths,arrayToLatLng,t)));for(var n=new google.maps.Polygon(e),i=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],o=0;o<i.length;o++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(t){e[n].apply(this,[t])})}(n,i[o]);return this.polygons.push(n),GMaps.fire("polygon_added",n,this),n},GMaps.prototype.removePolygon=function(e){for(var t=0;t<this.polygons.length;t++)if(this.polygons[t]===e){this.polygons[t].setMap(null),this.polygons.splice(t,1),GMaps.fire("polygon_removed",e,this);break}},GMaps.prototype.removePolygons=function(){for(var e,t=0;e=this.polygons[t];t++)e.setMap(null);this.polygons=[]},GMaps.prototype.getFromFusionTables=function(e){var t=e.events;delete e.events;var n=e,i=new google.maps.FusionTablesLayer(n);for(var o in t)!function(e,n){google.maps.event.addListener(e,n,function(e){t[n].apply(this,[e])})}(i,o);return this.layers.push(i),i},GMaps.prototype.loadFromFusionTables=function(e){var t=this.getFromFusionTables(e);return t.setMap(this.map),t},GMaps.prototype.getFromKML=function(e){var t=e.url,n=e.events;delete e.url,delete e.events;var i=e,o=new google.maps.KmlLayer(t,i);for(var a in n)!function(e,t){google.maps.event.addListener(e,t,function(e){n[t].apply(this,[e])})}(o,a);return this.layers.push(o),o},GMaps.prototype.loadFromKML=function(e){var t=this.getFromKML(e);return t.setMap(this.map),t},GMaps.prototype.addLayer=function(e,t){t=t||{};var n;switch(e){case"weather":this.singleLayers.weather=n=new google.maps.weather.WeatherLayer;break;case"clouds":this.singleLayers.clouds=n=new google.maps.weather.CloudLayer;break;case"traffic":this.singleLayers.traffic=n=new google.maps.TrafficLayer;break;case"transit":this.singleLayers.transit=n=new google.maps.TransitLayer;break;case"bicycling":this.singleLayers.bicycling=n=new google.maps.BicyclingLayer;break;case"panoramio":this.singleLayers.panoramio=n=new google.maps.panoramio.PanoramioLayer,n.setTag(t.filter),delete t.filter,t.click&&google.maps.event.addListener(n,"click",function(e){t.click(e),delete t.click});break;case"places":if(this.singleLayers.places=n=new google.maps.places.PlacesService(this.map),t.search||t.nearbySearch){var i={bounds:t.bounds||null,keyword:t.keyword||null,location:t.location||null,name:t.name||null,radius:t.radius||null,rankBy:t.rankBy||null,types:t.types||null};t.search&&n.search(i,t.search),t.nearbySearch&&n.nearbySearch(i,t.nearbySearch)}if(t.textSearch){var o={bounds:t.bounds||null,location:t.location||null,query:t.query||null,radius:t.radius||null};n.textSearch(o,t.textSearch)}}return void 0!==n?("function"==typeof n.setOptions&&n.setOptions(t),"function"==typeof n.setMap&&n.setMap(this.map),n):void 0},GMaps.prototype.removeLayer=function(e){if("string"==typeof e&&void 0!==this.singleLayers[e])this.singleLayers[e].setMap(null),delete this.singleLayers[e];else for(var t=0;t<this.layers.length;t++)if(this.layers[t]===e){this.layers[t].setMap(null),this.layers.splice(t,1);break}};var travelMode,unitSystem;GMaps.prototype.getRoutes=function(e){switch(e.travelMode){case"bicycling":travelMode=google.maps.TravelMode.BICYCLING;break;case"transit":travelMode=google.maps.TravelMode.TRANSIT;break;case"driving":travelMode=google.maps.TravelMode.DRIVING;break;default:travelMode=google.maps.TravelMode.WALKING}unitSystem="imperial"===e.unitSystem?google.maps.UnitSystem.IMPERIAL:google.maps.UnitSystem.METRIC;var t={avoidHighways:!1,avoidTolls:!1,optimizeWaypoints:!1,waypoints:[]},n=extend_object(t,e);n.origin=/string/.test(typeof e.origin)?e.origin:new google.maps.LatLng(e.origin[0],e.origin[1]),n.destination=/string/.test(typeof e.destination)?e.destination:new google.maps.LatLng(e.destination[0],e.destination[1]),n.travelMode=travelMode,n.unitSystem=unitSystem,delete n.callback;var i=this,o=new google.maps.DirectionsService;o.route(n,function(t,n){if(n===google.maps.DirectionsStatus.OK)for(var o in t.routes)t.routes.hasOwnProperty(o)&&i.routes.push(t.routes[o]);e.callback&&e.callback(i.routes)})},GMaps.prototype.removeRoutes=function(){this.routes=[]},GMaps.prototype.getElevations=function(e){e=extend_object({locations:[],path:!1,samples:256},e),e.locations.length>0&&e.locations[0].length>0&&(e.locations=array_flat(array_map([e.locations],arrayToLatLng,!1)));var t=e.callback;delete e.callback;var n=new google.maps.ElevationService;if(e.path){var i={path:e.locations,samples:e.samples};n.getElevationAlongPath(i,function(e,n){t&&"function"==typeof t&&t(e,n)})}else delete e.path,delete e.samples,n.getElevationForLocations(e,function(e,n){t&&"function"==typeof t&&t(e,n)})},GMaps.prototype.cleanRoute=GMaps.prototype.removePolylines,GMaps.prototype.drawRoute=function(e){var t=this;this.getRoutes({origin:e.origin,destination:e.destination,travelMode:e.travelMode,waypoints:e.waypoints,unitSystem:e.unitSystem,callback:function(n){n.length>0&&(t.drawPolyline({path:n[n.length-1].overview_path,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight}),e.callback&&e.callback(n[n.length-1]))}})},GMaps.prototype.travelRoute=function(e){if(e.origin&&e.destination)this.getRoutes({origin:e.origin,destination:e.destination,travelMode:e.travelMode,waypoints:e.waypoints,callback:function(t){if(t.length>0&&e.start&&e.start(t[t.length-1]),t.length>0&&e.step){var n=t[t.length-1];if(n.legs.length>0)for(var i,o=n.legs[0].steps,a=0;i=o[a];a++)i.step_number=a,e.step(i,n.legs[0].steps.length-1)}t.length>0&&e.end&&e.end(t[t.length-1])}});else if(e.route&&e.route.legs.length>0)for(var t,n=e.route.legs[0].steps,i=0;t=n[i];i++)t.step_number=i,e.step(t)},GMaps.prototype.drawSteppedRoute=function(e){var t=this;if(e.origin&&e.destination)this.getRoutes({origin:e.origin,destination:e.destination,travelMode:e.travelMode,waypoints:e.waypoints,callback:function(n){if(n.length>0&&e.start&&e.start(n[n.length-1]),n.length>0&&e.step){var i=n[n.length-1];if(i.legs.length>0)for(var o,a=i.legs[0].steps,r=0;o=a[r];r++)o.step_number=r,t.drawPolyline({path:o.path,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight}),e.step(o,i.legs[0].steps.length-1)}n.length>0&&e.end&&e.end(n[n.length-1])}});else if(e.route&&e.route.legs.length>0)for(var n,i=e.route.legs[0].steps,o=0;n=i[o];o++)n.step_number=o,t.drawPolyline({path:n.path,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight}),e.step(n)},GMaps.Route=function(e){this.origin=e.origin,this.destination=e.destination,this.waypoints=e.waypoints,this.map=e.map,this.route=e.route,this.step_count=0,this.steps=this.route.legs[0].steps,this.steps_length=this.steps.length,this.polyline=this.map.drawPolyline({path:new google.maps.MVCArray,strokeColor:e.strokeColor,strokeOpacity:e.strokeOpacity,strokeWeight:e.strokeWeight}).getPath()},GMaps.Route.prototype.getRoute=function(t){var n=this;this.map.getRoutes({origin:this.origin,destination:this.destination,travelMode:t.travelMode,waypoints:this.waypoints||[],callback:function(){n.route=e[0],t.callback&&t.callback.call(n)}})},GMaps.Route.prototype.back=function(){if(this.step_count>0){this.step_count--;var e=this.route.legs[0].steps[this.step_count].path;for(var t in e)e.hasOwnProperty(t)&&this.polyline.pop()}},GMaps.Route.prototype.forward=function(){if(this.step_count<this.steps_length){var e=this.route.legs[0].steps[this.step_count].path;for(var t in e)e.hasOwnProperty(t)&&this.polyline.push(e[t]);this.step_count++}},GMaps.prototype.checkGeofence=function(e,t,n){return n.containsLatLng(new google.maps.LatLng(e,t))},GMaps.prototype.checkMarkerGeofence=function(e,t){if(e.fences)for(var n,i=0;n=e.fences[i];i++){var o=e.getPosition();this.checkGeofence(o.lat(),o.lng(),n)||t(e,n)}},GMaps.prototype.toImage=function(e){var e=e||{},t={};if(t.size=e.size||[this.el.clientWidth,this.el.clientHeight],t.lat=this.getCenter().lat(),t.lng=this.getCenter().lng(),this.markers.length>0){t.markers=[];for(var n=0;n<this.markers.length;n++)t.markers.push({lat:this.markers[n].getPosition().lat(),lng:this.markers[n].getPosition().lng()})}if(this.polylines.length>0){var i=this.polylines[0];t.polyline={},t.polyline.path=google.maps.geometry.encoding.encodePath(i.getPath()),t.polyline.strokeColor=i.strokeColor,t.polyline.strokeOpacity=i.strokeOpacity,t.polyline.strokeWeight=i.strokeWeight}return GMaps.staticMapURL(t)},GMaps.staticMapURL=function(e){function t(e,t){if("#"===e[0]&&(e=e.replace("#","0x"),t)){if(t=parseFloat(t),t=Math.min(1,Math.max(t,0)),0===t)return"0x00000000";t=(255*t).toString(16),1===t.length&&(t+=t),e=e.slice(0,8)+t}return e}var n,i=[],o="http://maps.googleapis.com/maps/api/staticmap";e.url&&(o=e.url,delete e.url),o+="?";var a=e.markers;delete e.markers,!a&&e.marker&&(a=[e.marker],delete e.marker);var r=e.polyline;if(delete e.polyline,e.center)i.push("center="+e.center),delete e.center;else if(e.address)i.push("center="+e.address),delete e.address;else if(e.lat)i.push(["center=",e.lat,",",e.lng].join("")),delete e.lat,delete e.lng;else if(e.visible){var s=encodeURI(e.visible.join("|"));i.push("visible="+s)}var l=e.size;l?(l.join&&(l=l.join("x")),delete e.size):l="630x300",i.push("size="+l),e.zoom||(e.zoom=15);var c=e.hasOwnProperty("sensor")?!!e.sensor:!0;delete e.sensor,i.push("sensor="+c);for(var u in e)e.hasOwnProperty(u)&&i.push(u+"="+e[u]);if(a)for(var d,h,f=0;n=a[f];f++)d=[],n.size&&"normal"!==n.size?d.push("size:"+n.size):n.icon&&d.push("icon:"+encodeURI(n.icon)),n.color&&d.push("color:"+n.color.replace("#","0x")),n.label&&d.push("label:"+n.label[0].toUpperCase()),h=n.address?n.address:n.lat+","+n.lng,d.length||0===f?(d.push(h),d=d.join("|"),i.push("markers="+encodeURI(d))):(d=i.pop()+encodeURI("|"+h),i.push(d));if(r){if(n=r,r=[],n.strokeWeight&&r.push("weight:"+parseInt(n.strokeWeight,10)),n.strokeColor){var p=t(n.strokeColor,n.strokeOpacity);r.push("color:"+p)}if(n.fillColor){var m=t(n.fillColor,n.fillOpacity);r.push("fillcolor:"+m)}var g=n.path;if(g.join)for(var v,b=0;v=g[b];b++)r.push(v.join(","));else r.push("enc:"+g);r=r.join("|"),i.push("path="+encodeURI(r))}return i=i.join("&"),o+i},GMaps.prototype.addMapType=function(e,t){if(!t.hasOwnProperty("getTileUrl")||"function"!=typeof t.getTileUrl)throw"'getTileUrl' function required.";t.tileSize=t.tileSize||new google.maps.Size(256,256);var n=new google.maps.ImageMapType(t);this.map.mapTypes.set(e,n)},GMaps.prototype.addOverlayMapType=function(e){if(!e.hasOwnProperty("getTile")||"function"!=typeof e.getTile)throw"'getTile' function required.";var t=e.index;delete e.index,this.map.overlayMapTypes.insertAt(t,e)},GMaps.prototype.removeOverlayMapType=function(e){this.map.overlayMapTypes.removeAt(e)},GMaps.prototype.addStyle=function(e){var t=new google.maps.StyledMapType(e.styles,e.styledMapName);this.map.mapTypes.set(e.mapTypeId,t)},GMaps.prototype.setStyle=function(e){this.map.setMapTypeId(e)},GMaps.prototype.createPanorama=function(e){return e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")||(e.lat=this.getCenter().lat(),e.lng=this.getCenter().lng()),this.panorama=GMaps.createPanorama(e),this.map.setStreetView(this.panorama),this.panorama},GMaps.createPanorama=function(e){var t=getElementById(e.el,e.context);e.position=new google.maps.LatLng(e.lat,e.lng),delete e.el,delete e.context,delete e.lat,delete e.lng;for(var n=["closeclick","links_changed","pano_changed","position_changed","pov_changed","resize","visible_changed"],i=extend_object({visible:!0},e),o=0;o<n.length;o++)delete i[n[o]];for(var a=new google.maps.StreetViewPanorama(t,i),o=0;o<n.length;o++)!function(t,n){e[n]&&google.maps.event.addListener(t,n,function(){e[n].apply(this)})}(a,n[o]);return a},GMaps.prototype.on=function(e,t){return GMaps.on(e,this,t)},GMaps.prototype.off=function(e){GMaps.off(e,this)},GMaps.custom_events=["marker_added","marker_removed","polyline_added","polyline_removed","polygon_added","polygon_removed","geolocated","geolocation_failed"],GMaps.on=function(e,t,n){if(-1==GMaps.custom_events.indexOf(e))return google.maps.event.addListener(t,e,n);var i={handler:n,eventName:e};return t.registered_events[e]=t.registered_events[e]||[],t.registered_events[e].push(i),i},GMaps.off=function(e,t){-1==GMaps.custom_events.indexOf(e)?google.maps.event.clearListeners(t,e):t.registered_events[e]=[]},GMaps.fire=function(e,t,n){if(-1==GMaps.custom_events.indexOf(e))google.maps.event.trigger(t,e,Array.prototype.slice.apply(arguments).slice(2));else if(e in n.registered_events)for(var i=n.registered_events[e],o=0;o<i.length;o++)!function(e,t,n){e.apply(t,[n])}(i[o].handler,n,t)},GMaps.geolocate=function(e){var t=e.always||e.complete;navigator.geolocation?navigator.geolocation.getCurrentPosition(function(n){e.success(n),t&&t()},function(n){e.error(n),t&&t()},e.options):(e.not_supported(),t&&t())},GMaps.geocode=function(e){this.geocoder=new google.maps.Geocoder;var t=e.callback;e.hasOwnProperty("lat")&&e.hasOwnProperty("lng")&&(e.latLng=new google.maps.LatLng(e.lat,e.lng)),delete e.lat,delete e.lng,delete e.callback,this.geocoder.geocode(e,function(e,n){t(e,n)})},google.maps.Polygon.prototype.getBounds||(google.maps.Polygon.prototype.getBounds=function(){for(var e,t=new google.maps.LatLngBounds,n=this.getPaths(),i=0;i<n.getLength();i++){e=n.getAt(i);for(var o=0;o<e.getLength();o++)t.extend(e.getAt(o))}return t}),google.maps.Polygon.prototype.containsLatLng||(google.maps.Polygon.prototype.containsLatLng=function(e){var t=this.getBounds();if(null!==t&&!t.contains(e))return!1;for(var n=!1,i=this.getPaths().getLength(),o=0;i>o;o++)for(var a=this.getPaths().getAt(o),r=a.getLength(),s=r-1,l=0;r>l;l++){var c=a.getAt(l),u=a.getAt(s);(c.lng()<e.lng()&&u.lng()>=e.lng()||u.lng()<e.lng()&&c.lng()>=e.lng())&&c.lat()+(e.lng()-c.lng())/(u.lng()-c.lng())*(u.lat()-c.lat())<e.lat()&&(n=!n),s=l}return n}),google.maps.LatLngBounds.prototype.containsLatLng=function(e){return this.contains(e)},google.maps.Marker.prototype.setFences=function(e){this.fences=e},google.maps.Marker.prototype.addFence=function(e){this.fences.push(e)},google.maps.Marker.prototype.getId=function(){return this.__gm_id},Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),n=t.length>>>0;if(0===n)return-1;var i=0;if(arguments.length>1&&(i=Number(arguments[1]),i!=i?i=0:0!=i&&1/0!=i&&i!=-1/0&&(i=(i>0||-1)*Math.floor(Math.abs(i)))),i>=n)return-1;for(var o=i>=0?i:Math.max(n-Math.abs(i),0);n>o;o++)if(o in t&&t[o]===e)return o;return-1});
?>
Онлайн: 0
Реклама