?
| Current Path : /home/webyoo/www/hanessiim/site/admin/js/google-map/ |
| Current File : /home/webyoo/www/hanessiim/site/admin/js/google-map/maplace.min.js |
/**
* Maplace.js 0.1.2c
*
* Copyright (c) 2013 Daniele Moraschi
* Licensed under the MIT license
* For all details and documentation:
* http://maplacejs.com
*/
(function(f,s,d,undefined){'use strict';var q,n,p;q={activateCurrent:function(c){this.html_element.find("select").val(c)},getHtml:function(){var c=this,a="",b;if(1<this.ln){a+='<select class="dropdown controls '+this.o.controls_cssclass+'">';this.ShowOnMenu(this.view_all_key)&&(a+='<option value="'+this.view_all_key+'">'+this.o.view_all_text+"</option>");for(b=0;b<this.ln;b+=1)this.ShowOnMenu(b)&&(a+='<option value="'+(b+1)+'">'+(this.o.locations[b].title||"#"+(b+1))+"</option>");a=f(a+"</select>").bind("change",function(){c.ViewOnMap(this.value)})}(b=
this.o.controls_title)&&(b=f('<div class="controls_title"></div>').css(this.o.controls_applycss?{fontWeight:"bold",fontSize:this.o.controls_on_map?"12px":"inherit",padding:"3px 10px 5px 0"}:{}).append(this.o.controls_title));return this.html_element=f('<div class="wrap_controls"></div>').append(b).append(a)}};n={html_a:function(c,a,b){var e=this;a=a||c+1;b=b||this.o.locations[c].title;c=f('<a data-load="'+a+'" id="ullist_a_'+a+'" href="#'+a+'" title="'+b+'"><span>'+(b||"#"+(c+1))+"</span></a>");c.css(this.o.controls_applycss?
{color:"#666",display:"block",padding:"5px",fontSize:this.o.controls_on_map?"12px":"inherit",textDecoration:"none"}:{});c.on("click",function(a){a.preventDefault();a=f(this).attr("data-load");e.ViewOnMap(a)});return c},activateCurrent:function(c){this.html_element.find("li").removeClass("active");this.html_element.find("#ullist_a_"+c).parent().addClass("active")},getHtml:function(){var c=f("<ul class='ullist controls "+this.o.controls_cssclass+"'></ul>").css(this.o.controls_applycss?{margin:0,padding:0,
listStyleType:"none"}:{}),a;this.ShowOnMenu(this.view_all_key)&&c.append(f("<li></li>").append(n.html_a.call(this,!1,this.view_all_key,this.o.view_all_text)));for(a=0;a<this.ln;a++)this.ShowOnMenu(a)&&c.append(f("<li></li>").append(n.html_a.call(this,a)));(a=this.o.controls_title)&&(a=f('<div class="controls_title"></div>').css(this.o.controls_applycss?{fontWeight:"bold",padding:"3px 10px 5px 0",fontSize:this.o.controls_on_map?"12px":"inherit"}:{}).append(this.o.controls_title));return this.html_element=
f('<div class="wrap_controls"></div>').append(a).append(c)}};p=function(){function c(a){this.VERSION="0.1.2";this.errors=[];this.loaded=!1;this.dev=!1;this.markers=[];this.oMap=!1;this.view_all_key="all";this.infowindow=null;this.ln=0;this.oMap=!1;this.directionsDisplay=this.directionsService=this.Fusion=this.Polygon=this.Polyline=this.current_index=this.current_control=this.controls_wrapper=this.canvas_map=this.map_div=this.oBounds=null;this.o={map_div:"#gmap",controls_div:"#controls",generate_controls:!0,
controls_type:"dropdown",controls_cssclass:"",controls_title:"",controls_on_map:!0,controls_applycss:!0,controls_position:d.maps.ControlPosition.RIGHT_TOP,type:"marker",view_all:!0,view_all_text:"View All",start:0,locations:[],commons:{},map_options:{mapTypeId:d.maps.MapTypeId.ROADMAP,zoom:1},stroke_options:{strokeColor:"#0000FF",strokeOpacity:0.8,strokeWeight:2,fillColor:"#0000FF",fillOpacity:0.4},directions_options:{travelMode:d.maps.TravelMode.DRIVING,unitSystem:d.maps.UnitSystem.METRIC,optimizeWaypoints:!1,
provideRouteAlternatives:!1,avoidHighways:!1,avoidTolls:!1},styles:{},fusion_options:{},directions_panel:null,draggable:!1,show_infowindows:!0,show_markers:!0,infowindow_type:"bubble",listeners:{},beforeViewAll:function(){},afterViewAll:function(){},beforeShow:function(a,e,c){},afterShow:function(a,e,c){},afterCreateMarker:function(a,e,c){},beforeCloseInfowindow:function(a,e){},afterCloseInfowindow:function(a,e){},beforeOpenInfowindow:function(a,e,c){},afterOpenInfowindow:function(a,e,c){},afterRoute:function(a,
e,c){},onPolylineClick:function(a){}};this.AddControl("dropdown",q);this.AddControl("list",n);f.extend(!0,this.o,a)}c.prototype.controls={};c.prototype.create_objMap=function(){var a=0,b;for(b in this.o.styles)this.o.styles.hasOwnProperty(b)&&(0===a&&(this.o.map_options.mapTypeControlOptions={mapTypeIds:[d.maps.MapTypeId.ROADMAP]}),a++,this.o.map_options.mapTypeControlOptions.mapTypeIds.push("map_style_"+a));if(this.loaded)this.oMap.setOptions(this.o.map_options);else try{this.map_div.css({position:"relative",
overflow:"hidden"}),this.canvas_map=f("<div>").addClass("canvas_map").css({width:"100%",height:"100%"}).appendTo(this.map_div),this.oMap=new d.maps.Map(this.canvas_map.get(0),this.o.map_options)}catch(e){this.errors.push(e.toString())}a=0;for(b in this.o.styles)this.o.styles.hasOwnProperty(b)&&(a++,this.oMap.mapTypes.set("map_style_"+a,new d.maps.StyledMapType(this.o.styles[b],{name:b})),this.oMap.setMapTypeId("map_style_"+a));this.debug("01")};c.prototype.add_markers_to_objMap=function(){var a;a=
this.o.type||"marker";switch(a){case "marker":for(a=0;a<this.ln;a++)this.create.marker.call(this,a);break;default:this.create[a].apply(this)}};c.prototype.create={marker:function(a){var b=this,e=this.o.locations[a],c,h,l,m,g=new d.maps.LatLng(e.lat,e.lon),r=!1===e.visible?!1:!0;f.extend(e,{position:g,map:this.oMap,zIndex:1E4,visible:!1===this.o.show_markers?!1:r});e.image&&(l=e.image_w||32,m=e.image_h||32,f.extend(e,{icon:new d.maps.MarkerImage(e.image,new d.maps.Size(l,m),new d.maps.Point(0,0),new d.maps.Point(l/
2,m/2))}));c=new d.maps.Marker(e);d.maps.event.addListener(c,"click",function(){b.o.beforeShow(a,e,c);h=!1===e.show_infowindows?!1:!0;b.o.show_infowindows&&h&&b.open_infowindow(a,c);b.oMap.panTo(g);e.zoom&&b.oMap.setZoom(e.zoom);b.current_control&&(b.o.generate_controls&&b.current_control.activateCurrent)&&b.current_control.activateCurrent.call(b,a+1);b.current_index=a;b.o.afterShow(a,e,c)});this.oBounds.extend(g);this.markers.push(c);this.o.afterCreateMarker(a,e,c);e.visible=r;return c},polyline:function(){var a,
b,e=[];for(a=0;a<this.ln;a++)b=new d.maps.LatLng(this.o.locations[a].lat,this.o.locations[a].lon),e.push(b),this.create.marker.call(this,a);f.extend(this.o.stroke_options,{path:e,map:this.oMap});this.Polyline?this.Polyline.setOptions(this.o.stroke_options):this.Polyline=new d.maps.Polyline(this.o.stroke_options)},polygon:function(){var a=this,b,e,c=[];for(b=0;b<this.ln;b++)e=new d.maps.LatLng(this.o.locations[b].lat,this.o.locations[b].lon),c.push(e),this.create.marker.call(this,b);f.extend(this.o.stroke_options,
{paths:c,editable:this.o.draggable,map:this.oMap});this.Polygon?this.Polygon.setOptions(this.o.stroke_options):this.Polygon=new d.maps.Polygon(this.o.stroke_options);d.maps.event.addListener(this.Polygon,"click",function(b){a.o.onPolylineClick(b)})},fusion:function(){f.extend(this.o.fusion_options,{styles:[this.o.stroke_options],map:this.oMap});this.Fusion?this.Fusion.setOptions(this.o.fusion_options):this.Fusion=new d.maps.FusionTablesLayer(this.o.fusion_options)},directions:function(){var a=this,
b,c,k,h,l,m=[],g=0;for(b=0;b<this.ln;b++)k=new d.maps.LatLng(this.o.locations[b].lat,this.o.locations[b].lon),0===b?h=k:b===this.ln-1?l=k:(c=!0===this.o.locations[b].stopover?!0:!1,m.push({location:k,stopover:c})),this.create.marker.call(this,b);f.extend(this.o.directions_options,{origin:h,destination:l,waypoints:m});this.directionsService||(this.directionsService=new d.maps.DirectionsService);this.directionsDisplay?this.directionsDisplay.setOptions({draggable:this.o.draggable}):this.directionsDisplay=
new d.maps.DirectionsRenderer({draggable:this.o.draggable});this.directionsDisplay.setMap(this.oMap);this.o.directions_panel&&(this.o.directions_panel=f(this.o.directions_panel),this.directionsDisplay.setPanel(this.o.directions_panel.get(0)));this.o.draggable&&d.maps.event.addListener(this.directionsDisplay,"directions_changed",function(){g=a.compute_distance(a.directionsDisplay.directions);a.o.afterRoute(g)});this.directionsService.route(this.o.directions_options,function(b,c){c===d.maps.DirectionsStatus.OK&&
(g=a.compute_distance(b),a.directionsDisplay.setDirections(b));a.o.afterRoute(g,c,b)})}};c.prototype.compute_distance=function(a){var b=0,c=a.routes[0],d=c.legs.length;for(a=0;a<d;a++)b+=c.legs[a].distance.value;return b};c.prototype.type_to_open={bubble:function(a){this.infowindow=new d.maps.InfoWindow({content:a.html||""})}};c.prototype.open_infowindow=function(a,b){this.CloseInfoWindow();var c=this.o.locations[a],d=c.type||this.o.infowindow_type;c.html&&this.type_to_open[d]&&(this.o.beforeOpenInfowindow(a,
c,b),this.type_to_open[d].call(this,c),this.infowindow.open(this.oMap,b),this.o.afterOpenInfowindow(a,c,b))};c.prototype.get_html_controls=function(){return this.controls[this.o.controls_type]&&this.controls[this.o.controls_type].getHtml?(this.current_control=this.controls[this.o.controls_type],this.current_control.getHtml.apply(this)):""};c.prototype.generate_controls=function(){if(this.o.controls_on_map){var a=f('<div class="on_gmap '+this.o.controls_type+' gmap_controls"></div>').css(this.o.controls_applycss?
{margin:"5px"}:{}),b=f(this.get_html_controls()).css(this.o.controls_applycss?{background:"#fff",padding:"5px",border:"1px solid rgb(113,123,135)",boxShadow:"rgba(0, 0, 0, 0.4) 0px 2px 4px",maxHeight:this.map_div.find(".canvas_map").outerHeight()-80,minWidth:100,overflowY:"auto",overflowX:"hidden"}:{});a.append(b);this.oMap.controls[this.o.controls_position].push(a.get(0))}else this.controls_wrapper.empty(),this.controls_wrapper.append(this.get_html_controls())};c.prototype.init_map=function(){var a=
this,b=0;this.Polyline&&this.Polyline.setMap(null);this.Polygon&&this.Polygon.setMap(null);this.Fusion&&this.Fusion.setMap(null);this.directionsDisplay&&this.directionsDisplay.setMap(null);if(this.markers){for(b in this.markers)if(this.markers[b])try{this.markers[b].setMap(null)}catch(c){a.errors.push(c)}this.markers.length=0;this.markers=[]}this.o.controls_on_map&&this.oMap.controls&&this.oMap.controls[this.o.controls_position].forEach(function(b,c){try{a.oMap.controls[this.o.controls_position].removeAt(c)}catch(e){a.errors.push(e)}});
this.oBounds=new d.maps.LatLngBounds;this.debug("02")};c.prototype.perform_load=function(){1===this.ln?(this.oMap.setCenter(this.markers[0].getPosition()),this.ViewOnMap(1)):0===this.ln?(this.o.map_options.set_center?this.oMap.setCenter(new d.maps.LatLng(this.o.map_options.set_center[0],this.o.map_options.set_center[1])):this.oMap.fitBounds(this.oBounds),this.oMap.setZoom(this.o.map_options.zoom)):(this.oMap.fitBounds(this.oBounds),"number"===typeof(this.o.start-0)&&0<this.o.start&&this.o.start<=
this.ln?this.ViewOnMap(this.o.start):this.ViewOnMap(this.view_all_key))};c.prototype.debug=function(a){this.dev&&this.errors.length&&console.log(a+": ",this.errors)};c.prototype.AddControl=function(a,b){if(!a||!b)return!1;this.controls[a]=b;return!0};c.prototype.CloseInfoWindow=function(){this.infowindow&&(this.current_index||0===this.current_index)&&(this.o.beforeCloseInfowindow(this.current_index,this.o.locations[this.current_index]),this.infowindow.close(),this.infowindow=null,this.o.afterCloseInfowindow(this.current_index,
this.o.locations[this.current_index]))};c.prototype.ShowOnMenu=function(a){if(a===this.view_all_key&&this.o.view_all&&1<this.ln)return!0;a=parseInt(a,10);if("number"===typeof(a-0)&&0<=a&&a<this.ln){var b=!1===this.o.locations[a].on_menu?!1:!0;if(!1!==this.o.locations[a].visible&&b)return!0}return!1};c.prototype.ViewOnMap=function(a){if(a===this.view_all_key)this.o.beforeViewAll(),this.current_index=a,0<this.o.locations.length&&(this.o.generate_controls&&this.current_control&&this.current_control.activateCurrent)&&
this.current_control.activateCurrent.apply(this,[a]),this.oMap.fitBounds(this.oBounds),this.CloseInfoWindow(),this.o.afterViewAll();else if(a=parseInt(a,10),"number"===typeof(a-0)&&0<a&&a<=this.ln)try{d.maps.event.trigger(this.markers[a-1],"click")}catch(b){this.errors.push(b.toString())}this.debug("03")};c.prototype.SetLocations=function(a,b){this.o.locations=a;b&&this.Load()};c.prototype.AddLocations=function(a,b){var c=this;f.isArray(a)&&f.each(a,function(a,b){c.o.locations.push(b)});f.isPlainObject(a)&&
this.o.locations.push(a);b&&this.Load()};c.prototype.AddLocation=function(a,b,c){f.isPlainObject(a)&&this.o.locations.splice(b,0,a);c&&this.Load()};c.prototype.RemoveLocations=function(a,b){var c=this,d=0;f.isArray(a)?f.each(a,function(a,b){b-d<c.ln&&c.o.locations.splice(b-d,1);d++}):a<this.ln&&this.o.locations.splice(a,1);b&&this.Load()};c.prototype.Loaded=function(){return this.loaded};c.prototype._init=function(){this.ln=this.o.locations.length;for(var a=0;a<this.ln;a++)f.extend(this.o.locations[a],
this.o.commons),this.o.locations[a].html&&(this.o.locations[a].html=this.o.locations[a].html.replace("%index",a+1),this.o.locations[a].html=this.o.locations[a].html.replace("%title",this.o.locations[a].title||""));this.map_div=f(this.o.map_div);this.controls_wrapper=f(this.o.controls_div)};c.prototype.Load=function(a){f.extend(!0,this.o,a);a&&a.locations&&(this.o.locations=a.locations);this._init();!1===this.o.visualRefresh?d.maps.visualRefresh=!1:d.maps.visualRefresh=!0;this.init_map();this.create_objMap();
this.add_markers_to_objMap();1<this.ln&&this.o.generate_controls||this.o.force_generate_controls?(this.o.generate_controls=!0,this.generate_controls()):this.o.generate_controls=!1;var b=this;if(this.loaded)this.perform_load();else{d.maps.event.addListenerOnce(this.oMap,"idle",function(){b.perform_load()});d.maps.event.addListener(this.oMap,"resize",function(){b.canvas_map.css({width:b.map_div.width(),height:b.map_div.height()})});for(var c in this.o.listeners){var k=this.oMap,h=this.o.listeners[c];
this.o.listeners.hasOwnProperty(c)&&d.maps.event.addListener(this.oMap,c,function(e){h(k,e)})}}this.loaded=!0};return c}();"function"==typeof define&&define.amd?define(function(){return p}):s.Maplace=p})(jQuery,this,google);