forked from imranbaloch/jquery.gmapthumb
/
jquery.gmapthumb.min.js
4 lines (4 loc) · 1.84 KB
/
jquery.gmapthumb.min.js
1
2
3
4
/*! Google Map Thumb - v1.0. - 2012-05-13
* Created By: Imran Baloch
* Imran Baloch's Blog: http://weblogs.asp.net/imranbaloch */
(function(a){a.fn.gmapthumb=function(g){var c,e,k;return this.each(function(m,n){var p=g[m];if(!p||!(p instanceof google.maps.Map)){throw new Error("google.maps.Map object not found")}var o=a(this),l;o.delegate("div div div div div","mouseover",function(u){var s,t=a(this),r=t.position(),q=a('div:has(>img[src*="googleapis.com"])');l=undefined;if(q.length===0){return}q.each(function(){var v=a(this).position();if(v.left===r.left&&v.top===r.top){s=this;return false}});if(s&&(a("img",s).width()===256)){l=s;j();f(u,l)}i(u)});o.delegate("div div div div div","mousemove",function(q){if(!l){a(this).trigger("mouseover");return}f(q,l);i(q)});google.maps.event.addListener(p,"mouseout",function(){d()})});function b(){if(a(".gMapPopup").length===0){a("body").append('<div style="position: absolute;" class="gMapPopup"><img class="gMapImage" style="border: 5px solid #6d6d6d;" /><img class="gMapThumb" src="img/pointer.png" style="position: absolute;" /></div>')}c=a(".gMapPopup");e=a(".gMapThumb");k=a(".gMapImage")}function f(n,l){var m=h(l,n),p=h(document.body,n),o=a("img",l).attr("src");k.attr("src",o);c.css("left",(p.x+30*1)+"px");c.css("top",(p.y+30*1)+"px");e.css("left",m.x-2*1+"px");e.css("top",m.y-12*1+"px")}function h(o,l){var q=a(o),n=q.offset(),s={},r=q.css("borderLeftWidth"),p=q.css("borderTopWidth"),t=q.css("paddingTop"),m=q.css("paddingLeft");s.x=l.pageX-n.left+parseInt(isNaN(m)?0:m,10)+parseInt(isNaN(r)?0:r,10);s.y=l.pageY-n.top+parseInt(isNaN(t)?0:t,10)+parseInt(isNaN(p)?0:p,10);return s}function d(){if(!c){return}c.fadeOut("slow",function(){c.css("display","none")})}function j(){if(!c){b()}c.fadeIn("slow",function(){c.css("display","block")})}function i(l){l.stopPropagation();if(l.cancelBubble){l.cancelBubble=true}}}})(jQuery);