blob: 2ddf2504593ef2d245d061dabc54e1faf13a3ef2 [file] [log] [blame]
/**
* @module RD-Google Map
* @author Evgeniy Gusarov
* @see https://ua.linkedin.com/pub/evgeniy-gusarov/8a/a40/54a
* @version 0.1.4
*/
!function(a){"use strict";var o={cntClass:"rd-google-map",mapClass:"rd-google-map__model",locationsClass:"rd-google-map__locations",marker:{basic:"images/gmap_marker.png",active:"images/gmap_marker_active.png"},styles:[]},t={map:{x:-73.9924068,y:40.646197,zoom:14},locations:[]},e=function(o,t){var e=o.parent().find("."+t.locationsClass).find("li"),n=[];return e.length>0&&e.each(function(o){var e=a(this);e.data("x")&&e.data("y")&&(n[o]={x:e.data("x"),y:e.data("y"),basic:e.data("basic")?e.data("basic"):t.marker.basic,active:e.data("active")?e.data("active"):t.marker.active},n[o].content=a.trim(e.html())?'<div class="iw-content">'+e.html()+"</div>":!1)}),n};a.fn.googleMap=function(n){n=a.extend(!0,{},o,n),a(this).each(function(){var o=a(this),s=a.extend(!0,{},t,{map:{x:o.data("x"),y:o.data("y"),zoom:o.data("zoom")},locations:e(o,n)}),i=new google.maps.Map(this,{center:new google.maps.LatLng(parseFloat(s.map.y),parseFloat(s.map.x)),scrollwheel:!1,styles:n.styles,zoom:s.map.zoom}),c=new google.maps.InfoWindow,l=[];for(var r in s.locations)l[r]=new google.maps.Marker({position:new google.maps.LatLng(parseFloat(s.locations[r].y),parseFloat(s.locations[r].x)),map:i,icon:s.locations[r].basic,index:r}),s.locations[r].content&&(google.maps.event.addListener(l[r],"click",function(){for(var o in l)l[o].setIcon(s.locations[o].basic);c.setContent(s.locations[this.index].content),c.open(i,this),a(".gm-style-iw").parent().parent().addClass("gm-wrapper"),this.setIcon(s.locations[this.index].active)}),google.maps.event.addListener(c,"closeclick",function(){for(var a in l)l[a].setIcon(s.locations[a].basic)}));google.maps.event.addDomListener(window,"resize",function(){i.setCenter(new google.maps.LatLng(parseFloat(s.map.y),parseFloat(s.map.x)))})})}}(jQuery);